IBM Cloud

Hi,
I am planning to send my data to IBM using MQTT.
It works well but after eWON Reboot or drop connection, the data cannot be send to IBM again automatically.
The code is as below:
Init Section:
Mqtt “Open”,"d:::*",".messaging.internetofthings.ibmcloud.com"**
Mqtt “SetParam”,“Port”,"1883"
Mqtt “SetParam”,“Username”,"use-token-auth"
Mqtt “SetParam”,“Password”,"-----------"
Mqtt "Connect"

Tset 1,5
Ontimer 1,"goto MqttPublishValue"
End
Public Section:
Function GetTime$()
** $a$ = time$**
** $GetTime$ = $a$(7 To 10) + “-” + $a$(4 To 5) + “-” + $a$(1 To 2) + " " + $a$(12 To 13)+":"+$a$(15 To 16)+":"+$a$(18 To 19)**
EndFn

MqttPublishValue:

json$ = '{'
json$ = json$ + '“d”: {'
json$ = json$ + ‘“Temperature”:"’ + STR$ Temperature@ + '",'
json$ = json$ + ‘“time”: "’+@GetTime$()+’"'
json$ = json$ + '}'
json$ = json$ + '}'

status% = Mqtt "status"
** If status% = 5 Then**
** Mqtt “Publish”,“iot-2/evt/ewondata/fmt/json”,json$,0,0**
** Print “Value published”**
** Else**
** Print “Not Connected”**
** Endif**
End
How can i make it run automatically after reboot?

When on the basic IDE page in the upper right the is a “run” button. If you click that a drop down menu with appear where you can check “autorun”.

Hi,
I did checked the autorun button but it still cannot send data after ewon reboot.
Is that any problem with my code?

Hi,

Try inserting a delay in the code.

Tset 1,30
Ontimer 1, “@code_delay()”

Function code_delay()
tset 1,0
//Put code here
Endfn