fix: Spit working again also with linux
This commit is contained in:
Vendored
+1
-1
@@ -37,7 +37,7 @@
|
|||||||
"clangd.arguments": [
|
"clangd.arguments": [
|
||||||
"--background-index",
|
"--background-index",
|
||||||
"--query-driver=/home/gustice/.espressif/tools/riscv32-esp-elf/esp-14.2.0_20241119/riscv32-esp-elf/bin/riscv32-esp-elf-gcc",
|
"--query-driver=/home/gustice/.espressif/tools/riscv32-esp-elf/esp-14.2.0_20241119/riscv32-esp-elf/bin/riscv32-esp-elf-gcc",
|
||||||
"--compile-commands-dir=/home/gustice/jobs/projects/Proj_Zwickau_waitingRoom/FW_X_WatchController/build_uTest"
|
"--compile-commands-dir=/home/gustice/jobs/projects/Proj_Zwickau_waitingRoom/FW_X_WatchController/build"
|
||||||
],
|
],
|
||||||
"cmake.debugConfig": {
|
"cmake.debugConfig": {
|
||||||
"setupCommands": [
|
"setupCommands": [
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
idf_component_register(
|
idf_component_register(
|
||||||
SRC_DIRS "src" "src/esp"
|
SRC_DIRS "src" "src/esp"
|
||||||
INCLUDE_DIRS "include"
|
INCLUDE_DIRS "include"
|
||||||
REQUIRES esp_system esp_netif freeRtosApi
|
REQUIRES esp_system esp_netif freeRtosApi sockets
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include "syslog.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -86,6 +87,7 @@ class SClient : ISadClient {
|
|||||||
Callbacks mCallbacks;
|
Callbacks mCallbacks;
|
||||||
|
|
||||||
fos::TaskT<SClient &> *mThreadReceive{};
|
fos::TaskT<SClient &> *mThreadReceive{};
|
||||||
|
fos::TaskT<SClient &> *mThreadProcess{};
|
||||||
bool mStopReceiveMessages{};
|
bool mStopReceiveMessages{};
|
||||||
|
|
||||||
Connection mConnectionStatus{Connection::None};
|
Connection mConnectionStatus{Connection::None};
|
||||||
@@ -151,7 +153,8 @@ class SClient : ISadClient {
|
|||||||
private:
|
private:
|
||||||
bool startReceiveSPITMessages();
|
bool startReceiveSPITMessages();
|
||||||
void stopReceiveSPITMessages();
|
void stopReceiveSPITMessages();
|
||||||
static void receiveSPITMessage(SClient &rM);
|
static void receiveSpitMessage(SClient &rM);
|
||||||
|
static void processSpitMessage(SClient &rM);
|
||||||
// Reconnect to the server when connection is lost see eventConnectionStatus and eventServerDetected
|
// Reconnect to the server when connection is lost see eventConnectionStatus and eventServerDetected
|
||||||
bool _doReconnect{}; // true = on eventServerDetected connect to the server identified by mServerID
|
bool _doReconnect{}; // true = on eventServerDetected connect to the server identified by mServerID
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -2,8 +2,12 @@
|
|||||||
#include "spit_client.hpp"
|
#include "spit_client.hpp"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
#include "Queue.hpp"
|
||||||
|
|
||||||
namespace spit {
|
namespace spit {
|
||||||
static const char *TAG = "SPIT";
|
static const char *TAG = "SPIT";
|
||||||
|
static fos::Queue<vector<char>> incommingSpit(64);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new SPIT_client instance, should be done once by the user app.
|
* Create a new SPIT_client instance, should be done once by the user app.
|
||||||
@@ -225,7 +229,8 @@ bool SClient::startReceiveSPITMessages() {
|
|||||||
if (!mSocket.getIsBound())
|
if (!mSocket.getIsBound())
|
||||||
return false;
|
return false;
|
||||||
mStopReceiveMessages = false;
|
mStopReceiveMessages = false;
|
||||||
mThreadReceive = new fos::TaskT<SClient &>(receiveSPITMessage, *this, "receiveTask", fos::Task::DefaultStackSize * 4);
|
mThreadReceive = new fos::TaskT<SClient &>(receiveSpitMessage, *this, "receiveTask", fos::Task::DefaultStackSize, fos::Task::MAX_PRIORITY-3);
|
||||||
|
mThreadProcess = new fos::TaskT<SClient &>(processSpitMessage, *this, "processTask", fos::Task::DefaultStackSize);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +238,7 @@ void SClient::stopReceiveSPITMessages() {
|
|||||||
mStopReceiveMessages = true;
|
mStopReceiveMessages = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SClient::receiveSPITMessage(SClient &rM) {
|
void SClient::receiveSpitMessage(SClient &rM) {
|
||||||
char buffer[MAXSPITMESSAGEBYTECOUNT + 1];
|
char buffer[MAXSPITMESSAGEBYTECOUNT + 1];
|
||||||
int rdLen;
|
int rdLen;
|
||||||
while (rM.mStopReceiveMessages == false) {
|
while (rM.mStopReceiveMessages == false) {
|
||||||
@@ -244,13 +249,21 @@ void SClient::receiveSPITMessage(SClient &rM) {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto vec = vector<char>(buffer, buffer + rdLen);
|
auto vec = make_unique<vector<char>>(buffer, buffer + rdLen);
|
||||||
auto spitMsg = make_unique<Message>(vec);
|
|
||||||
rM.parseMessage(move(spitMsg));
|
incommingSpit.enqueue(std::move(vec));
|
||||||
// rM.checkParseMessage(move(spitMsg));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SClient::processSpitMessage(SClient &rM) {
|
||||||
|
while (true) {
|
||||||
|
auto data = *incommingSpit.dequeue();
|
||||||
|
auto spitMsg = make_unique<Message>(data);
|
||||||
|
rM.parseMessage(move(spitMsg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SClient::resetMessageNumberReceived() {
|
void SClient::resetMessageNumberReceived() {
|
||||||
mMessageNumberReceived = -1;
|
mMessageNumberReceived = -1;
|
||||||
mOvertakingMessages.clear();
|
mOvertakingMessages.clear();
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+12
-12
@@ -666,10 +666,10 @@ void onProjectUpdate(SClient::ProjUpdate state, string projectId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool onCheckSpitTypeVeto(bool knownType, bool createdByClient) {
|
bool onCheckSpitTypeVeto(bool knownType, bool createdByClient) {
|
||||||
|
return true; // Bypass veto
|
||||||
if (!knownType || !createdByClient) { // Don't allow foreign SPITTypes
|
if (!knownType || !createdByClient) { // Don't allow foreign SPITTypes
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -708,7 +708,7 @@ void onSpitType(SClient::ObjectEvent event, bool isRemote, const SType &sType) {
|
|||||||
// // onSpitObjectRemote(SClient::ObjectEvent::Changed, p_SPITType, *ptrSPITObject);
|
// // onSpitObjectRemote(SClient::ObjectEvent::Changed, p_SPITType, *ptrSPITObject);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
ESP_LOGI(TAG, "SPIT-REMOTE-Type CHANGED ID: %s GroupName: %s Name: %s confirmed: %d", sType.getID().data(), sType.GroupName.get().data(), sType.Name.get().data(), sType.getConfirmed());
|
// ESP_LOGI(TAG, "SPIT-REMOTE-Type CHANGED ID: %s GroupName: %s Name: %s confirmed: %d", sType.getID().data(), sType.GroupName.get().data(), sType.Name.get().data(), sType.getConfirmed());
|
||||||
} else if (event == SClient::ObjectEvent::Deleted) {
|
} else if (event == SClient::ObjectEvent::Deleted) {
|
||||||
ESP_LOGD(TAG, "SPIT-REMOTE-Type Removed ID: %s GroupName: %s Name: %s\n", sType.getID().data(), sType.GroupName.get().data(), sType.Name.get().data());
|
ESP_LOGD(TAG, "SPIT-REMOTE-Type Removed ID: %s GroupName: %s Name: %s\n", sType.getID().data(), sType.GroupName.get().data(), sType.Name.get().data());
|
||||||
}
|
}
|
||||||
@@ -716,11 +716,11 @@ void onSpitType(SClient::ObjectEvent event, bool isRemote, const SType &sType) {
|
|||||||
if (event == SClient::ObjectEvent::Created) {
|
if (event == SClient::ObjectEvent::Created) {
|
||||||
// Whenever you provide an action for this SPITType take this over in your code.
|
// Whenever you provide an action for this SPITType take this over in your code.
|
||||||
// call _SpitClient.setActionSPITType(sType.getID(), true);
|
// call _SpitClient.setActionSPITType(sType.getID(), true);
|
||||||
ESP_LOGI(TAG, "NEW SPIT-Type ID: %s GroupName: %s Name: %s confirmed: %d", sType.getID().data(), sType.GroupName.get().data(), sType.Name.get().data(), sType.getConfirmed());
|
// ESP_LOGI(TAG, "NEW SPIT-Type ID: %s GroupName: %s Name: %s confirmed: %d", sType.getID().data(), sType.GroupName.get().data(), sType.Name.get().data(), sType.getConfirmed());
|
||||||
} else if (event == SClient::ObjectEvent::Changed) {
|
} else if (event == SClient::ObjectEvent::Changed) {
|
||||||
ESP_LOGI(TAG, "SPIT-Type CHANGED ID: %s GroupName: %s Name: %s confirmed: %d", sType.getID().data(), sType.GroupName.get().data(), sType.Name.get().data(), sType.getConfirmed());
|
// ESP_LOGI(TAG, "SPIT-Type CHANGED ID: %s GroupName: %s Name: %s confirmed: %d", sType.getID().data(), sType.GroupName.get().data(), sType.Name.get().data(), sType.getConfirmed());
|
||||||
} else if (event == SClient::ObjectEvent::Deleted) {
|
} else if (event == SClient::ObjectEvent::Deleted) {
|
||||||
ESP_LOGI(TAG, "SPIT-Type Removed ID: %s GroupName: %s Name: %s\n", sType.getID().data(), sType.GroupName.get().data(), sType.Name.get().data());
|
// ESP_LOGI(TAG, "SPIT-Type Removed ID: %s GroupName: %s Name: %s\n", sType.getID().data(), sType.GroupName.get().data(), sType.Name.get().data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -734,11 +734,11 @@ void onSpitType(SClient::ObjectEvent event, bool isRemote, const SType &sType) {
|
|||||||
void onSpitObject(SClient::ObjectEvent event, bool isRemote, const SType &sType, const SObject &sObject) {
|
void onSpitObject(SClient::ObjectEvent event, bool isRemote, const SType &sType, const SObject &sObject) {
|
||||||
if (isRemote) {
|
if (isRemote) {
|
||||||
if (event == SClient::ObjectEvent::Created) {
|
if (event == SClient::ObjectEvent::Created) {
|
||||||
ESP_LOGI(TAG, "NEW SPIT-REMOTE-Object ID: %s Name: %s -> SPITType: %s", sObject.getID().data(), sObject.Name.get().data(), sType.Name.get().data());
|
// ESP_LOGI(TAG, "NEW SPIT-REMOTE-Object ID: %s Name: %s -> SPITType: %s", sObject.getID().data(), sObject.Name.get().data(), sType.Name.get().data());
|
||||||
// This is a remote SPITObject which can be used to remote control the server.
|
// This is a remote SPITObject which can be used to remote control the server.
|
||||||
// If you want you can list this for later use
|
// If you want you can list this for later use
|
||||||
} else if (event == SClient::ObjectEvent::Changed) {
|
} else if (event == SClient::ObjectEvent::Changed) {
|
||||||
ESP_LOGI(TAG, "SPIT-REMOTE-Object CHANGED ID: %s Name: %s -> SPITType: %s", sObject.getID().data(), sObject.Name.get().data(), sType.Name.get().data());
|
// ESP_LOGI(TAG, "SPIT-REMOTE-Object CHANGED ID: %s Name: %s -> SPITType: %s", sObject.getID().data(), sObject.Name.get().data(), sType.Name.get().data());
|
||||||
} else if (event == SClient::ObjectEvent::Deleted) {
|
} else if (event == SClient::ObjectEvent::Deleted) {
|
||||||
ESP_LOGD(TAG, "SPIT-REMOTE-Object Removed ID: %s Name: %s\n", sObject.getID().data(), sObject.Name.get().data());
|
ESP_LOGD(TAG, "SPIT-REMOTE-Object Removed ID: %s Name: %s\n", sObject.getID().data(), sObject.Name.get().data());
|
||||||
// This is a remote SPITObject
|
// This is a remote SPITObject
|
||||||
@@ -746,7 +746,7 @@ void onSpitObject(SClient::ObjectEvent event, bool isRemote, const SType &sType,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (event == SClient::ObjectEvent::Created) {
|
if (event == SClient::ObjectEvent::Created) {
|
||||||
ESP_LOGI(TAG, "NEW SPIT-Object ID: %s Name: %s -> SPITType: %s", sObject.getID().data(), sObject.Name.get().data(), sType.Name.get().data());
|
// ESP_LOGI(TAG, "NEW SPIT-Object ID: %s Name: %s -> SPITType: %s", sObject.getID().data(), sObject.Name.get().data(), sType.Name.get().data());
|
||||||
// check your actions
|
// check your actions
|
||||||
// Whenever you provide an action for this SPITObject take this over in your code.
|
// Whenever you provide an action for this SPITObject take this over in your code.
|
||||||
// call _SpitClient.setActionSPITObject(sObject.getID(), true);
|
// call _SpitClient.setActionSPITObject(sObject.getID(), true);
|
||||||
@@ -757,7 +757,7 @@ void onSpitObject(SClient::ObjectEvent event, bool isRemote, const SType &sType,
|
|||||||
// SPITObjects with other SPITTypes asscciated will trigger no actions
|
// SPITObjects with other SPITTypes asscciated will trigger no actions
|
||||||
|
|
||||||
} else if (event == SClient::ObjectEvent::Changed) {
|
} else if (event == SClient::ObjectEvent::Changed) {
|
||||||
ESP_LOGI(TAG, "SPIT-Object CHANGED ID: %s Name: %s -> SPITType: %s", sObject.getID().data(), sObject.Name.get().data(), sType.Name.get().data());
|
// ESP_LOGI(TAG, "SPIT-Object CHANGED ID: %s Name: %s -> SPITType: %s", sObject.getID().data(), sObject.Name.get().data(), sType.Name.get().data());
|
||||||
} else if (event == SClient::ObjectEvent::Deleted) {
|
} else if (event == SClient::ObjectEvent::Deleted) {
|
||||||
ESP_LOGD(TAG, "SPIT-Object Removed ID: %s Name: %s\n", sObject.getID().data(), sObject.Name.get().data());
|
ESP_LOGD(TAG, "SPIT-Object Removed ID: %s Name: %s\n", sObject.getID().data(), sObject.Name.get().data());
|
||||||
// Check your actions
|
// Check your actions
|
||||||
@@ -805,7 +805,7 @@ void onPlaySpitType(string p_PlayerID, string spitTypeId, bool p_PlayerIsRunning
|
|||||||
}
|
}
|
||||||
if (p_Started == true) {
|
if (p_Started == true) {
|
||||||
auto command = ProvidedSpitActions[spitTypeId];
|
auto command = ProvidedSpitActions[spitTypeId];
|
||||||
ESP_LOGI(TAG, "Player: %s is running: %s Object", p_PlayerID.data(), spitTypeId.c_str());
|
// ESP_LOGI(TAG, "Player: %s is running: %s Object", p_PlayerID.data(), spitTypeId.c_str());
|
||||||
commandQueue.enqueue(std::make_unique<MoveCommand>(command));
|
commandQueue.enqueue(std::make_unique<MoveCommand>(command));
|
||||||
Syslog::logv(Syslog::Severity::Informational, "Got SPIT command for move ot : r%d", command.pos);
|
Syslog::logv(Syslog::Severity::Informational, "Got SPIT command for move ot : r%d", command.pos);
|
||||||
}
|
}
|
||||||
@@ -923,8 +923,8 @@ void app_main(void) {
|
|||||||
static int ipVersion = AF_INET;
|
static int ipVersion = AF_INET;
|
||||||
static fos::TaskT<int> telnetSocket(telnetSocketTask, ipVersion, "tcpServer", 4096);
|
static fos::TaskT<int> telnetSocket(telnetSocketTask, ipVersion, "tcpServer", 4096);
|
||||||
static fos::TaskT<int> dmxNode(dmxSocketTask, ipVersion, "dmxNode", 4096);
|
static fos::TaskT<int> dmxNode(dmxSocketTask, ipVersion, "dmxNode", 4096);
|
||||||
// static fos::Task spit(SpitClientApp, "SpitClient");
|
static fos::Task spit(SpitClientApp, "SpitClient");
|
||||||
static fos::Task mqtt(MqttThread, "MqttEndpoint");
|
// static fos::Task mqtt(MqttThread, "MqttEndpoint");
|
||||||
// static Task otaUpdate(SystemFunctions::OtaTaskEntry, "otaTask", 8192);
|
// static Task otaUpdate(SystemFunctions::OtaTaskEntry, "otaTask", 8192);
|
||||||
|
|
||||||
auto &store = NvsApi::getInstance();
|
auto &store = NvsApi::getInstance();
|
||||||
|
|||||||
Reference in New Issue
Block a user