-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client driver for WiFiNINA firmware #98
Conversation
This is going to be very useful, thanks for working on it @bgould |
I've implemented enough at this point to connect to wifi and open a TCP connection and send data. The code needs some serious cleanup, which I will do, but I wanted to get something pushed in order to get some feedback on how the net package can be implemented. I copied the espat/net package and refactored it so that it relies on a "DeviceDriver" interface with a few methods to make it easier to switch between implementations. To wit: https://github.com/tinygo-org/drivers/blob/03adeaccb49a5feef5e69b76bdb3359565b627d0/wifinina/net/device.go
Do you think this is the correct approach, and if so should the "net" package be moved out of the espat package? |
2a664a7
to
0ce521b
Compare
I think this is starting to get close to being ready for an initial release. Known issues that work in espat but not with wifinina include:
The
In my opinion, if we are going to do that I think it might make sense to continue to iron out the "net" package in the drivers repo so that we can iterate more quickly and get the
If we agree on the above steps, I can open a new PR with those changes, and then once merged I can rebase this PR against it (which should reduce the size of this one a lot and I think make it more approachable from a review standpoint). Please advise about the above approach, thank you. |
Here is some feedback:
We for sure want to share as much implementation as possible here. There are yet other WiFi chipsets that we want to support that have similar implementation patterns, such as the ATECC608A family.
This is inevitable implementation detail that we probably cannot avoid.
Once we declare a 1.0 release, we are going to want to make some backward compatability guarantees, but this package is not at that point yet. What I am saying is that needed API changes are still acceptable, IMO.
We probably want to define an interface, and then implement it using the lower level APIs of whichever WiFi chips we will support. Anyhow, these are all excellent suggestions, I am happy to help out as well to make it happen! |
Hi, plans to have BLE commands access ? Or only wifi ? |
Nice! Thank you! |
Btw, wifiNina works with Arduino Uno ? (atmega328p) |
I didn't have any plans to work on a BLE driver at this time; I looked briefly at the Arduino library that exists for this and it looks pretty different than the protocol for wifi so there might not be a log that can be reused from the work I've already done... I could be wrong about that though
I haven't tried this, so it probably doesn't work well. In theory there is no reason that it shouldn't work, except that I did not really make the memory buffers fit into the small amount of RAM that chip has. Also I don't think TinyGo on AVR has garbage collection so that could be a problem. |
@deadprogram I should be able to get this rebased and ready to merge in the next few days, at least without UDP and possibly not TLS for now. I would like to fix whatever bug there is that is causing MQTT subscriptions to break after a little while, which I think shouldn't take too long. I'll work on that and also any remaining cleanup to get this ready to merge |
The MQTT subscriptions bug is probably in my implementation, and if you fixed that along the way I certainly would be most grateful! ;) |
07ea9e0
to
10549ed
Compare
After rebasing with #106 I'm not noticing the same issue I saw before with MQTT subscriptions being dropped, so I am removing (WIP) from the title and considering this ready to merge. There are still features I'd like to add and I'm sure some things will need to be fixed along the way, but I think this is an ok starting point. |
This is so very close to landing! I suggest adding the new examples to the smoke tests here: https://github.com/tinygo-org/drivers/blob/dev/Makefile#L10 Also, add to https://github.com/tinygo-org/drivers/blob/dev/README.md#currently-supported-devices Then we merge. |
Test failure was due to my inclusion of the MQTT examples in the smoke tests; since these have an external dependency it was failing. It could be fixed I think by adding a |
@bgould I cannot thank you enough for this contribution. It will make the onboarding process for developers so much easier, and thanks to the SPI interface it should be a lot faster as well. For developers with a NINA co-processor on the same physical board, in particular those with the WiFiNINA code already installed, it will make a big difference. Thank you also for all the changes getting this PR ready to merge... which I am going to squash/merge now! |
* wifinina: implementation of WiFiNINA driver, including: - TCP client example is working - reading sockets and mqtt working - switched over to common net package also used by espat package - smoke tests and updated README for wifinina
An alternative to the ESP-AT firmware for ESP8266 and ESP32 is nina-fw from Arduino: https://github.com/arduino/nina-fw
This is the default firmware on ESP chip of the Arduino Nano 33 IOT as well as a number of Adafruit boards and daughterboards, having a driver for it would obviate the need to reflash the ESP chip and simplify the experience of using these boards with TinyGo. Also, this firmware uses 8MHz SPI instead of UART which should be faster could eventually take advantage of DMA.
Currently WIP; code for framing messages to the ESP chip according the firmware's protocol and a number of commands are working. This initial commit has enough functionality implemented to initialize the SPI communication, scan for and connect to wifi networks, and read connection status and IP information.
Next steps will be to get connection and data transfer working with an API that matches espat/net with the goal that eventually users can easily choose between either implementation without having to rewrite their code.