I am trying to connect my target device which is BGM13 from the server.
I am using this command through which connection request is send with bg_err_code is to be success.
But the target device is not connected as gecko_evt_le_connection_opened_id is not executed.
Can you help me clear this doubt.
Where do you call the le_gap_connect command? Do you call it from the le_gap_scan_response event? Please see the Thermometer Client example which implements a BLE master and client device.
I would clarify one thing. You wrote that you were trying to connect to the device from the server. Did you mean a BLE server which is advertising? You can initiate a connection only from the master device after receiving connectable advertisements. From the documentation of the le_gap_connect command:
Connect to an advertising device with the specified initiating PHY on which connectable advertisements on primary advertising channels are received.
Are you logging the le_connection_close event? This indicates that connection failures have occurred.
Yes, I meant BLE server.
Actually I am calling le_gap_connect in external signal event as i am implementing UART transmit and recieve in that event.
Also is it compulsary to start discovery before le_gap_connect?
Does the target device advertise itself correctly? You don't need to do GAP discovery as you know the Bluetooth address of the remote device and after the connect command the Bluetooth stack will enter a state where it continuously scans for the connectable advertising packets from the remote device.
Anyway, I would issue the le_gap_start_discovery command, and check the BD_ADDR in the le_gap_scan_response event. If there is a match, initiate connection using the le_gap_connect command. In this way you can check if the advertisements and the Bluetooth address is correct.
Yes i know the bluetooth address so that part is clear now.
I have a doubt that when le_gap_connect command is executed le_gap_connection_opened should be executed right?
But in my case its not being initiated.
The le_connection_opened event indicates that a new connection was opened. If you call the le_gap_connect command and there is no le_connection_opened event, it means that the device didn't get a connectable advertisement from the target device.
Thanks for the help Zupi,
We need to write the Address in reverse form as the parameter of le_gap_connect command.
For eg. F3 45 8E C2 59 9C will be 9C 59 C2 8E 45 F3.