4 Replies Latest reply on Aug 31, 2018 5:55 AM by PhDi_1589426

    Central scan response packet request

    PhDi_1589426

      Hi,

       

      I serched in the community as well as in the code exsamples and could not find an API for requesting the scan response packet from a peripheral by a central.

       

      Is there an example a may have overseen?

       

      Thanks and regards

      Philipp

        • 1. Re: Central scan response packet request
          PY_21

          Hi,

           

          If the Peripheral is advertising and Central is scanning during this period Central will send scan request to the peripheral then the peripheral sends scan response data as shown in image.

           

          Whenever if we call Cy_BLE_GAPC_StartScan() function in the Central device this will discover the GAP peripheral devices that are available for connection. As soon as the discovery operation starts, CY_BLE_EVT_GAPC_SCAN_START_STOP event is generated. And the CY_BLE_EVT_GAPC_SCAN_PROGRESS_RESULT event is generated when a GAP peripheral device is located. Every Advertisement / Scan response packet is received in a new event, CY_BLE_EVT_GAPC_SCAN_PROGRESS_RESULT.

          This event is triggered every time a device is discovered. A pointer to structure of type cy_stc_ble_gapc_adv_report_param_t is returned as the event parameter. Where we can get the advertisement/ scan response data.

           

           

          Thanks,

          P Yugandhar.

          • 2. Re: Central scan response packet request
            PhDi_1589426

            Hi Yugandhar,

             

            the advertising report structur is of type cy_stc_ble_gapc_adv_report_param_t and the scan response structur is of type cy_stc_ble_gapp_scan_rsp_data_t:

             

            typedef struct {

                cy_en_ble_gapc_adv_event_t      eventType;

                uint8_t                                           peerAddrType;

                uint8_t*                                          peerBdAddr;

                uint8_t                                           dataLen;

                uint8_t*                                         data;

                int8_t                                             rssi;

            } cy_stc_ble_gapc_adv_report_param_t;

             

            typedef struct {

                uint8_t     scanRspData[CY_BLE_GAP_MAX_SCAN_RSP_DATA_LEN];

                uint8_t     scanRspDataLen;

            } cy_stc_ble_gapp_scan_rsp_data_t;

             

            The data array of cy_stc_ble_gapc_adv_report_param_t does not has the scanRspData of cy_stc_ble_gapp_scan_rsp_data_t.

             

            The eventparam of case CY_BLE_EVT_GAPC_SCAN_PROGRESS_RESULT must be either of type  cy_stc_ble_gapc_adv_report_param_t or of type cy_stc_ble_gapp_scan_rsp_data_t or their must be an other case for the response data or their must be a way to differentiate between these two data types in one case.

             

            Do I need to do a type cast on eventparam with cy_stc_ble_gapp_scan_rsp_data_t to get the scan response date?

             

            So could you give me an example how I can get the scan response data because it is not documented as far as I see it.

             

            Thank you in advance and best regards

             

            Philipp

            • 3. Re: Central scan response packet request
              PY_21

              Hi,


              In the below structure cy_stc_ble_gapc_adv_report_param_t
              typedef struct{
                  cy_en_ble_gapc_adv_event_t      eventType;
                  uint8_t                         peerAddrType;
                  uint8_t*                        peerBdAddr;
                  uint8_t                         dataLen;
                  uint8_t*                        data;
                  int8_t                          rssi;
              } cy_stc_ble_gapc_adv_report_param_t;

              Data is a pointer to advertising  or scan response data.
              EventType has the following values as shown
              1. Connectable undirected advertising = 0x00
              2. Connectable directed advertising = 0x01
              3. Scannable undirected advertising = 0x02
              4. Non connectable undirected advertising = 0x03
              5. Scan Response = 0x04
              If we consider the EventType as Scan Response then we can read the Scan Response data in the advertisement report.

                  

                   case CY_BLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

                       scanresponse=*(cy_stc_ble_gapc_adv_report_param_t*) eventParam;

                          if(scanresponse.eventType==0x04)

                          {

                              /* Read only the Scan Response Data */

                          }

              The Structure cy_stc_ble_gapp_scan_rsp_data_t is used to update the scan response data in the peripheral during advertisement.


              Thanks,
              P Yugandhar.

              1 of 1 people found this helpful
              • 4. Re: Central scan response packet request
                PhDi_1589426

                Hi Yugandhar,

                 

                great, thank you for the details reply.

                 

                Have a nice weekend

                 

                Philipp