Last active
August 29, 2015 14:09
-
-
Save sunnycyk/2fb8f9423cd7db11e069 to your computer and use it in GitHub Desktop.
Rapiro BLE Nano
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The Nordic UART Service | |
static const uint8_t uart_base_uuid[] = {0x71, 0x3D, 0, 0, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E}; | |
static const uint8_t uart_tx_uuid[] = {0x71, 0x3D, 0, 3, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E}; | |
static const uint8_t uart_rx_uuid[] = {0x71, 0x3D, 0, 2, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E}; | |
static const uint8_t uart_base_uuid_rev[] = {0x1E, 0x94, 0x8D, 0xF1, 0x48, 0x31, 0x94, 0xBA, 0x75, 0x4C, 0x3E, 0x50, 0, 0, 0x3D, 0x71}; | |
uint8_t txPayload[TXRX_BUF_LEN] = {0,}; | |
uint8_t rxPayload[TXRX_BUF_LEN] = {0,}; | |
GattCharacteristic txCharacteristic (uart_tx_uuid, txPayload, 1, TXRX_BUF_LEN, | |
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE); | |
GattCharacteristic rxCharacteristic (uart_rx_uuid, rxPayload, 1, TXRX_BUF_LEN, | |
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY); | |
GattCharacteristic *uartChars[] = {&txCharacteristic, &rxCharacteristic}; | |
GattService uartService(uart_base_uuid, uartChars, sizeof(uartChars) / sizeof(GattCharacteristic *)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void onDataWritten(uint16_t charHandle) | |
{ | |
uint8_t buf[TXRX_BUF_LEN]; | |
uint16_t bytesRead; | |
if (charHandle == txCharacteristic.getHandle()) | |
{ | |
ble.readCharacteristicValue(txCharacteristic.getHandle(), buf, &bytesRead); | |
for(uint8_t i=0; i<bytesRead; i++) | |
{ | |
Serial.write(buf[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment