bt_nus_send Failed

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.

Parents
  • Hello,

    So you have one DK acting as a peripheral, and you connect it to two mobile phones acting as centrals, is that the case?

    You figured out that bt_nus_send() returns something other than 0, since you are checking the value. But can you please check what it returns?

    int err;
    
    err = bt_nus_send(conn, data, len);
    
    if (err) {
        LOG_WRN("bt_nus_send() returned %d", err);
    }
    return err;

    Best regards,

    Edvin

Reply
  • Hello,

    So you have one DK acting as a peripheral, and you connect it to two mobile phones acting as centrals, is that the case?

    You figured out that bt_nus_send() returns something other than 0, since you are checking the value. But can you please check what it returns?

    int err;
    
    err = bt_nus_send(conn, data, len);
    
    if (err) {
        LOG_WRN("bt_nus_send() returned %d", err);
    }
    return err;

    Best regards,

    Edvin

Children
Related