mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-21 10:42:35 +10:00
add a .clang-format file (#9154)
This commit is contained in:
+88
-96
@@ -8,124 +8,116 @@
|
||||
|
||||
PacketAPI *packetAPI = nullptr;
|
||||
|
||||
PacketAPI *PacketAPI::create(PacketServer *_server)
|
||||
{
|
||||
if (!packetAPI) {
|
||||
packetAPI = new PacketAPI(_server);
|
||||
}
|
||||
return packetAPI;
|
||||
PacketAPI *PacketAPI::create(PacketServer *_server) {
|
||||
if (!packetAPI) {
|
||||
packetAPI = new PacketAPI(_server);
|
||||
}
|
||||
return packetAPI;
|
||||
}
|
||||
|
||||
PacketAPI::PacketAPI(PacketServer *_server)
|
||||
: concurrency::OSThread("PacketAPI"), isConnected(false), programmingMode(false), server(_server)
|
||||
{
|
||||
api_type = TYPE_PACKET;
|
||||
PacketAPI::PacketAPI(PacketServer *_server) : concurrency::OSThread("PacketAPI"), isConnected(false), programmingMode(false), server(_server) {
|
||||
api_type = TYPE_PACKET;
|
||||
}
|
||||
|
||||
int32_t PacketAPI::runOnce()
|
||||
{
|
||||
bool success = false;
|
||||
int32_t PacketAPI::runOnce() {
|
||||
bool success = false;
|
||||
#ifndef ARCH_PORTDUINO
|
||||
if (config.bluetooth.enabled) {
|
||||
if (!programmingMode) {
|
||||
// in programmingMode we don't send any packets to the client except this one notify
|
||||
programmingMode = true;
|
||||
success = notifyProgrammingMode();
|
||||
}
|
||||
} else
|
||||
if (config.bluetooth.enabled) {
|
||||
if (!programmingMode) {
|
||||
// in programmingMode we don't send any packets to the client except this one notify
|
||||
programmingMode = true;
|
||||
success = notifyProgrammingMode();
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
success = sendPacket();
|
||||
}
|
||||
success |= receivePacket();
|
||||
return success ? 10 : 50;
|
||||
{
|
||||
success = sendPacket();
|
||||
}
|
||||
success |= receivePacket();
|
||||
return success ? 10 : 50;
|
||||
}
|
||||
|
||||
bool PacketAPI::receivePacket(void)
|
||||
{
|
||||
bool data_received = false;
|
||||
while (server->hasData()) {
|
||||
isConnected = true;
|
||||
data_received = true;
|
||||
bool PacketAPI::receivePacket(void) {
|
||||
bool data_received = false;
|
||||
while (server->hasData()) {
|
||||
isConnected = true;
|
||||
data_received = true;
|
||||
|
||||
powerFSM.trigger(EVENT_CONTACT_FROM_PHONE);
|
||||
lastContactMsec = millis();
|
||||
powerFSM.trigger(EVENT_CONTACT_FROM_PHONE);
|
||||
lastContactMsec = millis();
|
||||
|
||||
meshtastic_ToRadio *mr;
|
||||
auto p = server->receivePacket()->move();
|
||||
int id = p->getPacketId();
|
||||
LOG_DEBUG("Received packet id=%u", id);
|
||||
mr = (meshtastic_ToRadio *)&static_cast<DataPacket<meshtastic_ToRadio> *>(p.get())->getData();
|
||||
meshtastic_ToRadio *mr;
|
||||
auto p = server->receivePacket()->move();
|
||||
int id = p->getPacketId();
|
||||
LOG_DEBUG("Received packet id=%u", id);
|
||||
mr = (meshtastic_ToRadio *)&static_cast<DataPacket<meshtastic_ToRadio> *>(p.get())->getData();
|
||||
|
||||
switch (mr->which_payload_variant) {
|
||||
case meshtastic_ToRadio_packet_tag: {
|
||||
meshtastic_MeshPacket *mp = &mr->packet;
|
||||
mp->transport_mechanism = meshtastic_MeshPacket_TransportMechanism_TRANSPORT_API;
|
||||
printPacket("PACKET FROM QUEUE", mp);
|
||||
service->handleToRadio(*mp);
|
||||
break;
|
||||
}
|
||||
case meshtastic_ToRadio_want_config_id_tag: {
|
||||
uint32_t config_nonce = mr->want_config_id;
|
||||
LOG_INFO("Screen wants config, nonce=%u", config_nonce);
|
||||
handleStartConfig();
|
||||
break;
|
||||
}
|
||||
case meshtastic_ToRadio_heartbeat_tag:
|
||||
if (mr->heartbeat.nonce == 1) {
|
||||
if (nodeInfoModule) {
|
||||
LOG_INFO("Broadcasting nodeinfo ping");
|
||||
nodeInfoModule->sendOurNodeInfo(NODENUM_BROADCAST, true, 0, true);
|
||||
}
|
||||
} else {
|
||||
LOG_DEBUG("Got client heartbeat");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("Error: unhandled meshtastic_ToRadio variant: %d", mr->which_payload_variant);
|
||||
break;
|
||||
}
|
||||
switch (mr->which_payload_variant) {
|
||||
case meshtastic_ToRadio_packet_tag: {
|
||||
meshtastic_MeshPacket *mp = &mr->packet;
|
||||
mp->transport_mechanism = meshtastic_MeshPacket_TransportMechanism_TRANSPORT_API;
|
||||
printPacket("PACKET FROM QUEUE", mp);
|
||||
service->handleToRadio(*mp);
|
||||
break;
|
||||
}
|
||||
return data_received;
|
||||
case meshtastic_ToRadio_want_config_id_tag: {
|
||||
uint32_t config_nonce = mr->want_config_id;
|
||||
LOG_INFO("Screen wants config, nonce=%u", config_nonce);
|
||||
handleStartConfig();
|
||||
break;
|
||||
}
|
||||
case meshtastic_ToRadio_heartbeat_tag:
|
||||
if (mr->heartbeat.nonce == 1) {
|
||||
if (nodeInfoModule) {
|
||||
LOG_INFO("Broadcasting nodeinfo ping");
|
||||
nodeInfoModule->sendOurNodeInfo(NODENUM_BROADCAST, true, 0, true);
|
||||
}
|
||||
} else {
|
||||
LOG_DEBUG("Got client heartbeat");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("Error: unhandled meshtastic_ToRadio variant: %d", mr->which_payload_variant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data_received;
|
||||
}
|
||||
|
||||
bool PacketAPI::sendPacket(void)
|
||||
{
|
||||
if (server->available()) {
|
||||
// fill dummy buffer; we don't use it, we directly send the fromRadio structure
|
||||
uint32_t len = getFromRadio(txBuf);
|
||||
if (len != 0) {
|
||||
static uint32_t id = 0;
|
||||
fromRadioScratch.id = ++id;
|
||||
bool result = server->sendPacket(DataPacket<meshtastic_FromRadio>(id, fromRadioScratch));
|
||||
if (!result) {
|
||||
LOG_ERROR("send queue full");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
bool PacketAPI::sendPacket(void) {
|
||||
if (server->available()) {
|
||||
// fill dummy buffer; we don't use it, we directly send the fromRadio structure
|
||||
uint32_t len = getFromRadio(txBuf);
|
||||
if (len != 0) {
|
||||
static uint32_t id = 0;
|
||||
fromRadioScratch.id = ++id;
|
||||
bool result = server->sendPacket(DataPacket<meshtastic_FromRadio>(id, fromRadioScratch));
|
||||
if (!result) {
|
||||
LOG_ERROR("send queue full");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PacketAPI::notifyProgrammingMode(void)
|
||||
{
|
||||
// tell the client we are in programming mode by sending only the bluetooth config state
|
||||
LOG_INFO("force client into programmingMode");
|
||||
memset(&fromRadioScratch, 0, sizeof(fromRadioScratch));
|
||||
fromRadioScratch.id = nodeDB->getNodeNum();
|
||||
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_config_tag;
|
||||
fromRadioScratch.config.which_payload_variant = meshtastic_Config_bluetooth_tag;
|
||||
fromRadioScratch.config.payload_variant.bluetooth = config.bluetooth;
|
||||
return server->sendPacket(DataPacket<meshtastic_FromRadio>(0, fromRadioScratch));
|
||||
bool PacketAPI::notifyProgrammingMode(void) {
|
||||
// tell the client we are in programming mode by sending only the bluetooth config state
|
||||
LOG_INFO("force client into programmingMode");
|
||||
memset(&fromRadioScratch, 0, sizeof(fromRadioScratch));
|
||||
fromRadioScratch.id = nodeDB->getNodeNum();
|
||||
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_config_tag;
|
||||
fromRadioScratch.config.which_payload_variant = meshtastic_Config_bluetooth_tag;
|
||||
fromRadioScratch.config.payload_variant.bluetooth = config.bluetooth;
|
||||
return server->sendPacket(DataPacket<meshtastic_FromRadio>(0, fromRadioScratch));
|
||||
}
|
||||
|
||||
/**
|
||||
* return true if we got (once!) contact from our client and the server send queue is not full
|
||||
*/
|
||||
bool PacketAPI::checkIsConnected()
|
||||
{
|
||||
isConnected |= server->hasData();
|
||||
return isConnected && server->available();
|
||||
bool PacketAPI::checkIsConnected() {
|
||||
isConnected |= server->hasData();
|
||||
return isConnected && server->available();
|
||||
}
|
||||
|
||||
#endif
|
||||
+19
-20
@@ -9,30 +9,29 @@
|
||||
* between two tasks running on CPU0 and CPU1, respectively.
|
||||
*
|
||||
*/
|
||||
class PacketAPI : public PhoneAPI, public concurrency::OSThread
|
||||
{
|
||||
public:
|
||||
static PacketAPI *create(PacketServer *_server);
|
||||
virtual ~PacketAPI(){};
|
||||
virtual int32_t runOnce();
|
||||
class PacketAPI : public PhoneAPI, public concurrency::OSThread {
|
||||
public:
|
||||
static PacketAPI *create(PacketServer *_server);
|
||||
virtual ~PacketAPI(){};
|
||||
virtual int32_t runOnce();
|
||||
|
||||
protected:
|
||||
PacketAPI(PacketServer *_server);
|
||||
// Check the current underlying physical queue to see if the client is fetching packets
|
||||
bool checkIsConnected() override;
|
||||
protected:
|
||||
PacketAPI(PacketServer *_server);
|
||||
// Check the current underlying physical queue to see if the client is fetching packets
|
||||
bool checkIsConnected() override;
|
||||
|
||||
void onNowHasData(uint32_t fromRadioNum) override {}
|
||||
void onConnectionChanged(bool connected) override {}
|
||||
void onNowHasData(uint32_t fromRadioNum) override {}
|
||||
void onConnectionChanged(bool connected) override {}
|
||||
|
||||
private:
|
||||
bool receivePacket(void);
|
||||
bool sendPacket(void);
|
||||
bool notifyProgrammingMode(void);
|
||||
private:
|
||||
bool receivePacket(void);
|
||||
bool sendPacket(void);
|
||||
bool notifyProgrammingMode(void);
|
||||
|
||||
bool isConnected;
|
||||
bool programmingMode;
|
||||
PacketServer *server;
|
||||
uint8_t txBuf[MAX_TO_FROM_RADIO_SIZE] = {0}; // dummy buf to obey PhoneAPI
|
||||
bool isConnected;
|
||||
bool programmingMode;
|
||||
PacketServer *server;
|
||||
uint8_t txBuf[MAX_TO_FROM_RADIO_SIZE] = {0}; // dummy buf to obey PhoneAPI
|
||||
};
|
||||
|
||||
extern PacketAPI *packetAPI;
|
||||
+39
-53
@@ -2,82 +2,68 @@
|
||||
#include "configuration.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
template <typename T>
|
||||
ServerAPI<T>::ServerAPI(T &_client) : StreamAPI(&client), concurrency::OSThread("ServerAPI"), client(_client)
|
||||
{
|
||||
LOG_INFO("Incoming API connection");
|
||||
template <typename T> ServerAPI<T>::ServerAPI(T &_client) : StreamAPI(&client), concurrency::OSThread("ServerAPI"), client(_client) {
|
||||
LOG_INFO("Incoming API connection");
|
||||
}
|
||||
|
||||
template <typename T> ServerAPI<T>::~ServerAPI()
|
||||
{
|
||||
client.stop();
|
||||
}
|
||||
template <typename T> ServerAPI<T>::~ServerAPI() { client.stop(); }
|
||||
|
||||
template <typename T> void ServerAPI<T>::close()
|
||||
{
|
||||
client.stop(); // drop tcp connection
|
||||
StreamAPI::close();
|
||||
template <typename T> void ServerAPI<T>::close() {
|
||||
client.stop(); // drop tcp connection
|
||||
StreamAPI::close();
|
||||
}
|
||||
|
||||
/// Check the current underlying physical link to see if the client is currently connected
|
||||
template <typename T> bool ServerAPI<T>::checkIsConnected()
|
||||
{
|
||||
return client.connected();
|
||||
}
|
||||
template <typename T> bool ServerAPI<T>::checkIsConnected() { return client.connected(); }
|
||||
|
||||
template <class T> int32_t ServerAPI<T>::runOnce()
|
||||
{
|
||||
if (client.connected()) {
|
||||
return StreamAPI::runOncePart();
|
||||
} else {
|
||||
LOG_INFO("Client dropped connection, suspend API service");
|
||||
enabled = false; // we no longer need to run
|
||||
return 0;
|
||||
}
|
||||
template <class T> int32_t ServerAPI<T>::runOnce() {
|
||||
if (client.connected()) {
|
||||
return StreamAPI::runOncePart();
|
||||
} else {
|
||||
LOG_INFO("Client dropped connection, suspend API service");
|
||||
enabled = false; // we no longer need to run
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class U> APIServerPort<T, U>::APIServerPort(int port) : U(port), concurrency::OSThread("ApiServer") {}
|
||||
|
||||
template <class T, class U> void APIServerPort<T, U>::init()
|
||||
{
|
||||
U::begin();
|
||||
}
|
||||
template <class T, class U> void APIServerPort<T, U>::init() { U::begin(); }
|
||||
|
||||
template <class T, class U> int32_t APIServerPort<T, U>::runOnce()
|
||||
{
|
||||
template <class T, class U> int32_t APIServerPort<T, U>::runOnce() {
|
||||
#ifdef ARCH_ESP32
|
||||
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
|
||||
auto client = U::accept();
|
||||
auto client = U::accept();
|
||||
#else
|
||||
auto client = U::available();
|
||||
auto client = U::available();
|
||||
#endif
|
||||
#elif defined(ARCH_RP2040)
|
||||
auto client = U::accept();
|
||||
auto client = U::accept();
|
||||
#else
|
||||
auto client = U::available();
|
||||
auto client = U::available();
|
||||
#endif
|
||||
if (client) {
|
||||
// Close any previous connection (see FIXME in header file)
|
||||
if (openAPI) {
|
||||
if (client) {
|
||||
// Close any previous connection (see FIXME in header file)
|
||||
if (openAPI) {
|
||||
#if RAK_4631
|
||||
// RAK13800 Ethernet requests periodically take more time
|
||||
// This backoff addresses most cases keeping max wait < 1s
|
||||
// Reconnections are delayed by full wait time
|
||||
if (waitTime < 400) {
|
||||
waitTime *= 2;
|
||||
LOG_INFO("Previous TCP connection still open, try again in %dms", waitTime);
|
||||
return waitTime;
|
||||
}
|
||||
// RAK13800 Ethernet requests periodically take more time
|
||||
// This backoff addresses most cases keeping max wait < 1s
|
||||
// Reconnections are delayed by full wait time
|
||||
if (waitTime < 400) {
|
||||
waitTime *= 2;
|
||||
LOG_INFO("Previous TCP connection still open, try again in %dms", waitTime);
|
||||
return waitTime;
|
||||
}
|
||||
#endif
|
||||
LOG_INFO("Force close previous TCP connection");
|
||||
delete openAPI;
|
||||
}
|
||||
|
||||
openAPI = new T(client);
|
||||
LOG_INFO("Force close previous TCP connection");
|
||||
delete openAPI;
|
||||
}
|
||||
|
||||
openAPI = new T(client);
|
||||
}
|
||||
|
||||
#if RAK_4631
|
||||
waitTime = 100;
|
||||
waitTime = 100;
|
||||
#endif
|
||||
return 100; // only check occasionally for incoming connections
|
||||
return 100; // only check occasionally for incoming connections
|
||||
}
|
||||
+29
-31
@@ -8,51 +8,49 @@
|
||||
* Provides both debug printing and, if the client starts sending protobufs to us, switches to send/receive protobufs
|
||||
* (and starts dropping debug printing - FIXME, eventually those prints should be encapsulated in protobufs).
|
||||
*/
|
||||
template <class T> class ServerAPI : public StreamAPI, private concurrency::OSThread
|
||||
{
|
||||
private:
|
||||
T client;
|
||||
template <class T> class ServerAPI : public StreamAPI, private concurrency::OSThread {
|
||||
private:
|
||||
T client;
|
||||
|
||||
public:
|
||||
explicit ServerAPI(T &_client);
|
||||
public:
|
||||
explicit ServerAPI(T &_client);
|
||||
|
||||
virtual ~ServerAPI();
|
||||
virtual ~ServerAPI();
|
||||
|
||||
/// override close to also shutdown the TCP link
|
||||
virtual void close();
|
||||
/// override close to also shutdown the TCP link
|
||||
virtual void close();
|
||||
|
||||
protected:
|
||||
/// We override this method to prevent publishing EVENT_SERIAL_CONNECTED/DISCONNECTED for wifi links (we want the board to
|
||||
/// stay in the POWERED state to prevent disabling wifi)
|
||||
virtual void onConnectionChanged(bool connected) override {}
|
||||
protected:
|
||||
/// We override this method to prevent publishing EVENT_SERIAL_CONNECTED/DISCONNECTED for wifi links (we want the
|
||||
/// board to stay in the POWERED state to prevent disabling wifi)
|
||||
virtual void onConnectionChanged(bool connected) override {}
|
||||
|
||||
virtual int32_t runOnce() override; // Check for dropped client connections
|
||||
virtual int32_t runOnce() override; // Check for dropped client connections
|
||||
|
||||
/// Check the current underlying physical link to see if the client is currently connected
|
||||
virtual bool checkIsConnected() override;
|
||||
/// Check the current underlying physical link to see if the client is currently connected
|
||||
virtual bool checkIsConnected() override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Listens for incoming connections and does accepts and creates instances of ServerAPI as needed
|
||||
*/
|
||||
template <class T, class U> class APIServerPort : public U, private concurrency::OSThread
|
||||
{
|
||||
/** 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.
|
||||
*/
|
||||
T *openAPI = NULL;
|
||||
template <class T, class U> class APIServerPort : public U, private concurrency::OSThread {
|
||||
/** 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.
|
||||
*/
|
||||
T *openAPI = NULL;
|
||||
#if defined(RAK_4631) || defined(RAK11310)
|
||||
// Track wait time for RAK13800 Ethernet requests
|
||||
int32_t waitTime = 100;
|
||||
// Track wait time for RAK13800 Ethernet requests
|
||||
int32_t waitTime = 100;
|
||||
#endif
|
||||
|
||||
public:
|
||||
explicit APIServerPort(int port);
|
||||
public:
|
||||
explicit APIServerPort(int port);
|
||||
|
||||
void init();
|
||||
void init();
|
||||
|
||||
protected:
|
||||
int32_t runOnce() override;
|
||||
protected:
|
||||
int32_t runOnce() override;
|
||||
};
|
||||
|
||||
@@ -6,27 +6,24 @@
|
||||
|
||||
static WiFiServerPort *apiPort;
|
||||
|
||||
void initApiServer(int port)
|
||||
{
|
||||
// Start API server on port 4403
|
||||
if (!apiPort) {
|
||||
apiPort = new WiFiServerPort(port);
|
||||
LOG_INFO("API server listen on TCP port %d", port);
|
||||
apiPort->init();
|
||||
}
|
||||
void initApiServer(int port) {
|
||||
// Start API server on port 4403
|
||||
if (!apiPort) {
|
||||
apiPort = new WiFiServerPort(port);
|
||||
LOG_INFO("API server listen on TCP port %d", port);
|
||||
apiPort->init();
|
||||
}
|
||||
}
|
||||
void deInitApiServer()
|
||||
{
|
||||
if (apiPort) {
|
||||
delete apiPort;
|
||||
apiPort = nullptr;
|
||||
}
|
||||
void deInitApiServer() {
|
||||
if (apiPort) {
|
||||
delete apiPort;
|
||||
apiPort = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
WiFiServerAPI::WiFiServerAPI(WiFiClient &_client) : ServerAPI(_client)
|
||||
{
|
||||
api_type = TYPE_WIFI;
|
||||
LOG_INFO("Incoming wifi connection");
|
||||
WiFiServerAPI::WiFiServerAPI(WiFiClient &_client) : ServerAPI(_client) {
|
||||
api_type = TYPE_WIFI;
|
||||
LOG_INFO("Incoming wifi connection");
|
||||
}
|
||||
|
||||
WiFiServerPort::WiFiServerPort(int port) : APIServerPort(port) {}
|
||||
|
||||
@@ -12,19 +12,17 @@
|
||||
* Provides both debug printing and, if the client starts sending protobufs to us, switches to send/receive protobufs
|
||||
* (and starts dropping debug printing - FIXME, eventually those prints should be encapsulated in protobufs).
|
||||
*/
|
||||
class WiFiServerAPI : public ServerAPI<WiFiClient>
|
||||
{
|
||||
public:
|
||||
explicit WiFiServerAPI(WiFiClient &_client);
|
||||
class WiFiServerAPI : public ServerAPI<WiFiClient> {
|
||||
public:
|
||||
explicit WiFiServerAPI(WiFiClient &_client);
|
||||
};
|
||||
|
||||
/**
|
||||
* Listens for incoming connections and does accepts and creates instances of WiFiServerAPI as needed
|
||||
*/
|
||||
class WiFiServerPort : public APIServerPort<WiFiServerAPI, WiFiServer>
|
||||
{
|
||||
public:
|
||||
explicit WiFiServerPort(int port);
|
||||
class WiFiServerPort : public APIServerPort<WiFiServerAPI, WiFiServer> {
|
||||
public:
|
||||
explicit WiFiServerPort(int port);
|
||||
};
|
||||
|
||||
void initApiServer(int port = SERVER_API_DEFAULT_PORT);
|
||||
|
||||
@@ -7,20 +7,18 @@
|
||||
|
||||
static ethServerPort *apiPort;
|
||||
|
||||
void initApiServer(int port)
|
||||
{
|
||||
// Start API server on port 4403
|
||||
if (!apiPort) {
|
||||
apiPort = new ethServerPort(port);
|
||||
LOG_INFO("API server listening on TCP port %d", port);
|
||||
apiPort->init();
|
||||
}
|
||||
void initApiServer(int port) {
|
||||
// Start API server on port 4403
|
||||
if (!apiPort) {
|
||||
apiPort = new ethServerPort(port);
|
||||
LOG_INFO("API server listening on TCP port %d", port);
|
||||
apiPort->init();
|
||||
}
|
||||
}
|
||||
|
||||
ethServerAPI::ethServerAPI(EthernetClient &_client) : ServerAPI(_client)
|
||||
{
|
||||
LOG_INFO("Incoming ethernet connection");
|
||||
api_type = TYPE_ETH;
|
||||
ethServerAPI::ethServerAPI(EthernetClient &_client) : ServerAPI(_client) {
|
||||
LOG_INFO("Incoming ethernet connection");
|
||||
api_type = TYPE_ETH;
|
||||
}
|
||||
|
||||
ethServerPort::ethServerPort(int port) : APIServerPort(port) {}
|
||||
|
||||
@@ -8,19 +8,17 @@
|
||||
* Provides both debug printing and, if the client starts sending protobufs to us, switches to send/receive protobufs
|
||||
* (and starts dropping debug printing - FIXME, eventually those prints should be encapsulated in protobufs).
|
||||
*/
|
||||
class ethServerAPI : public ServerAPI<EthernetClient>
|
||||
{
|
||||
public:
|
||||
explicit ethServerAPI(EthernetClient &_client);
|
||||
class ethServerAPI : public ServerAPI<EthernetClient> {
|
||||
public:
|
||||
explicit ethServerAPI(EthernetClient &_client);
|
||||
};
|
||||
|
||||
/**
|
||||
* Listens for incoming connections and does accepts and creates instances of EthernetServerAPI as needed
|
||||
*/
|
||||
class ethServerPort : public APIServerPort<ethServerAPI, EthernetServer>
|
||||
{
|
||||
public:
|
||||
explicit ethServerPort(int port);
|
||||
class ethServerPort : public APIServerPort<ethServerAPI, EthernetServer> {
|
||||
public:
|
||||
explicit ethServerPort(int port);
|
||||
};
|
||||
|
||||
void initApiServer(int port = SERVER_API_DEFAULT_PORT);
|
||||
|
||||
Reference in New Issue
Block a user