adafruit / Adafruit_CircuitPython_ESP_ATcontrol

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

allow baud rate change #6

Closed jerryneedell closed 5 years ago

jerryneedell commented 5 years ago

See if you think this is a good way to do this. espatcommands has an input parameter baudrate but it actually does not use it so I use it to allow you to switch the baudrate after it initializes. At 115200 I am getting a lot of dropped characters. it works much better at 9600 baud! We can change the baudrate of the ESP8266 or ESP32 permanetly via AT+UART_DEF but this way we can start at the 115200 default and set it if we want to. If the input baudrate matches the current baudrate setting, then it does not do anything so you don't have to use this.

jerryneedell commented 5 years ago

oh yeah -- this also fixed the funny issue with the missing space after the send prompt on the nrf52!

ladyada commented 5 years ago

nice!

ladyada commented 5 years ago

wanna maybe move that code to a set_baudrate() function, that way people can call it if they need

jerryneedell commented 5 years ago

sure - will do.

jerryneedell commented 5 years ago

I left the old unused baudrate in place (renamed ) since taking it out breaks all the examples. Do you want me to take it out now as well?

ladyada commented 5 years ago

perhaps init() should perform the initial baudrate setting as well?

jerryneedell commented 5 years ago

ah -- ok - set it in init if it is different -- that makes sense - I like this because you can change it back when you are done if you want!

ladyada commented 5 years ago

either way, i expect this to change a bunch before 'release' :)

jerryneedell commented 5 years ago

I now have things working on on the external ESP8266 via normal UART and the the particle argon on board ESP32 with the modified AT Firmware using the programming uart ! Still need to test external ESP32 with normal UART. Just trying to find a common set of code that works on all -- I'm close. If you are not in a rush I hope to have some updates later today and I can just add them to this PR or you can merge this and I'll create a new one -- or close this one and I'll start over with all my changes. Whatever works for you.

jerryneedell commented 5 years ago

@ladyada I updated this to my latest working version mostly so you can see what I've been doing. I can use any of the AT Firmware options with this (external ESP8266 or ESP32) with the standart UART AT firmware or the onboard ESP32 in the Particle_argon with the modfied AT FIrmware)

One thing I had to do was comment out one of the checks done for the .send function. It turns out there are some tricky differences in the way the various AT firmwares respond and since we already verify the we received "SEND OK" it was not clear how much of this checking really was needed. I'll look into a way to re-instate it. The baudrate change seems to work well and is very useful. The various timeouts are just ones I adjusted but I'm really not sure what they have to be yet. You are welcom to merge this if you are happy with it or I can keep adding to it.