2 Replies Latest reply on Apr 12, 2016 8:34 AM by dturney_1462731

    Filtering scanned data

    dturney_1462731

      This might be more of a C programming question, but, in my app, when a device is scanned, there are several bytes in the CYBLE_GAPC_ADV_REPORT_T advReport->data (The advertisement packet) that need to be picked out in order to be directed to the next step.  I know the simple way of just looking at each byte in the array, but I want put it all in a struct, and just the necessary bytes.  For example, if a device includes the Service UUID (32-bit) + Service Data, which bytes are in advReport->data[16]-[22]: how can I put those in

         

      struct scannedData {

         

          uint32 serviceID;

         

          uint8* serviceData;

         

      }newScan;

        • 1. Re: Filtering scanned data
          bmah

          You can extract the values inside the event CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT. 

             

          For e.g., 

             

          case CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:  
                      advReport=*(CYBLE_GAPC_ADV_REPORT_T *)eventParam;
                      if(advReport.dataLen!=0)
                      { 
                          Test_Data=advReport.data[16]; 
                       }

             

          In your application, you can probably use a memcpy function - memcpy(&newScan.serviceID, &advReport.data[16], sizeof(uint32));       

          • 2. Re: Filtering scanned data
            dturney_1462731

            So, using the memcpy function, using "&advReport.data[16], sizeof(uint32)" as one end of the comparison will pull the (4) 8-byte values from advReport.data?