mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-03 03:09:59 +00:00
Make tcp API now work. Sample usage and caveats below:
Sample usage: First configure device to use @mc-hamster's new wifi stuff: meshtastic --set wifi_ssid mylanname --set wifi_password mylanpassword Then reboot the device (so wifi starts up). (assuming device was assigned addr 192.168.81.45) meshtastic --info --host 192.168.81.45 (See the usual device info you previously had to get over USB) Caveats: * Currently we are limiting to one active TCP connection open at once, if you open a new session the old one is closed automatically * There are no access controls/authentication needed to open a TCP connection to the device * Currently main.cpp is kinda dumb about how we should schedule work and we rely on too many helper loop() functions. Very soon in my queue (related to all the other cleanup) is to add a basic notion of coroutines, so that we can get away from freertos threads and this old school arduino loop function. Once that cleanup happens we can the a) have much lower battery consumption (always) and b) super fast response for all operations.
This commit is contained in:
parent
d1c3078698
commit
2996c7c8e2
@ -52,6 +52,14 @@ void WiFiServerPort::loop()
|
||||
{
|
||||
auto client = available();
|
||||
if (client) {
|
||||
new WiFiServerAPI(client);
|
||||
// Close any previous connection (see FIXME in header file)
|
||||
if (openAPI)
|
||||
delete openAPI;
|
||||
|
||||
openAPI = new WiFiServerAPI(client);
|
||||
}
|
||||
|
||||
if (openAPI)
|
||||
// Allow idle processing so the API can read from its incoming stream
|
||||
openAPI->loop();
|
||||
}
|
@ -29,6 +29,13 @@ class WiFiServerAPI : public StreamAPI
|
||||
*/
|
||||
class WiFiServerPort : public WiFiServer
|
||||
{
|
||||
/** The currently open port
|
||||
*
|
||||
* FIXME: We currently only allow one open TCP connection at a time, because we depend on the loop() call in this class to
|
||||
* delegate to the worker. Once coroutines are implemented we can relax this restriction.
|
||||
*/
|
||||
WiFiServerAPI *openAPI = NULL;
|
||||
|
||||
public:
|
||||
WiFiServerPort();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user