This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Mixed coded and uncoded PHY on central side with NCS

My use case: There are different but similar peripherals advertising with 1M uncoded or coded PHY. Some of them are even advertising in mixed mode. 

Question: How to connect to each of them with my central?

What I did until now: I initialized scanning like that:

struct bt_le_scan_param scan_param = {
    .type = BT_LE_SCAN_TYPE_ACTIVE,
    .interval = BT_GAP_SCAN_FAST_INTERVAL,
    .window = BT_GAP_SCAN_FAST_WINDOW,
    .options = BT_LE_SCAN_OPT_CODED 
};

struct bt_scan_init_param scan_init = {
    .connect_if_match = 0,
    .scan_param = &scan_param,
    .conn_param = NULL
};

bt_scan_init(&scan_init);

I could verify that my central is receiving both coded and uncoded advertising.

When I decide to connect to one of these peripherals I assumed that I have to initialize connection the same way:

struct bt_conn_le_create_param create_param = 
    BT_CONN_LE_CREATE_PARAM_INIT(
        BT_CONN_LE_OPT_CODED, 
        BT_GAP_SCAN_FAST_INTERVAL, 
        BT_GAP_SCAN_FAST_WINDOW
    );
      
struct bt_le_conn_param conn_param = BT_LE_CONN_PARAM_INIT(16, 16, 0, 400);

// addr AND _currentConnection has been previously defined 
int error =
    bt_conn_le_create(&addr, &create_param, &conn_param, &_currentConnection);

But that leads to an error -5 (I/O error) when calling bt_conn_le_create. In this case there is a log warning 

bt_hci_core: opcode 0x2043 status 0x12

I am only able to connect if I explicitly set "BT_CONN_LE_OPT_CODED | BT_CONN_LE_OPT_NO_1M" or "BT_CONN_LE_OPT_NONE" as option of the bt_conn_le_create_param struct. It seems that the SDK is not choosing the appropriate settings automatically.

Is this expected behavior? Do I miss some config or anything else? Or do I have to parse the bt_scan_device_info and setup the connection create parameter dependent to the received phy in bt_scan_device_info?

Regards,
Oliver

Parents
  • Is this expected behavior? Do I miss some config or anything else? Or do I have to parse the bt_scan_device_info and setup the connection create parameter dependent to the received phy in bt_scan_device_info?

    I am not sure if we need to do that. It might be that bt_conn_le_create somehow has the dependency on knowing what phy it is sending to. I will check few things on Monday and come back later to with info. Thanks for your patience.

  • it looks like you are right about the behavior, just tested it, but it is unclear to me if this is the behavior from the spec or the limitation on our stack. Need to dig a bit more which might take some time. But it looks like you need to filter the scan info to decode the phy and send the correct request.  Please go ahead with your scan info decoding of the phy and send the connect request appropriately on the phy.

Reply
  • it looks like you are right about the behavior, just tested it, but it is unclear to me if this is the behavior from the spec or the limitation on our stack. Need to dig a bit more which might take some time. But it looks like you need to filter the scan info to decode the phy and send the correct request.  Please go ahead with your scan info decoding of the phy and send the connect request appropriately on the phy.

Children
Related