adafruit / Adafruit_CircuitPython_ESP_ATcontrol

Use the ESP AT command sent to communicate with the Interwebs
MIT License
20 stars 17 forks source link

add try/except to cheerlights demo #13

Closed jerryneedell closed 5 years ago

jerryneedell commented 5 years ago

fixes #12

<--- b''
[b'']
---> AT+CIPCLOSE
<--- b'CLOSED\r\n\r\nOK\r\n'
Reply is OK!
---------------------------------------- Size:  0

----------------------------------------
IndexError processing Body, retrying
 list index out of range
---> ATE0
<--- b'\r\nOK\r\n'
---> AT+CIPSTATUS
<--- b'STATUS:4\r\n\r\nOK\r\n'
Retrieving data source...---> AT+CIPSTATUS
<--- b'STATUS:4\r\n\r\nOK\r\n'
---> AT+CIPSTART="TCP","api.thingspeak.com",80,10
<--- b'CONNECT\r\n\r\nOK\r\n'
---> AT+CIPSTATUS
<--- b'STATUS:3\r\n+CIPSTATUS:0,"TCP","52.0.246.0",80,59857,0\r\n\r\nOK\r\n'
---> AT+CIPSEND=109
<--- b'\r\nOK\r\n'
<--- b''
Receiving: 1276
[b'HTTP/1.1 200 OK', b'Content-Type: application/json; charset=utf-8', b'Transfer-Encoding: chunked', b'Connection: close', b'Status: 200 OK', b'X-Frame-Options: SAMEORIGIN', b'Access-Control-Allow-Origin: *', b'Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE, PATCH', b'Access-Control-Allow-Headers: origin, content-type, X-Requested-With', b'Access-Control-Max-Age: 1800', b'ETag: "97ee10b474406c89ea7eabc03786b9d1"', b'Cache-Control: max-age=0, private, must-revalidate', b'X-Request-Id: a0fd91ad-6f58-423b-be26-d6c956e1fa43', b'X-Runtime: 0.020318', b'X-Powered-By: Phusion Passenger 4.0.57', b'Date: Thu, 27 Dec 2018 16:43:32 GMT', b'Server: nginx/1.9.3 + Phusion Passenger 4.0.57', b'', b'264', b'{"channel":{"id":1417,"name":"CheerLights","description":"CheerLights is an \xe2\x80\x9cInternet of Things\xe2\x80\x9d project created by Hans Scharler that allows people\xe2\x80\x99s lights all across the world to synchronize to one color set by Twitter. This is a way to connect physical things with social networking experiences.","latitude":"40.5","longitude":"-80.22","field1":"Last CheerLights Command","field2":"CheerLights HEX Color","created_at":"2011-12-01T03:30:04Z","updated_at":"2018-07-20T01:05:15Z","last_entry_id":498816},"feeds":[{"created_at":"2018-12-27T16:20:49Z","entry_id":498816,"field1":"pink","field2":"#FFC0CB"}]}', b'0', b'', b'']
---> AT+CIPCLOSE
<--- b'\r\nERROR\r\n'
Reply is OK!
---------------------------------------- Size:  624
264
ladyada commented 5 years ago

ooh can you stick the valueerror check here? https://github.com/adafruit/Adafruit_CircuitPython_ESP_ATcontrol/blob/master/examples/espatcontrol_cheerlights.py#L61 that's a little more elegant?

jerryneedell commented 5 years ago

but it failed on the index of lines[1] on line 86 since there is no [1] https://github.com/adafruit/Adafruit_CircuitPython_ESP_ATcontrol/blob/master/examples/espatcontrol_cheerlights.py#L86

ladyada commented 5 years ago

oh right! sorry i thought it was the json indexer. whee!