Executive summary:
How long does it take the IMP to wake up and start monitoring the UART?
How long should the sending device wait after taking PIN1 high to begin sending data?
Back ground
Lets forget about all the other problems. I can conditional a server.sleepfor when the data is complete or copy the function setup in your code. I can also strip the 00h at the end of the send to make the conversion to ascii correct.
The stopper problem I cannot manage is wakeup on pin 1 then read the UART.
I know it is sending correctly because:
-putty with FTDI = 1,0,072.0,071.5,079.0,078.5,100.0
-awake imp UART=1,0,072.0,071.5,079.0,078.5,100.0 (my code strips the trailing 00h)
-IMP wake up and read=72 aa 62 82 ba ca 72 82 62 82 ba c2 72 aa 62 8a 82 82 72 82 6a 0a 00
the code you posted returns this:
2015-03-29 16:43:31 UTC-5 [Device] awake for 529ms, got string '23', going to sleep 2015-03-29 16:43:31 UTC-5 [Device] binary: 72 aa 62 82 ba ca 72 82 62 82 ba c2 72 aa 62 8a 82 82 72 82 6a 0a 00 2015-03-29 16:43:31 UTC-5 [Device] sleeping until 1427665611000
FYI its actually 36 with the trailing 00h.
when I mod your code and comment out the server.sleep for as follows: `
function sleepnow() {
imp.onidle(function() {
now = hardware.millis() - now;
server.log(“awake for “+now+“ms, got string '”+s+”’, going to sleep”);
//server.sleepfor(200); //STAYS AWAKE FOR THE NEXT SEND
});
}
`
the response is 2015-03-29 16:51:08 UTC-5 [Device] awake for 1007ms, got string '0', going to sleep 2015-03-29 16:51:08 UTC-5 [Device] 2015-03-29 16:52:43 UTC-5 [Device] awake for 98659ms, got string '36', going to sleep 2015-03-29 16:52:43 UTC-5 [Device] binary: 31 2c 30 2c 30 37 32 2e 30 2c 30 37 31 2e 35 2c 30 37 39 2e 30 2c 30 37 38 2e 35 2c 31 30 30 2e 30 0d 0a 00
The last line show binary because of the trailing 00h which is put in for end of string.
Removing the 00h makes it converts correctly to 1,0,072.0,071.5,079.0,078.5,100.0.
My code (which is considerably different from yours) is the same. Awake for send = OK. Wake up and read = not ok.
Our system currently takes PIN1 high and waits 5mS before sending data. I have tried 500mS and 1mS. The results were roughly the same with not enough data received after a wakeup. (although the data string received was different in each case)