
BLE Nano Code.Tested with Integrated mDot code
Dependencies: BLE_API mbed nRF51822
Fork of eco_Labs_ble_Client by
Diff: ble_uart.cpp
- Revision:
- 33:17b8c186eb07
- Parent:
- 31:d25111c2fa21
- Child:
- 35:b2af2293635a
--- a/ble_uart.cpp Wed Dec 07 10:05:21 2016 +0000 +++ b/ble_uart.cpp Thu Dec 15 06:26:45 2016 +0000 @@ -20,15 +20,15 @@ #include "mbed.h" #include "BLE.h" #include "ble_types.h" +#include "spi_slave.h" #include "UARTService.h" /******************************************************************************/ /* Local Defines */ /******************************************************************************/ #define DEBUG(STR) { if (uart) uart->write(STR, strlen(STR)); } - -//#define BLE_DEVICE_NAME "Ecolab" - +//const static uint8_t AdvData[] = {"advdata"}; +const static uint8_t LocName[] ={"EcolabICE"}; /******************************************************************************/ /* Global Variables */ /******************************************************************************/ @@ -92,10 +92,12 @@ static void ble_dataReceiveCallback(const GattWriteCallbackParams *params) { - uint8_t buf[32] = {0}; - - memcpy(buf, params->data, params->len); - data_ready_cb(buf, params->len); + uint8_t buf[SPI_TX_BUF_SIZE] = {0}; + if(params->len<=SPI_TX_BUF_SIZE) + { + memcpy(buf, params->data, params->len); + data_ready_cb(buf, params->len); + } } /******************************************************************************/ @@ -124,11 +126,10 @@ ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (const uint8_t *)tx_buf, length); - 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 *)uuid16_list, sizeof(uuid16_list)); - ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); - +// 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 *)uuid16_list, sizeof(uuid16_list)); + ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME,LocName, sizeof(LocName)); ble.setAdvertisingInterval(160); /* 100ms; in multiples of 0.625ms. */ ble.startAdvertising();