I tried to establish communication between the two development boards and the phone. The specific process is as follows: One development board works in slave mode and the other board works in master mode to receive data sent from the slave and forward the received data to the cell phone.
The code for forwarding is as follows:
static uint8_t ble_data_received(struct bt_nus_client *nus,struct bt_conn *conn, const uint8_t *data, uint16_t len) { if (bt_nus_send(conn, data, len)) { LOG_WRN("Failed to send data over BLE connection"); } return BT_GATT_ITER_CONTINUE; }
But the serial debugger will show "Failed to send data over BLE_connection".
Another problem: I'm not quite sure where the "conn" is being assigned. Since this board works as both a slave and a master, I need to know which device the "conn" represents.