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

the pc-ble-driver - adapter question

Hi,

I'm using the the pc-ble-driver together with the nrf-ble-driver-4.1.1-win_x86_32 library and two nRF52840 dongles on two different COM ports.I'd like to clarify on how to properly use the library with two dongles. My assumtion is to use "adapter" to distinguish between the two COM streams.

When establishing communication with the dongle/SoftDevice we call

m_adapter = sd_rpc_adapter_create (transport_layer);

Later, when receiving events from the SoftDevice, this gets called:

static void ble_evt_dispatch (adapter_t *adapter, ble_evt_t *p_ble_evt)
{

...

....

}

So if I match adapter to m_adapter I know where the data is from... correct?

In reality I find that adapter and m_adapter is not the same. Why not? How can I use one only library instance on two COM ports?

Thanks for your help

M

Parents
  • Hi,

    Yes, it is correct that you can use multiple adapters with one pc-ble-driver application. We have this implemented in the tests in pc-ble-driver repository, for instance, this test uses two different adapters. It is a bit hidden in different util functions.

    In reality I find that adapter and m_adapter is not the same.

    How often do you see this? What is it when it is not the same?

    Best regards,
    Jørgen

  • Hi Jørgen,

    Thank you for your reply. The fact that one can use multiple adapters is already great news. The examples are a good starting point, however they use two separate functions (see below) instead of only one (my case). 

    c->setGapEventCallback([&](const uint16_t eventId, const ble_gap_evt_t *gapEvent) -> bool {
    switch (eventId)
    {


    p->setGapEventCallback([&](const uint16_t eventId, const ble_gap_evt_t *gapEvent) {
    switch (eventId)
    {

    In my case I'd like to distinguish between "c" and "p" based on the function's "*adapter" argument.

    static void ble_evt_dispatch (adapter_t *adapter, ble_evt_t *p_ble_evt)
    {

        if (adapter == c) ...

        if (adapter == p) ...

    I find that the statement "if (adapter == c)" won't work and that I need to use "if (adapter->internal == adapter->internal)" instead. Based on code in "test_util_adapter_wrapper.cpp" it even seems that I could use "m_adapter->internal" for whatever I want...

    From this discussion I'd like to find out how to do this properly.

    Thanks!

    M

Reply
  • Hi Jørgen,

    Thank you for your reply. The fact that one can use multiple adapters is already great news. The examples are a good starting point, however they use two separate functions (see below) instead of only one (my case). 

    c->setGapEventCallback([&](const uint16_t eventId, const ble_gap_evt_t *gapEvent) -> bool {
    switch (eventId)
    {


    p->setGapEventCallback([&](const uint16_t eventId, const ble_gap_evt_t *gapEvent) {
    switch (eventId)
    {

    In my case I'd like to distinguish between "c" and "p" based on the function's "*adapter" argument.

    static void ble_evt_dispatch (adapter_t *adapter, ble_evt_t *p_ble_evt)
    {

        if (adapter == c) ...

        if (adapter == p) ...

    I find that the statement "if (adapter == c)" won't work and that I need to use "if (adapter->internal == adapter->internal)" instead. Based on code in "test_util_adapter_wrapper.cpp" it even seems that I could use "m_adapter->internal" for whatever I want...

    From this discussion I'd like to find out how to do this properly.

    Thanks!

    M

Children
No Data
Related