
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:
- 25:96044c55f844
- Parent:
- 22:7980e0aa7938
- Child:
- 31:d25111c2fa21
--- a/ble_uart.cpp Sun Oct 23 12:46:21 2016 +0000 +++ b/ble_uart.cpp Sun Oct 23 14:41:49 2016 +0000 @@ -63,7 +63,6 @@ tx_buf[3] = 0x04; spi_slave_tx_data(tx_buf, 4); isDeviceConnected = true; - // enable_interrupt_line(true); toggle_led(); } @@ -79,11 +78,8 @@ tx_buf[1] = 0xA8; tx_buf[2] = 0x00; tx_buf[3] = 0x04; - spi_slave_tx_data(tx_buf, 4); - + spi_slave_tx_data(tx_buf, 4); isDeviceConnected = false; - //toggle_led(); - // enable_interrupt_line(false); ble.startAdvertising(); } @@ -96,28 +92,10 @@ static void ble_dataReceiveCallback(const GattWriteCallbackParams *params) { - - #if 1 uint8_t buf[32] = {0}; memcpy(buf, params->data, params->len); - - // if (data_ready_cb != NULL) { - data_ready_cb(buf, params->len); - // } - // spi_slave_tx_data(buf, (params->len)); - // ble_send_data((uint8_t *)params->data, params->len); - #endif - #if 0 - uint8_t tx_buf[10]; - tx_buf[0] = 0x01; - tx_buf[1] = 0xA5; - tx_buf[2] = 0x06; - tx_buf[3] = 0x0B; - tx_buf[4] = 0x0A; - tx_buf[5] = 0x04; - spi_slave_tx_data(tx_buf, 6); - #endif + data_ready_cb(buf, params->len); } /******************************************************************************/ @@ -140,17 +118,6 @@ ble.onDataWritten(ble_dataReceiveCallback); uart = new UARTService(ble); -#if 0 - /* setup advertising */ - ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED); - ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); - ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME, - (const uint8_t *)BLE_DEVICE_NAME, sizeof(BLE_DEVICE_NAME) - 1); - ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS, - (const uint8_t *)UARTServiceUUID_reversed, sizeof(UARTServiceUUID_reversed)); - - ble.setAdvertisingInterval(160); /* 100ms; in multiples of 0.625ms. */ -#endif /* Setup advertising */ ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);