Author Topic: mc-Script Beacon API  (Read 211 times)

millennial

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
mc-Script Beacon API
« on: January 29, 2017, 04:15:20 pm »
I was using the 4 bytes of beacon data to store temperature and battery voltage information and have a suggestion to help clean up and simplify the beacon API for programming. These comments are based on revision 0.7 (August 2016) of the mc-Script user guide.

This is the current state of the beacon API:

Shared Sub SendBeacon(data As ListOfByte)
Shared Sub SetBeacon(time As Integer, data As ListOfByte)
Shared Sub SetBeaconData(data As ListOfByte)
Shared Sub SetBeaconTime(time As Integer)
Shared Sub BeaconNow()

For a programmer to send data in the beacon, one of the first three sub procedures must be used. SendBeacon could be used in conjunction with a timed Shared Event, but this may (sometimes) require using SetBeaconTime with 0 as the time argument. SetBeacon implies that the data is set only once, so sending data that changes over time (such as temperature) doesn't make much sense here. SetBeaconData works when SetBeaconTime is used (unless the default of 10 seconds is acceptable), but SetBeaconData would have to be wrapped in a timed Shared Event. In my mind, there are questions regarding if 1 timed Shared Event will consistently fire (and finish processing) before the beacon interval fires, leading to a case where 2 beacons have the same temperature data and a temperature reading is missed.

My proposal is that additional Lifecycle Events (hooks) are added to the language. I pseudo-randomly found a development environment (Android https://developer.android.com/reference/android/app/Application.html) that exhibits this paradigm. If a Lifecycle Event (Software Events or additional Hardware Events may be appropriate names as well) named BeforeBeaconBroadcast was added, a programmer could use SetBeaconData in that routine and avoid using any other parts of the beacon API (although they are still useful). Using this approach, there would be no question that the data was set correctly on the outgoing beacon.

Share on Facebook Share on Twitter