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.

Connectab;e directed adverisement not working



Hi all ,

Am using keyfobdemo with BLE dongle (HostTestreleaseall) ,connectable undirected adverisement is working fine ,but when i modify the code for connectable directed advertisement , i could not able to see the directed advertisement,.

This is what the change i made ,

In Peripheral.c (GAPRole_Init( ) ) ,i have modified the 

  gapRole_AdvEventType = GAP_ADTYPE_ADV_DIRECT_IND;

i have updated this global variable with my BLE dongle address , but i cannot able to see any advertisement ! Kindly help me to resolve this.

static uint8  gapRole_AdvDirectAddr[B_ADDR_LEN] = {0x3C,0x2D,0xB7,0x85,0xEE,0xFE};

I have searched the forum thoroughly but anywhere i cannot able to find "connectable directed advertisement " working ! 

Thanks in advance for the help. 

Regards,

Senthil

 

  • Hello.

    It appears as if your code is correct.  It is preferable, however, to do this at the application level (keyfobdemo.c).  In a similar fashion to the other parameters, you could do:

    uint8 desired_adv_event_type = GAP_ADTYPE_ADV_DIRECT_IND;
    uint8 desired_adv_direct_addr[] =
      {
        0x3C,
        0x2D,
        0xB7,
        0x85,
        0xEE,
        0xFE
      };

      GAPRole_SetParameter( GAPROLE_ADV_EVENT_TYPE, sizeof( uint8 ), &desired_adv_event_type );
      GAPRole_SetParameter( GAPROLE_ADV_DIRECT_ADDR, B_ADDR_LEN, desired_adv_direct_addr );

    Regardless, I think your issue may be how you are interacting with the direct advertisements.  When you are performing direct advertising, you are only in the advertising state for a maximum of 1.28 seconds.  Also, you can not scan for direct advertisements; you must initiate a connection with them.  Therefore, you must call GAP_EstablishLinkReq either before or during this 1.28 seconds period.

    You can accomplish this in BTool with the following steps:

    1. Enter the keyfob's BD_ADDR into the slave BDA field on the Discover / Connect tab.  You must do this manually since you will not find it during a scan.

    2. Click establish.  This will send the GAP_EstablishLinkReq to the keyfob.

    3. Perform the directed connectable advertising with the keyfob.  You should now be in a connected state.

    You can find more information about directed connectable advertising on page 2225 of the Bluetooth 4.0 Spec.

    Best wishes,

    Tim

  • Hi Timothy,

    Thanks for your information about "Directed advertisement".

    I have tried your procedure but i cannot able to connect to Keyfob.

    1.You said that i have to enter the BD_ADDR manually in the Btool,but manual enter option is not available in the Btool .( Am using the Btool comes with the version 1.2.1 )

    So ,what i did is I make my keyfob advertise ,connectable undirected advertisement and i will scan using Btool ,once the slave address appeared in the Btool , I have flashed my code ( for connectable directed advertisement ) and i will establish the connection by directly clicking on the "Establish " (Immediately after flashing the code using IAR )icon in the Btool.

    2.The B-tool will struck after receiving the GAP_HCI_ExtensionCommandStatus as shown below.

    [1] : <Tx> - 02:11:55.356
    -Type : 0x01 (Command)
    -Opcode : 0xFE09 (GAP_EstablishLinkRequest)
    -Data Length : 0x09 (9) byte(s)
    HighDutyCycle : 0x00 (Disable)
    WhiteList : 0x00 (Disable)
    AddrTypePeer : 0x00 (Public)
    PeerAddr : F0:5D:B2:EB:D7:90
    Dump(Tx):
    01 09 FE 09 00 00 00 F0 5D B2 EB D7 90

    ------------------------------------------------------------------------------------------------------------------------
    [2] : <Rx> - 02:11:55.466
    -Type : 0x04 (Event)
    -EventCode : 0xFF (HCI_LE_ExtEvent)
    -Data Length : 0x06 (6) bytes(s)
    Event : 0x067F (GAP_HCI_ExtentionCommandStatus)
    Status : 0x00 (Success)
    OpCode : 0xFE09 (GAP_EstablishLinkRequest)
    DataLength : 0x00 (0)
    Dump(Rx):
    04 FF 06 7F 06 00 09 FE 00

    ------------------------------------------------------------------------------------------------------------------------

    /* Will struck here */

    3.Upon pressing the cancel button in the B-tool , am getting "Connection not accepted " in the B-tool.

    4.I am running "Packet sniffer " in other PC , Where i can able to see "Directed adverisement PDU " with FCS error.

  • HI Timothy ,

    7776.DirectAdv.psd

    PFA for the log from Packet Sniffer.

    Regards,

    Senthil

  • It turns out that you have to reverse the byte ordering when you are initializing the address of the device you are trying to direct advertise to.

    For example, if I wanted to use the address 00:18:31:85:2A:62, in the project code I would write

      uint8 desired_adv_direct_addr[] =
      {
        0x62,
        0x2A,
        0x85,
        0x31,
        0x18,
        0x00
      };

    It is not necessary to do this in BTool.  Also, I am using BTool 1.20c and I am able to to enter an address manually by entering text into the Slave BDA field.  I believe this should be the case for version 1.21 also.

    Best wishes,

    TIm

  • Hi Tim,

    Thanks for your support , I can able to establish the connection :) 

    In this we are hard coding the dongle address , how can i make it generic ?

    I can change this dongle address once i established the connection through the handle from Btool ,but assume am selling a product with directed advertisement  (like keyfob which can be used with the smart phone for proximity ) so when the device is first power ON , i have to give the Smart phone address as the input to the Keyfob .How can i do this ? 

    Regards,

    Senthil 

  • In this scenario, you will need to acquire the address of the smartphone somehow.  One method could be to initially use undirected advertisement.  You could use connectable undirected to actually establish a connection or use discoverable undirected to simply receive a scan request and send a response telling the smartphone that you want to directly advertise towards it.  Then, for every other connection after the first one, you can use directed advertising towards the smartphone.  As you can see, directed connectable advertising is generally used for fast reconnection.  If this isn't necessary for you, I would consider just using undirected advertising as it is much more flexible.

    -Tim