BLE Nano Code.Tested with Integrated mDot code

Dependencies:   BLE_API mbed nRF51822

Fork of eco_Labs_ble_Client by Happiest

Revision:
16:79b149aae10a
Parent:
15:67fbed00edf2
Child:
17:3fb1aafa4436
--- a/ble_uart.cpp	Tue Oct 11 09:49:14 2016 +0000
+++ b/ble_uart.cpp	Tue Oct 11 12:01:10 2016 +0000
@@ -27,14 +27,12 @@
 /******************************************************************************/
 #define DEBUG(STR) { if (uart) uart->write(STR, strlen(STR)); }
  
-#define BLE_DEVICE_NAME "Ecolab-ICE"
+#define BLE_DEVICE_NAME "Ecolab"
  
 /******************************************************************************/
 /* Global Variables                                                           */
 /******************************************************************************/
- 
-extern void enable_interrupt_line(bool status );
-extern void enable_interrupt_line(bool status );
+ extern void enable_interrupt_line(bool status,uint8_t pin_num );
 void spi_slave_tx_data(uint8_t *tx_buf, uint8_t len);
 bool isDeviceConnected = false;
  
@@ -116,16 +114,9 @@
     tx_buf[1] = 0xA5;
     tx_buf[2] = 0x06;
     tx_buf[3] = 0x0B;
-    tx_buf[4] = 0x04;
-    
- //   spi_slave_tx_data(tx_buf, 6);
-    
-    
-     if (data_ready_cb != NULL) {
-        data_ready_cb(tx_buf, 6);
-    }
-    
-    ble_send_data(tx_buf, 6);
+    tx_buf[4] = 0x0A;
+    tx_buf[5] = 0x04;    
+    spi_slave_tx_data(tx_buf, 6);
  #endif
 }
  
@@ -164,11 +155,13 @@
     /* Setup advertising */
     ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
     ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME,
-                                     (const uint8_t *)"BLE UART", sizeof("BLE UART") - 1);
+    ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME,
+                                     (const uint8_t *)BLE_DEVICE_NAME, sizeof(BLE_DEVICE_NAME) - 1);
     ble.accumulateAdvertisingPayload(GapAdvertisingData::INCOMPLETE_LIST_128BIT_SERVICE_IDS,
                                      (const uint8_t *)UARTServiceUUID_reversed, sizeof(UARTServiceUUID_reversed));
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::INCOMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)UARTServiceUUID_reversed, sizeof(UARTServiceUUID_reversed));                               
+ //   ble.accumulateAdvertisingPayload(GapAdvertisingData::INCOMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));  
+    ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
+                              
     ble.setAdvertisingInterval(160); /* 100ms; in multiples of 0.625ms. */
     ble.startAdvertising();
 }