I am currently in the evaluation stage of utilizing the nRF540 SoC as the chip for our product. However, during development and testing, we encountered the following issue:
Environment:
- nRF-Connect-SDK: v2.0.2
- Operating System: Windows 11 Pro - Version: 21H2
- BLE Central: nRF5340
- BLE Peripheral: DA14531
Description:
Our project involves two chips for BLE connection, one acting as the BLE Central (nRF5340) and the other as the BLE Peripheral (DA14531). For the Central role, we referred to the central_uart example (NUS), while for the Peripheral role, we inherited the old legacy code from the previous device (DA14531). Our BLE service and characteristics resemble the example (UUID128), there are differences in the values.
(1) -> BLE Central: nRF5340 (TX) ------------> (RX)BLE Peripheral: DA14531 (Property: Write Without Response)
(2) -> BLE Central: nRF5340 (RX) <------------ (TX)BLE Peripheral: DA14531 (Property: Notification)
We have successfully established a connection between the two devices. However, we encounter the following problem:
(1) - Unable to write data from Central to Peripheral: DA14531, configured as (1).
(2) - Functioning normally, receiving data from BLE peripheral.
Here is the configuration of BLE Peripheral (DA14531):
const struct attm_desc_128 custs1_att_db[CUSTS1_IDX_NB] = { /************************* * Serial over BLE Service ************************* */ [SERIAL_SVC] = {(uint8_t*)&att_decl_svc, ATT_UUID_128_LEN, PERM(RD, ENABLE), sizeof(custs1_serial), sizeof(custs1_serial), (uint8_t*)&custs1_serial}, // Rx Characteristic Declaration [SERIAL_RX_CHAR] = {(uint8_t*)&att_decl_char, ATT_UUID_16_LEN, PERM(RD, ENABLE), 0, 0, NULL}, // Rx Characteristic Value [SERIAL_RX_VAL] = {SERIAL_RX_UUID, ATT_UUID_128_LEN, PERM(WR, ENABLE) | PERM(WRITE_COMMAND, ENABLE), DEF_SERIAL_RX_CHAR_LEN, 0, NULL}, // Tx Characteristic Declaration [SERIAL_TX_CHAR] = {(uint8_t*)&att_decl_char, ATT_UUID_16_LEN, PERM(RD, ENABLE), 0, 0, NULL}, // Tx Characteristic Value/ [SERIAL_TX_VAL] = {SERIAL_TX_UUID, ATT_UUID_128_LEN, PERM(NTF, ENABLE), DEF_SERIAL_TX_CHAR_LEN, 0, NULL}, // Tx Characteristic Configuration Descriptor [SERIAL_TX_NTF_CFG] = {(uint8_t*)&att_desc_cfg, ATT_UUID_16_LEN, PERM(RD, ENABLE) | PERM(WR, ENABLE) | PERM(WRITE_REQ, ENABLE), sizeof(uint16_t), 0, NULL}, };
Here is the code on BLE Central for sending data:
int bt_nus_client_send(struct bt_nus_client *nus_c, const uint8_t *data, uint16_t len) { int err = 0; if (!nus_c->conn) { return -ENOTCONN; } nus_c->rx_write_params.func = on_sent; nus_c->rx_write_params.handle = nus_c->handles.rx; nus_c->rx_write_params.offset = 0; nus_c->rx_write_params.data = data; nus_c->rx_write_params.length = len; err = bt_gatt_write_without_response(nus_c->conn, nus_c->rx_write_params.handle, nus_c->rx_write_params.data, nus_c->rx_write_params.length, false); return err; }
Case 1:
(1) -> BLE Central: Mobile app (TX) ------------> (RX): BLE Peripheral: DA14531 (Property: Write Without Response)
(2) -> BLE Central: nRF5340 (RX) <------------ (TX)BLE Peripheral: DA14531 (Property: Notification)
Using our mobile app as BLE Central, we attempted to write data to Peripheral: DA14531, and it worked normally. We were able to send/receive data between (1) and (2) and vice versa.
Case 2:
(1) -> BLE Central: nRF5340 (TX) ------------> (RX): BLE Peripheral: nRF5340 (Property: Write Without Response)
(2) -> BLE Central: nRF5340 (RX) <------------ (TX)BLE Peripheral: nRF5340 (Property: Notification)
We used another nRF5340 chip, this time configured as a BLE peripheral, and ported the code from the DA14531 Peripheral. Again, it functioned normally, allowing us to send/receive data between (1) and (2) and vice versa.
However, we find these results puzzling.
Additional Information:
During debugging, I utilized BLE Central: nRF5340 and discovered services:
1. BLE Peripheral: DA14531
00> ATT[1]: UUID: 0x2803 Handle: 0x0018 Value: 00> 00> Characteristic: 0x0f9123ce-d5db-485e-b55a-6a7abd65eed9 Properties: 0x0004 00> 00> ATT[2]: UUID: 0x0f9123ce-d5db-485e-b55a-6a7abd65eed9 Handle: 0x0019 Value: 00> 00> ATT[3]: UUID: 0x2803 Handle: 0x001A Value: 00> 00> Characteristic: 0x4d1b75de-b864-4ca7-b6ef-6c571c34f3c8 Properties: 0x0010 00> 00> ATT[4]: UUID: 0x4d1b75de-b864-4ca7-b6ef-6c571c34f3c8 Handle: 0x001B Value: 00> 00> ATT[5]: UUID: 0x2902 Handle: 0x001C Value: 00> 00> CCCD 00>
2. BLE Peripheral: nRF5340
00> ATT[1]: UUID: 0x2803 Handle: 0x0011 Value: 00> 00> Characteristic: 0x0f9123ce-d5db-485e-b55a-6a7abd65eed9 Properties: 0x0004 00> 00> ATT[2]: UUID: 0x0f9123ce-d5db-485e-b55a-6a7abd65eed9 Handle: 0x0012 Value: 00> 00> ATT[3]: UUID: 0x2803 Handle: 0x0013 Value: 00> 00> Characteristic: 0x4d1b75de-b864-4ca7-b6ef-6c571c34f3c8 Properties: 0x0010 00> 00> ATT[4]: UUID: 0x4d1b75de-b864-4ca7-b6ef-6c571c34f3c8 Handle: 0x0014 Value: 00> 00> ATT[5]: UUID: 0x2902 Handle: 0x0015 Value: 00> 00> CCCD
The services, characteristics, and properties are quite similar except for the Handle value: 1 starts from 0x0018, while 2 starts from 0x0011.
2. Could you please help me analyze this issue? Thank you in advance.