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.

Related