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.

I can not capture advertising packages being in the central role of MasterSlaveSwitch



Hello, excuse my English. I am a beginner both IAR BLE and programming. I'm using the proyect Slave Master Switch in 1.4.1 stack with the Keyfob device., (KeyFob1but the changing role is handle dynamically with a timer, step 5 seconds in peripheral role and 10 in the central role. I have another keyfob (KeyFob2) with the original MasterSlaveSwitch project, DEFAULT_DISCOVERABLE_MODE in GAP_ADTYPE_FLAGS_GENERAL to do not stop advertising to 180 seconds. Using a dongle in Sniffer mode.

My idea is that KeyFob1 receives advertising packages of KeyFob2, look at the contents of those packages, take a specific byte and store it. With that stored byte, KeyFob1 modify the content of his advertData, modifying one of its bytes for the value stored. To do this in simpleBLECentralEventCB (), I have introduced the case of GAP_DEVICE_INFO_EVENT. As a test I entered the following code (I have the variable contadorData declared and initialized to 0):

case GAP_DEVICE_INFO_EVENT: 
{

    advertData[7] = contadorData; 
    GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData ); 
    contadorData++; 
}

If the central role receives a packet during their periods of scanning, the content of the advertData[7]  should change . This does not happen. In the Smart RF packet sniffer I can see that KeyFob1 and KeyFob2 come to exchange ADV_SCAN_REQ and may start a connection, although these connections do not last more than 10 seconds is the maximum time that KeyFob1 is central role before moving to peripheral role and so successively. I understand, therefore, that KeyFob1 receives packets, but am not being able to receive the GAP_DEVICE_INFO_EVENT event.

Do you have any restrictions this event? Is it only occurs to a certain type of input packet?

Best wishes.

Luis G. 

  • Hi Luis,

    Are you calling this function when you are in Slave role:
    GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );

    Best wishes
  • Hi Zahid, 

    But the problem is not that, when I enter the following code in the event GAP_LINK_ESTABLISHED_EVENT advertData change is followed correctly in my next cycle advertising:

    static uint8 simpleBLECentralEventCB( gapCentralRoleEvent_t *pEvent )
    {
      uint8 i;  
      
      switch ( pEvent->gap.opcode )
      {
      case GAP_LINK_ESTABLISHED_EVENT:
        {
                advertData[7] =0x4c;              
                GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );             
                
                
          if ( pEvent->gap.hdr.status == SUCCESS )
          {          
            for(i=0; i<MAX_CONNECTIONS;i++)
            {
              //Check against addresses we want to connect to
              if(deviceList[i].addr[5] == pEvent->linkCmpl.devAddr[5])
              {
                deviceList[i].state = BLE_STATE_CONNECTED;
                deviceList[i].connHandle = pEvent->linkCmpl.connectionHandle;
              }
            }
          }        
        }
        break;
    

    In MasterSlaveSwitch project only the central role in the processes simpleBLECentralEventCB () function and the GAP_LINK_ESTABLISHED_EVENT GAP_LINK_TERMINATED_EVENT, both events related to a connection. Unlike the simpleBLECentral project in the same function in addition to the two previous events also processes GAP_DEVICE_INIT_DONE_EVENT, GAP_LINK_PARAM_UPDATE_EVENT, GAP_DEVICE_DISCOVERY_EVENT and GAP_DEVICE_INFO_EVENT.
    I need to process the event with pEvent-> gap.opcode = GAP_DEVICE_INFO_EVENT to access the data content of the received packets. However this event is never received, something I'm leaving ... Did the events that appear in the document TI_BLE_Software_Developer's_Guide in paragraph I.3 GAP API are not automatically sent when the specified condition is met in each?