Author Topic: RFduino.send on demand, not streaming  (Read 248 times)

andrey_dung

  • RFduino Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
RFduino.send on demand, not streaming
« on: May 02, 2017, 08:52:09 PM »
I am building a low power device based on RFduino. There is an app to monitor the device, which every hour (and by demand of users when click a button) asks for some data from RFduino.

I don't want to put RFduino.send function in the for loop, since it will continuously streaming data when RFduino is connected to the app, and that will waste battery.

On the other hand, I could put RFduino.send whenever the device connects to the smartphone. However this way to get new data, the app would have to disconnect and connect again.

Code: [Select]
void RFduinoBLE_onConnect() {
  RFduinoBLE.send(data);
}

What is the best way to implement on demand data sending in RFduino?

tolson

  • Global Moderator
  • *****
  • Posts: 855
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: RFduino.send on demand, not streaming
« Reply #1 on: May 03, 2017, 08:31:37 AM »
You can put the send in the main loop within a conditional statement that only sends when the condition has been met.