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

Multiple pipes in service data

Hi :)

In my program, just ONE pipe to use advertising service data is not enough. There is the function:

lib_aci_open_adv_pipes(const uint8_t * const adv_service_data_pipes);

When i use it in my program, serial monitor says i'm in a while(1) loop. If i replace this function to:

lib_aci_open_adv_pipe(const uint8_t pipe);

It is working.

The problem is, i want to advertise more data than uint_8 (using values between 0-255 is too less)

I thought i can use "lib_aci_open_adv_pipes" to send "more" service data.

Maybe i don't know what "adv_service_data_pipes" do or where i have to initialize that.

My goal is to get GPS data and put this data into "service data". Maybe it's possible to change "lib_aci.h" that i can use something else than uint8_t ?

Can anyone help me please? :)

  • The Service Pipe maps the Characteristic and the operation, in this case the operation is to advertise or broadcast. This is the pipe number that is present in the services.h file as a #define. Use the lib_aci_open_adv_pipe or the lib_aci_open_adv_pipes to open the broadcast pipe. If you have more than one broadcast pipe you can open all of them in one function call using the lib_aci_open_adv_pipes, if you have one pipe you can use the lib_aci_open_adv_pipe.

    You can send a maximum 20 bytes of data using the Service Data on a single pipe. You need the make the Characteristic to which the Broadcast property is attached as 20 bytes. Then use the lib_aci_set_local_data to update the data whenever your data source changes. The GPS data can fit in 20 bytes is my assumption.

    Note: The pipe needs to be opened before use, but the set_local_data function is used to actually set the data that is being sent over the air. The data that is sent over the air is controlled by the

    /**@brief Sets Local Data.
     *  @details
     *  This command updates the value of the characteristic value or the characteristic
     * descriptor stored locally on the device.
     *  Can be called for all types of pipes as long as the data is stored locally.
     *  @param ACI state structure
     *  @param pipe Pipe number on which the data should be set.
     *  @param value Pointer to the data to set.
     *  @param size Size of the data to set.
     *  @return True if the transaction is successfully initiated.
    */
    bool lib_aci_set_local_data(aci_state_t *aci_stat, 
                                              uint8_t pipe, 
                                              uint8_t *value, 
                                              uint8_t size);
    

    Please note the lib_aci_set_local_data uses a pointer to the array of uint8_t and the number of bytes in the array. For example:

    if (ACI_CMD_GET_DEVICE_VERSION == aci_evt->params.cmd_rsp.cmd_opcode)
    {
      /*Store the version and configuration information of the nRF8001 
       in the Hardware Revision String Characteristic
       */
      lib_aci_set_local_data(&aci_state,
                             PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET,
                             (uint8_t *)&(aci_evt->params.cmd_rsp.params.get_device_version),
                              sizeof(aci_evt_cmd_rsp_params_get_device_version_t));
    }
    

    In this example the get_device_version is a structure of type aci_evt_cmd_rsp_params_get_device_version_t , which is more than 1 byte (See the lib_aci.h for more details ). Using the pointer and length allows you to set more than one bye in the lib_aci_set_local_data

  • Thanks for your answer. I know (because my previous threads/questions) that i can use lib_aci_set_local_data to send service data an this works only for values between 0-255, because inside this function the "data" goes to unint8_t *value. How can i send more than 1 byte (because uint8_t is one byte with a value between 0..255) to *value ? Sorry, i don't get it!

    Where in the sketch can i update my data in lib_aci_set_local_data ? When i try this in void loop () the serial monitor gives me a "you're in a while (1) loop" error.

    If i use lib_aci_open_adv_pipe (like: lib_aci_open_adv_pipe(2) ) i open advertise pipe number 2 (that works fine!). But what do i have to use in: lib_aci_open_adv_pipes ? Can you give an example? (Is it like: lib_aci_open_adv_pipes(2,3) or something like that to open pipe 2 and 3?)

    Thanks in advance. I'm still excited of the professional help here *thumbs up *

  • I edited my answer to better answer your question with an example. You do not need to use lib_aci_open_adv_pipes as the lib_aci_open_pipe works just as well for you.

Related