nodemcu / nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32

Home Page:https://nodemcu.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alignment between ESP32 and ESP8266 library

pjsg opened this issue · comments

Expected behavior

Functions like file.getcontents ought to be available (and behave the same) on both ESP32 and ESP8266 branches.

Actual behavior

file.getcontents isn't available on the dev-esp32-idf4 branch.

This is just one example of the differences -- the wifi module is different as well. It isn't clear which is the path forward -- it would be nice to align some of this stuff. I suspect that the esp8266 stuff has progressed and left the esp32 stuff behind, but I'm not sure.

Thoughts?

Even the partial list from 2018 is daunting and discouraging: https://github.com/nodemcu/nodemcu-firmware/wiki/ESP8266---ESP32-Compatibility

I believe when @jmattsson created the ESP32 port he considered the shortcomings of the initial API and improved it.

I'm happy if we say that the ESP32 versions are the way forward, but I suspect that much of the 8266 interface is actually an improvement.

Maybe we should just decide on what to do on a module-by-module basis. The two of interest to me (at the moment) are:

file https://nodemcu-firmware.readthedocs.io/en/dev-esp32/modules/file/ vs https://nodemcu-firmware.readthedocs.io/en/master/modules/file/
wifi https://nodemcu-firmware.readthedocs.io/en/dev-esp32/modules/wifi/ vs https://nodemcu-firmware.readthedocs.io/en/master/modules/wifi/

I propose that the esp8266 interface is better than the current esp32 interface and we should migrate forwards.

Any contrarians?

I'm in the process of deprecating most of the file module in favour of the standard Lua io module on the ESP32...

Also keep in mind that the underlying SDKs are utterly different between the 8266 and the 32, both in terms of structure and in terms of features.

I feel that whatever we do on the ESP32 side we should leave the ESP8266 APIs as is. On the ESP32 side we have complete freedom IMO as we never officially released anything.

I feel that whatever we do on the ESP32 side we should leave the ESP8266 APIs as is.

I agree. The API there is the way it is for good reason (well, mostly at least). Trying to shoehorn an ESP32-based view onto it makes as little sense as shoehorning the 8266isms onto the ESP32.

I'd quite like to have us settle on some sort of standard naming convention. It's all a bit of a mess at the moment.
Something like

  • Functions consisting of multiple words should (or should not) contain underscores between the words (or camel case even?)
  • Setters are (or are not) prefixed with "set", while getters are (or are not) prefixed with "get".
  • Module constants are in upper case, with underscores between words (I think this is one that's mostly followed?)

I'm really not too fussed about which way we lean, as long as we're consistent about it. Right now on the esp32 we have wifi.sta.setip() but eth.set_ip() for example, which is a bit confusing.

I'm in the process of deprecating most of the file module in favour of the standard Lua io module on the ESP32...

@jmattsson, there are pros and cons this approach, so perhaps it is worth thinking through and discussing the implications.

I realise that file library was a bit of an interim botch by zeroday as his original intention was to introduce a proper io implementation at some point. It has also evolved in a somewhat uncontrolled manner, and now includes elements of os and other convenient methods. A lot of ESP Lua developers have now written code for the ESP8266 implementation, and this is quite a break that will force them to do a lot of recoding to migrate to ESP32, and this could be significantly mitigated by keeping (possibly) a subset library which is essentially a wrapper around the io implementation.