This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2650EM-7ID-RD: Direct Advertising - How to use it

Part Number: CC2650EM-7ID-RD

Hello,

I'm trying to get the direct advertising to work on my two SmartTF06 dev boards with the CC2650EM shield. But I cannot get it to  work, maybe you can help me with a few questions.

  1. Do I have to change the mode of discovery for the central device or should the directed advertising packets be found just like the undirected? At the moment I do not receive anything from the peripheral when directed advertising is enabled.
  2. Should the directed advertising packet even be found by the central if there was no prior bonding? I other words, can I just use hard coded adresses on the peripheral side to address the central?
  3. I found some threads in the forum noting that the address given for GAPROLE_ADV_DIRECT_ADDR should be reversed, is this true?

The SDK version is "ble_sdk_2_02_02_25".

I've started with the simple_peripheral and simple central and changed the following:

Peripheral:

SimpleBLEPeripheral_init(){

...  after all the GAPRole_SetParameter calls I added:

    uint8_t resolvedAddr[B_ADDR_LEN] = {0x00, 0x2f, 0xdc, 0x43, 0xb4, 0xb0};
    uint8_t idx = GAPBondMgr_ResolveAddr( advDirectAddrType, resolvedAddr, NULL);

    if ( idx < GAP_BONDINGS_MAX ){

        uint8_t advDirectType = GAP_ADTYPE_ADV_LDC_DIRECT_IND;

        bool bIsEnabled = false;
        GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &bIsEnabled);
        GAPRole_SetParameter(GAPROLE_ADV_DIRECT_ADDR, B_ADDR_LEN, resolvedAddr);
        GAPRole_SetParameter(GAPROLE_ADV_EVENT_TYPE, sizeof(uint8), &advDirectType);

        //GAPRole_SetParameter(GAPROLE_ADV_DIRECT_TYPE, sizeof(uint8_t), &advDirectAddrType);

        bIsEnabled = true;
        GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &bIsEnabled);

Display_print0(dispHandle, 5, 1, "bonded!");
Display_print0(dispHandle, 6, 1, Util_convertBdAddr2Str(resolvedAddr));
Display_print0(dispHandle, 7, 1, "Directed");
}

Central:

#define DEFAULT_DEV_DISC_BY_SVC_UUID          FALSE

 

For the Central the evaluation allows to list all the found MAC-Adresses but the address of the periperal device does not show up. Do you have any hints or can somebody provide a working example?

Best regards

Fabian

  • Hi Fabian,
    Assigning one of the experts to comment.
  • Hi Joakim,

    thanks for your support.

    In the meantime I managed to receive the direct advertising message, but I still have some questions:

    1. On the peripheral side I had to reverse the address for 'GAPROLE_ADV_DIRECT_ADDR', to make the central receive it - as others suggested it.
    2. On the central side I can only see the direct-advertising-peripheral when the 'GAP_DEVICE_DISCOVERY_EVENT' event was received, but not in the 'GAP_DEVICE_INFO_EVENT'. At first I put all my code into the 'GAP_DEVICE_INFO_EVENT' event, and I thought it would provide the same results as 'GAP_DEVICE_DISCOVERY_EVENT' but more instant/faster. Shouldn't it show up on both events / are direct advertising packets excluded in the GAP_DEVICE_INFO_EVENT?
    3. The received peripheral address is also reversed - Why are the adresses reversed? Due to little/big-endianess?

    Best regards and thanks

    Fabian

    _________

    My current code for the peripheral, any suggestions for improvement?

        // Read address of last bonded device from non-volatile memory
        // address shall be reversed!
        // uint8_t addr[B_ADDR_LEN] =         {0xb0, 0xb4, 0x48, 0xdc, 0x2f, 0x00};
    
        uint8_t addr[B_ADDR_LEN] =         {0x00, 0x2f, 0xdc, 0x48, 0xb4, 0xb0};
        uint8_t resolvedAddr[B_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
        uint8_t u8bondCount = 0;
        uint8_t advDirectAddrType = ADDRMODE_PUBLIC;
        uint8_t idx = 0;
    
        // get bond count from gap manager
        GAPBondMgr_GetParameter(GAPBOND_BOND_COUNT, &u8bondCount);
    
        // resolve the address, using the gap bond manager (-> bonding exists)
        idx = GAPBondMgr_ResolveAddr( advDirectAddrType, addr, resolvedAddr);
    
        // check if address could be resolved
        bool unResolved = true;
        for(uint8_t c=0; c<B_ADDR_LEN; c++){
            unResolved &= resolvedAddr[c] == 0xff;
        }
    
        if ( idx < GAP_BONDINGS_MAX && u8bondCount && !unResolved){
            uint8_t advDirectType = GAP_ADTYPE_ADV_LDC_DIRECT_IND; //GAP_ADTYPE_ADV_HDC_DIRECT_IND;
    
            bool bIsEnabled = false;
            GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &bIsEnabled);
            GAPRole_SetParameter(GAPROLE_ADV_DIRECT_ADDR, B_ADDR_LEN, resolvedAddr);
            GAPRole_SetParameter(GAPROLE_ADV_EVENT_TYPE, sizeof(uint8), &advDirectType);
    
            bIsEnabled = true;
            GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &bIsEnabled);
    
            Display_print0(dispHandle, 6, 1, Util_convertBdAddr2Str(resolvedAddr));
            Display_print0(dispHandle, 7, 1, "Direct advertising");
        }
      }
    

     

    My current code for the central, any suggestions for improvement?

    case GAP_DEVICE_DISCOVERY_EVENT:
          {
           // discovery complete
           scanningStarted = FALSE;
    
           // connect to known device, get this from non-volitle memory
           //uint8_t devAddr[B_ADDR_LEN] = {0xB0, 0xB4, 0x48, 0xC2, 0x64, 0x02}; // - original address needs to be reversed
           uint8_t devAddr[B_ADDR_LEN] = {0x02, 0x64, 0xC2, 0x48, 0xb4, 0xb0}; // Copy results scanRes = pEvent->discCmpl.numDevs; memcpy(devList, pEvent->discCmpl.pDevList,(sizeof(gapDevRec_t) * scanRes)); // Try to locate the known and bonded device in the discovery results gapDevRec_t *ptrFound = NULL; uint8_t found = false; for(uint8_t c=0; c<DEFAULT_MAX_SCAN_RES; c++){ bool check = true; for(uint8_t i=0; i<B_ADDR_LEN; i++){ check &=devList[c].addr[i] == devAddr[i]; } if(check){ ptrFound = &devList[c]; found = true; break; } } // if the device was found, initiate the connection, otherwise start the discovery again if(found){ Display_print1(dispHandle, 4, 0, "Device found: %d", scanRes); bStatus_t status = GAPCentralRole_EstablishLink(DEFAULT_LINK_HIGH_DUTY_CYCLE, DEFAULT_LINK_WHITE_LIST, ptrFound->addrType, ptrFound->addr); }else{ SimpleBLECentral_startGapDiscovery(); }

  • Hello Fabian,
    1) and 3) Yes, its due to endianess.
    2) I checked the source and directed advertisements are not reported in GAP_DEVICE_INFO_EVENT.