Communicate two microcontrollers via BLE

Hello,

I'm using a nRF52 DK to test BLE communication with another microcontroller. What I need to test is the nRF52 pairing with another brand microcontroller, send a data stream and close the connection.

Could you please tell me which example from the Bluetooth samples list I can use for starting?

Thanks for your attention.

Regards,

Parents
  • Hello ,

    Thank you very much. I've reviewed this example and it is supposed to connect with the first device with an strong signal. Is there a way to force the board to connect with the device with a given MAC address?

  • I can establish the connection but after some seconds the microcontroller resets:

    If I add the line for sending data over NUS (call to 'bt_nus_client_send' function) it fails with -128 error.

    1. The ble peer failed pairing.

    2.  /zephyr/subsys/bluetooth/host/gatt.c:5034: "__ASSERT(conn, "invalid parameters\n");"
      What means that bt_gatt_subscribe was not called with a valid connection object. This can be a consequential error due to the failed pairing attempt. 
  • I have added a call to the 'bt_gatt_dm_conn_get' function in the 'discovery_complete' function as follows:

    This way the microcontroller doesn't reset anymore. Nevertheless, the pairing still fails:

    How can I solve this problem?

  • Have you tried to initiate pairing from an Android/iOS device to confirm if that works? The pairing error ('9' == BT_SECURITY_ERR_UNSPECIFIED) does not help us pinpoint the problem, unfortunately.

  • From nRF Connect I cannot detect the device. Would it be possible given that the nRF52 is working as a central?

Reply Children
  • Sorry, I meant to ask if you were able to pair with the peripheral device from your phone.

  • Yes, with my phone I can pair with the peripheral device.

  • Thanks for confirming. This indicates that the problem is likely in the nRF FW. Can you please show where you are calling bt_conn_set_security() or post your main.c file here?

  • Below the main.c file:

  • I am not able to spot any errors in your implementation. Could you upload the full project so I can try reproducing this here?