This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Parsing Adv data - manufacturer data parsing

Hi , 

I am trying to parse the manufacturer specific data that a beacon is advertising. 

I can read successfully the company_id but unable to read the "specific data " (ble_advdata_manuf_data_t.data  ).

Is there any example of parsing and displaying the manufacturer data ? I am using nRF52840

or is there a beacon parser available to be used as a reference ? 

Thanks, 

Ran

Parents
  • Hi Ran,

    Are you using using the provided beacon example from the SDK?
    If so, please have a look at the documentation for the beacon example provided in the SDK.
    Particularly, I think the "Testing" section of the documentation might be of interest to you?

    I can read successfully the company_id but unable to read the "specific data " (ble_advdata_manuf_data_t.data  )

    I am not sure I understand exactly what you mean here. Did you successfully receive the advertised packet, and read the company_identifier from it, but you do not see the remaining bit fields of the packet received packet?

    If you are using the beacon example from the SDK, you can see the data structure of the data in the packets being broadcast, in the advertising_init function. You can use this to create a parser for the incoming data.

    Pay special attention to the structure of the data inside the ble_advdata_manuf_data_t structure, as the data field you are trying to access in it self is a structure containing a pointer to the beginning of the data, and a length variable indicating the length of the data.
    Therefore, trying to access just ble_advdata_manuf_data_t.data might not yield the expected result.

    Here is an exempt from the above mentioned function, in the beacon example, in case you have not already seen it:

        
        ...
        
        ble_advdata_manuf_data_t manuf_specific_data;
    
        manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;
        
        ...
        
        manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info;
        manuf_specific_data.data.size   = APP_BEACON_INFO_LENGTH;
        
        ...


    If this does not answer your question, please provide the function in which you are attempting to extract the data, and the contents of the packet where you were able to extract company_id, but not the rest.

    Best regards,
    Karl 

  • Karl - Thanks. 

    This nested array within the manuf_data can be a bit confusing. 

    I am advertising 4 bytes ( 0x02,003,0x04,0x05 ) with company id 0x0064. 

    Here is a wire shark capture 

    As you can see : 

    length is 7 ( tag + company_id 2 bytes + my 4 bytes ) 

    then we can see 0x0064 , then we can see my data. 

    ( which I am now able to see in my scanner ) 

    so data is actually following the id field , however - the structures confuses me  : 

    /**@brief Manufacturer specific data structure. */
    typedef struct
    {
        uint16_t                     company_identifier;                  /**< Company identifier code. */
        uint8_array_t                data;                                /**< Additional manufacturer specific data. */
    } ble_advdata_manuf_data_t;
    
    typedef struct
    {
        uint16_t  size;                 /**< Number of array entries. */
        uint8_t * p_data;               /**< Pointer to array entries. */
    } uint8_array_t;
    

    ble_advdata_manuf_data_t.data.size actually not exist . 

    The specific data follows the company id. 

    I probably confused you :) sorry for that. 

    This is why I was looking for examples for parsing manuf data. 

  • No problem at all, I am happy to help.

    ran said:
    ( which I am now able to see in my scanner ) 

     Great! Does this resolve your initial question of not being able to see the specific advertisement data?

    ran said:
    I probably confused you :) sorry for that. 

    It is no problem at all, I will do my best to understand what issues you are facing.

    ran said:
    ble_advdata_manuf_data_t.data.size actually not exist .
    ran said:
    This is why I was looking for examples for parsing manuf data. 

    Do I understand you correctly that you are wanting, but still unable, to extract the received advertisement data into a variable in your program?
    If this is the case, could you please post the code where you are able to extract the company identifier into a variable, but not the manufacturer specific data?
    To make it easier for me to understand your intentions in your application, please post the complete source file for your scanner.

    Best regards,
    Karl

     

Reply
  • No problem at all, I am happy to help.

    ran said:
    ( which I am now able to see in my scanner ) 

     Great! Does this resolve your initial question of not being able to see the specific advertisement data?

    ran said:
    I probably confused you :) sorry for that. 

    It is no problem at all, I will do my best to understand what issues you are facing.

    ran said:
    ble_advdata_manuf_data_t.data.size actually not exist .
    ran said:
    This is why I was looking for examples for parsing manuf data. 

    Do I understand you correctly that you are wanting, but still unable, to extract the received advertisement data into a variable in your program?
    If this is the case, could you please post the code where you are able to extract the company identifier into a variable, but not the manufacturer specific data?
    To make it easier for me to understand your intentions in your application, please post the complete source file for your scanner.

    Best regards,
    Karl

     

Children
No Data
Related