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.
pull/438/head
geeksville 2020-09-25 16:18:30 -07:00
rodzic d1c3078698
commit 2996c7c8e2
2 zmienionych plików z 16 dodań i 1 usunięć

Wyświetl plik

@ -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();
}

Wyświetl plik

@ -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();