I found an example code of the BASIC IDE on one of these discussions. I tried the code and I am not getting any data to transfer. The code I copied is below. I left out my personal information so it cannot be copied.
Doc Created by: Time Beaulieu
Code Created by: Deryck Beliveau
I have a tag in both EWONs named “Tag1” with a tag description “send”
I altered these fields in the code with my information.
//Account info
account$ = “tims”
username$ = “script_user”
password$ = “script_user”
developerid$ = “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”
//info for remote flexy
devicename$ = “Deryck_Flexy”
deviceusername$ = “adm”
devicepassword$ = “adm”
Is there more I need to change? I do receive a “data sent” message but the tag in the destination EWON does not get updated with the the source EWON value.
TSET 1, 5
ONTIMER 1, “GOTO UpdateRemote”
ONSTATUS “@response()”
//Account info
account$ = “tims”
username$ = “script_user”
password$ = “script_user”
developerid$ = “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”
//info for remote flexy
devicename$ = “Deryck_Flexy”
deviceusername$ = “adm”
devicepassword$ = “adm”
url$ = “https://m2web.talk2m.com/t2mapi/get/"+devicename$+"/rcgi.bin/UpdateTagForm?"
accountinfo$ = “&t2maccount=”+account$+”&t2musername="+username$+"&t2mpassword="+password$
accountinfo$ = accountinfo$ + “&t2mdeveloperid=”+developerid$+"&t2mdeviceusername="+deviceusername$+"&t2mdevicepassword=" + devicepassword$
UpdateRemote:
TSET 1, 0
method$ = “POST”
//get number of tags and loop through each one
SETSYS SYS, “LOAD”
C% = GETSYS PRG,“NBTAGS”
x%=1
n%=0
FOR i% = 0 TO (C% - 1)
SETSYS TAG,“LOAD”, -i%
tagname$ = GETSYS TAG,“Name”
desc$ = GETSYS TAG, “Description”
If (desc$ = “send”)Then
// Print tagname$ + desc$
a$ = GETSYS TAG,“TagValue”
IF (x% = 1) Then
payload$ = “&TagName”+ STR$(x%) + “=”+tagname$+"&TagValue"+ STR$(x%) + “=”+ a$
n%=1
Else
//for each loop grab the tag at with that ID and send to remote site
payload$ = payload$ + “&TagName”+ STR$(x%) + “=”+tagname$+"&TagValue"+ STR$(x%) + “=”+ a$
ENDIF
x%=x%+1
//Print "success “+“index: " + STR$(i%)
Endif
NEXT i%
//Print payload$
If (n% = 1)Then
payload$ = payload$ + accountinfo$
REQUESTHTTPX url$, method$,”” , payload$
actionID% = GETSYS PRG, “ACTIONID”
//ONSTATUS “@response()”
Print “Data sent”
Endif
TSET 1, 5
END
FUNCTION response()
eventId% = GETSYS PRG, “EVTINFO”
IF (eventId% = actionID%) THEN
SETSYS PRG, “ACTIONID”, eventId%
stat% = GETSYS PRG, “ACTIONSTAT”
IF (stat% = 0) THEN
b$ = RESPONSEHTTPX "STATUSCODE"
IF (b$ <> "200")THEN
LOGEVENT "HTTP RESPONSE: " + b$ ,77
//can add an event here on error
ENDIF
ELSE
LOGEVENT "Error (ERROR = "+Str$(stat%) + ")" , 78
//LOGEVENT url$,79
//LOGEVENT payload$,80
ENDIF
ENDIF
Endfn