iOS Toolkit App

Hi MeiGuoRen,
Thank you for the comments - Sadly, I don’t currently have time to do an android version at the moment.


Version 3.1 of Mesh Developers Toolkit, has been just released in the iTunes Store and adds two options to allow for you to broadcast and scan for iBeacons containing guids.

This functionality works when the App is in the foreground and allows you to scan for other Mesh Developers Toolkits running iBeacons.

This allows you to quickly share your GUID without the need for a “shout” message.

A new Today Widget, “Mesh quick share”, allows you to switch of the broadcasting and scanning of the iBeacon for three minutes without the need to manually switch the functionality on in the setting dialog:

IMG_0090

The widget allows you to quickly startup advertising or scanning for the iBeacon as iBeacons cannot run in the background.

Three “Script events” are generated when the App detects, or loses an iBeacon from another Mesh Toolkit (or something else - see below):

  • beacon_found - with the new GUID being passed in the “guid” variable.

  • beacon_disconnected - with the GUID of the device disconnected in “guid” in the “guid” variable.

  • all_beacons_disconnected - when all devices have disconnected.

You can handle the event as follows (and the default script has been updated to reflect these events):

if (message == "startup_event") {
     shout("Startup");
      return "";
} else if (message == "beacon_found") {
      send(guid,"Hi this is my guid");
      return "";
} else if (message == "beacon_disconnected") {
      print("beacon_disconnected");
      return "";
} else if (message == "all_beacons_disconnected") {
      print("all_beacons_disconnected");
      return "";
} else {
      return message;
}

But in addition to using Mesh Developers Toolkit running as an iBeacon, other devices can run generate a iBeacon, for example a raspberry pi zero-w.

The following script will start advertising a beacon which can be found by Mesh Developers Toolkit:

sudo hciconfig hci0 up
sudo hciconfig hci0 leadv 3
sudo hciconfig hci0 no-scan
sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 E2 C5 6D B5 FD BF D8 2D 60 B0 E4 D0 10 96 F7 A5 00 00 ff ff C8 00

The bytes 00 00 FF FF indicate the “guid” and I would suggest that you set these to a value less than 65535 (only change the FF FF pairs) to identify you “iBeacon”
, you can then check for this in your script:

if (message == "beacon_found") {
     if (guid > 65535) {
          // its a goTenna
          send(guid,"Hi this is my guid");
     } else {
          // its a raspberry pi
          print("I am at a beacon - do something.");
     }
     return "";
}

I have found that a beacon running on a raspberry pi drops very quickly - so you will get multiple connect and disconnect events - but I have not had time to investigate.

Three new javascript functions have also been added:

  • startweb() - to start the inbuilt web server from the script.

  • stopweb() - stops the inbuilt web server.

  • pressure() - if the iPhone or iPad has an inbuilt barometer, this function returns the current barometric pressure.


How can you use this functionality?

If you have two devices you can quickly share your guid with someone else, using the script (like Lynq compete app? - #3 by Pete94):

if (message == "beacon_found") {
     if (guid > 65535) {
          // its a goTenna
          send(guid,"Hi this is my guid");
     }
}

If you have Mesh Developers Toolkit in a fixed location, you can by default switch the web server off and only switch it on (to view the graphs etc.) when you are in close proximity of the device:

if (message == "beacon_found") {
     if (guid == 123456789) {
          // its my goTenna
          startweb();
     }
     return "";
} else if (message == "beacon_disconnected") {
     if (guid == 123456789) {
          // its my goTenna
          send(guid,"Hi this is my guid");
          stopweb();
     }
     return "";
}

Use a few pi-zeros as “beacons” to allow people to quickly check in, using the widget, when they reach a particular way point (e.g. back at camp)…

2 Likes