Author Topic: Sending Beacon Data Over MQTT  (Read 462 times)

bdevlin

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Sending Beacon Data Over MQTT
« on: October 23, 2017, 08:31:34 pm »
Here's a snippet of code that works. I use it for versioning the MC-110/120 modules. This way I can see in the ide which ones have the latest code.

Class mqtt_json
    Shared version As Float
    Shared Event Boot()
        '############ This is your mcMod software version. You can see the version in the first byte of beacon data in Device maintenence and Connections under the ->Tools->Devices menu.
        version = 2
        '############ Add the version to the first byte of beacon data.
        Dim beacondata As ListOfByte = New ListOfByte()
        beacondata.Add(version.ToByte)
        Lplan.SetBeaconData(beacondata)
       
       
        '### Write out boot acknowledgement for debugging. Not required for the beacon, but picked up in an MQTT subscription
        Dim id As String = Device.mcUID().ToString("x8")
        Lplan.Publish("mqtt/boot", ("{Boot:" + id + ",Version:" + version.ToString+ "}").ToListOfByte, QoS.AtLeastOnce)       
    End Event

Useful Useful x 1 View List