1
MQTT / Re: Sending MQTT messages to a MC-Product
« on: January 09, 2017, 09:12:52 pm »
Works. Thanks.
One problem ... it is slow.
Like a 30sec to 1min wait time.
How to i get the response time faster?
I doubt people would accept a delay of 1 minute to unlock the front door or turn on the lights.
Thanks.
'-------- code --------------------------------
Class ReceiveMQTT
Shared Event Boot()
Lplan.Subscribe("mcThings/000205D8")
End Event
Const GNSSTimeout_uS As Integer = 120000000
Const GNSS_MIN_SAT_COUNT As Integer = 3
Shared Event SubscriptionDelivery()
Dim msg As Message = Lplan.GetDelivery()
If msg.Topic= "mcThings/000205D8" Then
Dim payload As ListOfByte = msg.PayLoad
If payload.ToString() = "LightOn" Then
Led3 = True
End If
If payload.ToString() = "LightOff" Then
Led3 = False
End If
If payload.ToString() = "GPS" Then
Led2 = True
Thread.Sleep(50000)
Led2 = False
Device.StartGPS(GNSSTimeout_uS, GNSS_MIN_SAT_COUNT)
End If
End If
End Event
Shared Event LocationDelivery()
Dim lat As Float = Device.GetLatitude()
Dim lon As Float = Device.GetLongitude()
Dim time As Integer = Device.GetGpsFixTime()
Led2 = False
Dim lat_String As String
Dim lon_String As String
lat_String = lat.ToString()
lon_String = lon.ToString()
Dim payload As ListOfByte = New ListOfByte
Dim paystring As String = "Location: " + lat_String + " " + lon_String
payload.Add(paystring)
Lplan.Publish("/water", payload)
Thread.Sleep(100000)
Thread.ClearHardwareEvent()
Dim update As Integer = Device.Uptime()
End Event
End Class
'----------------------------------------
One problem ... it is slow.
Like a 30sec to 1min wait time.
How to i get the response time faster?
I doubt people would accept a delay of 1 minute to unlock the front door or turn on the lights.
Thanks.
'-------- code --------------------------------
Class ReceiveMQTT
Shared Event Boot()
Lplan.Subscribe("mcThings/000205D8")
End Event
Const GNSSTimeout_uS As Integer = 120000000
Const GNSS_MIN_SAT_COUNT As Integer = 3
Shared Event SubscriptionDelivery()
Dim msg As Message = Lplan.GetDelivery()
If msg.Topic= "mcThings/000205D8" Then
Dim payload As ListOfByte = msg.PayLoad
If payload.ToString() = "LightOn" Then
Led3 = True
End If
If payload.ToString() = "LightOff" Then
Led3 = False
End If
If payload.ToString() = "GPS" Then
Led2 = True
Thread.Sleep(50000)
Led2 = False
Device.StartGPS(GNSSTimeout_uS, GNSS_MIN_SAT_COUNT)
End If
End If
End Event
Shared Event LocationDelivery()
Dim lat As Float = Device.GetLatitude()
Dim lon As Float = Device.GetLongitude()
Dim time As Integer = Device.GetGpsFixTime()
Led2 = False
Dim lat_String As String
Dim lon_String As String
lat_String = lat.ToString()
lon_String = lon.ToString()
Dim payload As ListOfByte = New ListOfByte
Dim paystring As String = "Location: " + lat_String + " " + lon_String
payload.Add(paystring)
Lplan.Publish("/water", payload)
Thread.Sleep(100000)
Thread.ClearHardwareEvent()
Dim update As Integer = Device.Uptime()
End Event
End Class
'----------------------------------------