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

NRF8001 + Ardino - set advertisement data

Hello,

I have been since many days desperately trying to set the bytes in the advertisement packets in my Arduino, combined with an NRF8001.

What I am trying to achieve?

I am using an app for Android to test my Arduino program screenshot. I used the BLE_BROADCAST example. My chip is being recognized as "bcast". Then, I followed the documentation and was trying to set the advertisement data (change bytes in the scan record). I tried to open pipes, use aci_set_local_data etc. Either it doesn't work entirely or it generates errors (ACI Command: 1B / Aci Command: D).

I think I miss some basics. On the Internet there are absolutely no examples. Can you please help me to achieve my goal? As I understood, I only have to open a pipe and set the data. But, apparently, it is not that easy.

What I have already tried?

With this code I seem to be able to change the device name.

case ACI_DEVICE_STANDBY:
            Serial.println(F("Evt Device Started: Standby"));
            //See ACI Broadcast in the data sheet of the nRF8001
            bool pipeOpened = lib_aci_open_adv_pipe(1);
            if (pipeOpened) {
              Serial.println(F("Pipe opened."));
              uint8_t data[] = { 72, 97, 108, 108, 111, 44, 32, 83, 101, 98, 97 };
              bool dataSet = lib_aci_set_local_data(&aci_state, 1, data, sizeof(data) / sizeof(uint8_t));
              if (dataSet) {
                Serial.println(F("Data successfully set."));
              }
              else {
                Serial.println(F("Data not set."));
                while (true);
              }
            }
            else {
              Serial.println(F("Pipe not opened."));
              while(true);
            }

The problem: if I just add only one more character to data, the device name is bcast again and I get a message "ACI Command: D".

What I am asking about?

What is the correct way to change the bytes in the scan record? How is the device name defined and where does the actual advertisement data begin? Why I am only able to use only one pipe ("1")? The goal is that a BLE-enabled smartphone performs a scan and reads the device name and the advertisement data (which should be 20 bytes long, as I understood). Actually a very simple task. But, as I said, I seem to miss some basics.

Any help will be highly appreciated.

Parents
  • My apologies on the trouble that you have faced. I see that there is a similar set of questions have been posted and answered on the devzone.

    Please see these

    devzone.nordicsemi.com/.../

    devzone.nordicsemi.com/.../

    [Added to clarify] All the bytes in the advertising and in the scan response are changeable from broadcast pipes. However you need to be aware that the any command that is sent to the nRF8001 will get a response like a Command Response event. When you are opening a pipe using the ACI Command OpenAdvPipe, you need to wait for the Command Response Event. You are using the return code incorrectly , the return code says that the command has been successfully placed in the queue and the pipe is not open yet.

    You also need to do an ACI broadcast /ACI connect to start the radio which you are not doing.

    =Steps= Once the nRF8001 sends the ACI Device Started Standby event, you can use the ACI OpenAdvPipe command on the broadcast pipe.

    The functions to use the ACI commands are present in the lib_aci.h ( lib_aci_open_adv_pipes , lib_aci_set_local_data )

    Then start advertising using the ACI broadcast command.

    You can update the data in the Pipe by using the ACI Set Local Data command. lib_aci_set_local_data

  • Sadly no. I had already found the linked threads. They are not helpful. I still do not know how to change other bytes in the scan record.

Reply Children
No Data
Related