Author Topic: Replacing advertisement data for Simblee  (Read 680 times)

arietimmerman

  • RFduino Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Replacing advertisement data for Simblee
« on: July 13, 2016, 01:03:05 PM »
For a security project, I would like to update the advertisement data of my Simblee device every couple seconds. I use this advertisement data as a heartbeat mechanism. This allows my other devices to know (1) that the Simblee peripheral is up-and-running and (2) can be trusted.

Now I was wondering if it is absolutely necessary to end and start SimbleeBLE for replacing the advertisement message.
To me, this looks like unneeded overhead. Since my device should run on a battery, I want to limit the overhead as much as possible

Question: Can I replace the advertisement data without restarting SimbleeBLE using SimbleeBLE.end() and SimbleeBLE.begin()?

If I don't use the end() and begin() methods, the advertisement data won't change. If I do call these methods, I see the updated advertisement data on my scanning devices.

Below I've copied the relevant code.

Code: [Select]

MESSAGE message; //message is a struct, having multiple attributes variables, including a counter
uint8_t b[sizeof(message)];

void setup() {

    // [..]

    memcpy(b, &message, sizeof(message));
    SimbleeBLE_advdata_len = sizeof(b);
    SimbleeBLE_advdata = b;
    SimbleeBLE.begin();

    // [..]

}

void loop() {

   Simblee_ULPDelay(SECONDS(10));
   
   message.counter++; //change the message by increasing the counter
   
   //replace the advertised message
   memcpy(b, &message, sizeof(message));

   //Replacing the message has no effect, unless I uncomment the lines below.
   // SimbleeBLE.end();
   // SimbleeBLE.begin();   

}


tolson

  • Global Moderator
  • *****
  • Posts: 831
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Replacing advertisement data for Simblee
« Reply #1 on: July 14, 2016, 07:18:53 PM »
It is done by stopping BLE advertising with SimbleeBLE.end(), change the advertisement, then restart advertising with SimbleeBLE.begin().

 

anything