Sharing data between two EWON Flexy in two different locations

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

Can you share a backup with support files from the relevant Ewons? That should give us a look at any errors that are being reported as they try to run this code.

Can you try making the relevant API calls in Postman, or another external tool for testing APIs? That will help verify that your details are correct and being accepted by our API, and that your remote Flexy is updating its data in response.

How do I share a backup file with you?

I am new to API so I am not sure how to test your suggestion. Is there something I need to sent up in the EWONs to use the API. I have registered and received a developer ID already.

You can use eBuddy to capture a backup with support files from your Ewon. To do this, open eBuddy, select the Ewon device you’d like help with, and click “Backup/Restore”. Make sure to check “include support files”, then click through to create a backup.

If you don’t have it, you can download eBuddy here: Ewon Software Download | Ewon Technical Support

To test the API call in Postman, download Postman for your system, then skip the login to open your workspace. You should see Scratch Pad at the top left. A bit to the right of that, click Import, then import this collection file:
Test Flexy Sync.postman_collection.json (1.4 KB)

Once that’s imported and you’ve selected the request, you’ll need to change DEVICE-NAME in the URL (near the top, next to POST) to the name of your Ewon. Then in the Query Params, change the values of TagName, TagValue, t2maccount, and so on to your own details. Finally, click Send at the top right to send the request. If everything works properly, the value on your Ewon should change. If it doesn’t, you may receive an error message in the Response area at the bottom. Here’s a screenshot of what everything should look like:

I am sharing tags between two eWon at different locations using ShareTalk2MTags Java addon and configuring the T2M_TAGS IOServer in both eWon. It requires developers id of eCatcher account.

The down side is it consumes lot of data. I am updating two tags every 15 seconds between two eWon.

1 Like

Thank you very much for explaining the “Postman” test to me. This will be very helpful now and in the future.

I am getting this error when I follow your steps: {“message”:“Device [xxxx] is currently unavailable”,“code”:502,“success”:false}

I tried running the same test with a few other EWON flexy we have on our account and I get the same error code. I can connect to the devices through eCATCHER without any issues. I will continue to look into my settings and see if maybe I have something not configured correctly.

Thank you for the info. I will do some research on this option and see if it will work for my aplication.

It’s interesting that you’re getting that error despite being able to reach the Ewon through eCatcher. It looks like you’re able to reach our servers to send the request, but the device is behaving as if it’s offline. What firmware version is the device running? If it’s not running the latest firmware (currently 14.6s0), can you update it and try again?

Can you share a backup with support files of the device you’re trying to update tags on?

Sure thing.
MOVED TO STAFF NOTE (147.5 KB)

It has 14.4s1 currently on it. I can try to update the firmware. I have not done that on any EWON devices yet so I will read how that is done while I wait for your response.

Thank you,

I updated firmware to 14.6s0 and I am still getting the same error in Postman.

Thanks for checking on that. Looking at your device’s backup, it seems to be having some network issues. It’s reporting frequent DNS failures as it tries to resolve the address of our access server and there are a lot of messages indicating the VPN connection starting and stopping repeatedly. Have you been able to connect consistently?

You mentioned testing this with other Flexys and also being unable to edit their tags despite them being reachable through eCatcher. Are those other devices at the same site? Can you share a backup from one of them as well?

Well I just have this one sitting on my test bench right now. There was a cellular card in it that was not set up yet with a sim card. I removed that card from the flexy. The other one I was using is for a different job that I was just using for testing while I still had it in the shop. The other one was set up and tested for sending emails and didn’t have any issues. The one that I have on the test bench I have not really tried staying connected to it for any length of time really. I am going to put some test code into it now to test that it can send emails through the Talk2M server. I will leave it powered up and connected over night tonight and see what the log says in the morning I guess. I have other EWONS out on site being used and they have no issues sending emails. I tried the Postman test with them and I get the same response. Is there anyway to see if my developer I.D. is good through my account? Is there anything in the account that is not allowing the tag update feature?

The EWON Flexy has no issue sending me an email using the Talk2M relay.