This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Problem with connection BLED112 to BMD-300 (sometimes)

Hi,

Often when I try connect BLED112 dongle to bluetooth module BMD-300 by command:

ble_cmd_gap_connect_direct(DeviceMAC, gap_address_type_random, 60, 76, 100, 0);

event ble_rsp_gap_connect_direct is triggered with msg->result = 0x0181 (device in wrong state) and then event ble_evt_connection_status is not triggered.

After this, even when I unplug BLED112 and BMD-300 from USB (power) and connect again, problem still exists. I have to do it a few times to be able to connect. Why? Please look on the log from "Bluegiga BLE GUI Tool" program:

------------- Scanning start -------------

2017.10.27 07:25:10.196 ble_cmd_gap_discover mode: 1 (0x01)
2017.10.27 07:25:10.196 TX: 0001060201

2017.10.27 07:25:10.198 ble_rsp_gap_discover result:0x0000 ['No Error']
2017.10.27 07:25:10.198 RX: 000206020000

2017.10.27 07:25:12.885 ble_evt_gap_scan_response rssi: -51 (0xffffffcd) packet_type: 0 (0x00) sender:f6:28:b7:24:df:5b address_type: 1 (0x01) bond: 255 (0xff) data:0201050c094e6f726469635f55415254
2017.10.27 07:25:12.888 RX: 801b0600cd005bdf24b728f601ff100201050c094e6f726469635f55415254
(...)
2017.10.27 07:25:18.593 ble_evt_gap_scan_response rssi: -63 (0xffffffc1) packet_type: 0 (0x00) sender:f6:28:b7:24:df:5b address_type: 1 (0x01) bond: 255 (0xff) data:0201050c094e6f726469635f55415254
2017.10.27 07:25:18.594 RX: 801b0600c1005bdf24b728f601ff100201050c094e6f726469635f55415254

-------------- Scanning stop -------------
2017.10.27 07:25:18.621 ble_cmd_gap_end_procedure 
2017.10.27 07:25:18.621 TX: 00000604

2017.10.27 07:25:18.622 ble_rsp_gap_end_procedure result:0x0000 ['No Error']
2017.10.27 07:25:18.623 RX: 000206040000

---------------- Connect ------------------
2017.10.27 07:28:14.636 ble_cmd_gap_connect_direct address: 5b df 24 b7 28 f6 addr_type: 1 (0x01) conn_interval_min: 60 (0x003c) conn_interval_max: 76 (0x004c) timeout: 100 (0x0064) latency: 0 (0x0000)
2017.10.27 07:28:14.637 TX: 000f06035bdf24b728f6013c004c0064000000

2017.10.27 07:28:14.641 ble_rsp_gap_connect_direct result:0x0000 ['No Error'] connection_handle: 0 (0x00)
2017.10.27 07:28:14.641 RX: 00030603000000

-------------- Connect (again) ------------
2017.10.27 07:30:38.340 ble_cmd_gap_connect_direct address: 5b df 24 b7 28 f6 addr_type: 1 (0x01) conn_interval_min: 60 (0x003c) conn_interval_max: 76 (0x004c) timeout: 100 (0x0064) latency: 0 (0x0000)
2017.10.27 07:30:38.341 TX: 000f06035bdf24b728f6013c004c0064000000

2017.10.27 07:30:38.342 ble_rsp_gap_connect_direct result:0x0181 ['Device is in wrong state to receive command'] connection_handle: 1 (0x01)
2017.10.27 07:30:38.343 RX: 00030603810101

------------------ end log -----------------------

You can see that after the first press of the "Start" button, the "ble_evt_connection_status" event did not occur. In my program I expect this event to continue next steps. After the second press of the "Connect" button, in the "ble_rsp_gap_connect_direct" event, I get the result 0x0181 ("Device is in wrong state to receive command"). When I try connect to device, scanning is stopped.

Related