this is a new program based on BLE_Uart_Peripheral. Change program name due to relation Client&Peripheral to Client&Server

Dependencies:   RingBuffer nRF51_Vdd nRF51_WakeUp

This is a BLE Server (Device) program for nRF51.
You can communicate with mbed BLE using "BLE_Uart_Client" program as follows.
/users/kenjiArai/code/BLE_Uart_Client/
Please refer following my notebook.
/users/kenjiArai/notebook/ble-client-and-peripheral-using-switch-sience-ty51/#

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Sat Apr 16 22:01:45 2016 +0000
Parent:
1:9b27a9710d94
Child:
3:fd5273a70b21
Commit message:
Show MAC address to modify Client main.cpp program

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Apr 16 12:12:59 2016 +0000
+++ b/main.cpp	Sat Apr 16 22:01:45 2016 +0000
@@ -22,7 +22,7 @@
  *      http://mbed.org/users/kenjiArai/
  *
  *      Started:  March     7th, 2016
- *      Revised:  April    16th, 2016
+ *      Revised:  April    17th, 2016
  *
  *  Original program:
  *      BLE_LoopbackUART
@@ -65,6 +65,7 @@
 const char      *deviceName = "UART_P";
 
 //  RAM -------------------------------------------------------------------------------------------
+Gap::Address_t      my_mac;
 uint8_t             tx_buf[24];
 uint8_t             tx_len          = 0;
 uint8_t             rx_buf[24];
@@ -112,6 +113,18 @@
     // Interrupt by switch
     wake_up_sw.fall(&interrupt_by_sw);
     ble.init();
+    Gap::AddressType_t my_mac_type;
+    ble.gap().getAddress(&my_mac_type, my_mac);
+    pc.printf(
+        "  my_MAC %02x:%02x:%02x:%02x:%02x:%02x (%s)\r\n",
+        my_mac[5], my_mac[4], my_mac[3], my_mac[2], my_mac[1], my_mac[0],
+        (my_mac_type == Gap::ADDR_TYPE_PUBLIC) ? "public" : "random"
+    );
+    pc.printf(
+        "  mac_board_? = {0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x};\r\n",
+        my_mac[0], my_mac[1], my_mac[2], my_mac[3], my_mac[4], my_mac[5]
+    );
+    pc.printf("  Please write above mac_board_?(?=1,2,...) data into Client main.cpp\r\n");
     ble.setDeviceName((const uint8_t *)deviceName);
     ble.onDisconnection(disconnectionCallback);
     ble.onDataWritten(onDataWritten);
@@ -135,7 +148,7 @@
     while(true){
         if (time_out){
 #if GOTO_SLEEP_MODE
-            wakeup.set_and_wait(10);
+            wakeup.set_and_wait(120);
             while(true){    // never come here but just in case
                 deepsleep();
             }
@@ -201,7 +214,7 @@
 }
 
 void adjust_line(uint8_t *bf){
-uint8_t i, c;
+    uint8_t i, c;
 
     for (i = 0; i <20; bf++, i++){
         c = *bf;