#include #define TXRX_BUF_LEN 20 BLE ble; Timeout timeout; static uint8_t rx_buf[TXRX_BUF_LEN]; static uint8_t rx_buf_num; static uint8_t rx_state=0; // The Nordic UART Service static const uint8_t service1_uuid[] = {0x71, 0x3D, 0, 0, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E}; static const uint8_t service1_tx_uuid[] = {0x71, 0x3D, 0, 3, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E}; static const uint8_t service1_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 tx_value[TXRX_BUF_LEN] = {0,}; uint8_t rx_value[TXRX_BUF_LEN] = {0,}; uint8_t direction_data[] = {'a','d','r','i','a','n'}; uint8_t direction_data_[] = {'a','a','a','a','a','a'}; static uint8_t nus_buffer[20]; uint8_t numbers = 255; GattCharacteristic characteristic1(service1_tx_uuid, tx_value, 1, TXRX_BUF_LEN, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE ); //GattCharacteristic characteristic2(service1_rx_uuid, rx_value, 1, TXRX_BUF_LEN, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY); GattCharacteristic characteristic2(service1_rx_uuid, (uint8_t *)nus_buffer, sizeof(nus_buffer), sizeof(nus_buffer), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY); //GattCharacteristic characteristic2(service1_rx_uuid, rx_value, 1, TXRX_BUF_LEN, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY); GattCharacteristic *uartChars[] = {&characteristic1, &characteristic2}; GattService uartService(service1_uuid, uartChars, sizeof(uartChars) / sizeof(GattCharacteristic *)); void disconnectionCallBack(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) { Serial.println("Disconnected_!"); Serial.println("Restarting the advertising process_"); ble.startAdvertising(); } void writtenHandle(const GattWriteCallbackParams *Handler) { uint8_t buf[TXRX_BUF_LEN]; uint16_t bytesRead, index; Serial.println("onDataWritten_ : "); if (Handler->handle == characteristic1.getValueAttribute().getHandle()) { ble.readCharacteristicValue(characteristic1.getValueAttribute().getHandle(), buf, &bytesRead); Serial.print("bytesRead_: "); Serial.println(bytesRead, HEX); for(byte index=0; index