Re: Problem with getting "msgreturn" msg from one ESP to ano
Posted: Wed Jan 18, 2017 5:26 am
I'm thinking it might be something with the Wget function (possibly) ..and wondered if maybe there was another way of receiving the returned message.
You could try returning your messages using udp, even if just to prove the point.
The transmitter would need to include something like...
Code: Select all
udpport = 5001 '(or whatever your preferred port number)
targetIP = "192.168.1.17" '(or whatever your required destination IP)
myrtnmsg = "whatever message you wish to send"
udpwrite targetIP, udpport, myrtnmsg
The receiver would need to set up a udp listening port and branch, something like...
Code: Select all
udpport = 5001
udpbegin udpport 'sets up a udp port to listen for incomming messages
udpbranch [UDPMSG] 'branch to handle incoming messages
wait
[UDPMSG]
mypayload = udpread() 'reads incoming msg into your designated variable
if mypayload = "this" then gosub [DoThis] else gosub [DoThat]
return
If both nodes contain both the appropriate transmit and receive codes they can send and receive messages with each other just using udp.
I should point out that you have a very long line which may give problems...
if status = "ON" or status = "OFF" then myrtnmsg="MSG OK" else myrtnmsg="MSG ERROR" 'SET RETURN MSG TO "MSG OK" IF "ON" OR "OFF" RECEIVED, "ERROR" IF ANYTHING ELSE
Lines that don't contain a carraige return before the end of the edit line will wrap over to the next line (usually just comments), which Esp_Basic used to assume was the beginning of a new line to be interpreted. It used to cause many weird errors until I twigged it and took pains to ensured my lines have never wrapped around since.