Get reference to existing WiFi interface object?
Posted: Sat Aug 06, 2022 8:08 pm
I have been using mqtt_as as well as a couple of other MQTT classes for MicroPython, basically learning how they have been implemented. And this has exposed an interesting question, IMHO, anyway.
All of these classes basically own the network.WLAN object they create. Which means that interface is hidden effectively, other than changing the class to allow visible access to said interface. Is there any other way to get a reference to that (hidden) interface object? Some clever trick or method, of the network.WLAN object, that is not illustrated in the typical documentation?
An example is, say I need to grab the MAC address, so I can create a unique host name, similar to what the default host name for Tasmota based devices do, i.e. tasmota_XXXXXX.
Maybe tweaking a given class like mqtt_as, to explicitly expose the interface object, is the only or best option? Given my unique use case, not sure such would applicable to forking the given module/class or even suggesting it to the applicable author.
Of course, I can always create my own object, get what I need, then release it and let the MQTT class do its thing, but that seems like a lot of code to get from point A to B, when there might be a better way?
All of these classes basically own the network.WLAN object they create. Which means that interface is hidden effectively, other than changing the class to allow visible access to said interface. Is there any other way to get a reference to that (hidden) interface object? Some clever trick or method, of the network.WLAN object, that is not illustrated in the typical documentation?
An example is, say I need to grab the MAC address, so I can create a unique host name, similar to what the default host name for Tasmota based devices do, i.e. tasmota_XXXXXX.
Maybe tweaking a given class like mqtt_as, to explicitly expose the interface object, is the only or best option? Given my unique use case, not sure such would applicable to forking the given module/class or even suggesting it to the applicable author.
Of course, I can always create my own object, get what I need, then release it and let the MQTT class do its thing, but that seems like a lot of code to get from point A to B, when there might be a better way?