sensboston / BLEConsole

Bluetooth Low Energy device console app
https://sensboston.github.io/BLEConsole
MIT License
196 stars 73 forks source link

Read characteristic from BLE tinyshield #35

Closed Steven4899 closed 6 months ago

Steven4899 commented 8 months ago

Hello,

I've been experimenting with a BLE TinyShield paired with a TinyZero from TinyCircuits. Successfully, I managed to establish a connection and issue commands to the Arduino by writing them into the characteristic "Custom Characteristic: 6e400002-b5a3-f393-e0a9-e50e24dcca9e W" (details below). Despite thorough testing of all available characteristics and services, I can't seem to read the data written by the Arduino into the UART characteristic.

Any insights on this? I must admit, I'm quite new to coding.

Thank You!


What I tried using the BLEConsole: BLE: ls

Address Name

00: 49:d7:0d:da:c2:22 no_advertising_name

01: e1:81:69:a0:a8:53 BlueNRG

02: c4:07:1f:9f:b2:0b Forerunner 935

BLE: open #1 Device BlueNRG is disconnected. Connecting to BlueNRG. Found 3 services:

00: GenericAttribute

01: GenericAccess

02: Custom Service: 6e400001-b5a3-f393-e0a9-e50e24dcca9e

BLE: set #0 Selected service GenericAttribute.

00: ServiceChanged I

BLE: set #0 Selected service GenericAttribute.

00: ServiceChanged I

BLE: read #0 Read failed: ProtocolError 0x02: Read Not Permitted BLE: set #1 Selected service GenericAccess.

00: DeviceName RW

01: Appearance RW

02: PeripheralPreferredConnectionParameters R

BLE: read #0 Read 7 bytes. utf8: BlueNRG hex: 42 6C 75 65 4E 52 47 BLE: read #1 Read 2 bytes. utf8: hex: 00 00 BLE: read #2 Read 8 bytes. utf8: ???? ?? hex: FF FF FF FF 00 00 FF FF BLE: set #2 Selected service Custom Service: 6e400001-b5a3-f393-e0a9-e50e24dcca9e. #00: Custom Characteristic: 6e400002-b5a3-f393-e0a9-e50e24dcca9e W ---> characteristic I use to write

01: Custom Characteristic: 6e400003-b5a3-f393-e0a9-e50e24dcca9e N

BLE: read #0 Read failed: ProtocolError 0x02: Read Not Permitted BLE: read #1 Read failed: ProtocolError 0x02: Read Not Permitted


How the BLE shield writes data inside the characteristic:

uint8_t lib_aci_send_data(uint8_t ignore, uint8_t sendBuffer, uint8_t sendLength) { return !Write_UART_TX((char)sendBuffer, sendLength); }

uint8_t Write_UART_TX(char* TXdata, uint8_t datasize) { tBleStatus ret;

ret = aci_gatt_update_char_value(UARTServHandle, UARTRXCharHandle, 0, datasize, (uint8_t *)TXdata);

if (ret != BLE_STATUS_SUCCESS) { PRINTF("Error while updating UART characteristic.\n") ; return BLE_STATUS_ERROR ; } return BLE_STATUS_SUCCESS; }

AND

if (!lib_aci_send_data(PIPE_UART_OVER_BTLE_UART_TX_TX, (uint8_t*)sendBuffer, sendLength)) { SerialMonitorInterface.println(F("TX dropped!")); }

sensboston commented 6 months ago

Probably it's an issue in your own code. I don't have these "Tiny" stuff and have no plans to try but my Arduino firmware for my ESP32 BLE enabled gadgets are working pretty fine, right out of box.

P.S. I don't provide a free consultation but if you're working on commercial project, I can provide you consulting services.