Author Topic: Lplan.Subscribe error  (Read 220 times)

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Lplan.Subscribe error
« on: July 20, 2016, 04:28:25 am »
Hello.

I have noticed several errors when using Lplan.Subscribe on a mcModule.

This is what i have seen so far.

When using this Lplan.Subscribe("mcModule/Kitchen/freezer") then the Shared Event SubscriptionDelivery() will trigger when a message is sent to that topic, but if I change to Lplan.Subscribe("mcModule/Kitchen/#") then it does not trigger and sometimes I get error in mcStudio (could not read data...) and after I have debugged with Lplan.Subscribe("mcModule/Kitchen/#") then i can't end the debug session.
I think i did read that the # was now supported in mcModule?

I also noticed that when i run several tests with this then my mcGateway stopped to publishing to MQTT from my other devices, I had to reset the mcGateway to get that working again.

I will continue to run more tests and I hope i could collect some more data that could help but i thought it was good to start the topic.

Share on Facebook Share on Twitter


kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: Lplan.Subscribe error
« Reply #1 on: July 23, 2016, 03:27:30 am »
I have now tested some more.

If I add two Lplan.Subscribe in the boot event then the mcModule freezes, sometimes mcStudio reports back could not read data but most of the times mcStudio does nothing and when trying to stop the debug session it gives error message Stop Debugging failed.

If i add one Lplan.Subscribe that is published from external system then it does not work, but add one Lplan.Subscribe to a topic that another mcModule is publishing on that works.

So this is what i got.

Two Lplan.Subscribe don't work
One Lplan.Subscribe local topic work
One Lplan.Subscribe external topic don't work

Could someone please test this with the latest firmware? and verify if you get the same result as I.

helge

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Lplan.Subscribe error
« Reply #2 on: July 23, 2016, 09:14:43 am »
I've tested the following code and it does work, the module does not freeze in runtime mode. I didn't try to debug it.

Sometimes my MQTT server doesn't get the external publish, don't know why yet. Maybe a mosquitto bug, dunno.

Code: [Select]
Class MQTTSubscribeExample
    Const DeviceId As String = "mc-001"
    Const SubscribeTopicLED1 As String = "mcThings/ioT/" + DeviceId + "/led1"
    Const SubscribeTopicLED2 As String = "mcThings/ioT/" + DeviceId + "/led2"
   
    Shared Event Boot()
        Lplan.SetLowPowerMode(1) ' CAUTION: do not use 1 second interval in production
        Lplan.Subscribe(SubscribeTopicLED1)
        Lplan.Subscribe(SubscribeTopicLED2)
    End Event
   
    Shared Event SubscriptionDelivery()
        Dim msg As Message = Lplan.GetDelivery()
        If msg.Topic= SubscribeTopicLED1 Then
            Dim payload As ListOfByte = msg.PayLoad
            If payload(0) = 0x31 Then
                LedGreen = True
            Else
                LedGreen = False
            End If
        ElseIf msg.Topic= SubscribeTopicLED2 Then
            Dim payload As ListOfByte = msg.PayLoad
            If payload(0) = 0x31 Then
                LedRed = True
            Else
                LedRed = False
            End If
        End If
    End Event
End Class

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: Lplan.Subscribe error
« Reply #3 on: July 23, 2016, 09:17:00 am »
Okey, thats good.
I have only tried in debug mode.

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: Lplan.Subscribe error
« Reply #4 on: July 23, 2016, 04:30:20 pm »
I have made som more tests with different mcModules and now it seems like it could have been a broken battery that was causing this behavior.
I will continue my investigation.