mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-16 13:25:03 +01:00
get OTA enabling working
This commit is contained in:
@@ -18,29 +18,33 @@ class OtaTcpPlugin : public Plugin {
|
||||
private:
|
||||
OtaConfig config;
|
||||
Task otaTask;
|
||||
MeshNet* network;
|
||||
MeshNet* net;
|
||||
public:
|
||||
OtaTcpPlugin(OtaConfig cfg){
|
||||
config = cfg;
|
||||
|
||||
}
|
||||
void connectUpdateNetwork(Network* network) {
|
||||
// if(!network->isConnected()){
|
||||
// static_cast<MeshNet*>(network)->config.stationMode = 1;
|
||||
// }
|
||||
network->connectStation();
|
||||
void connectUpdateNetwork() {
|
||||
Serial.println("OTA connect to update-network");
|
||||
net->connectStation(1);
|
||||
}
|
||||
void enable() {
|
||||
Serial.println("OTA enable");
|
||||
ArduinoOTA.begin();
|
||||
otaTask.enable();
|
||||
}
|
||||
void onMessage(MeshMessage msg) {
|
||||
//enable();
|
||||
Serial.println("OTA msg received");
|
||||
if(msg.type == MeshMessage::OTA){
|
||||
Serial.println("OTA msg received");
|
||||
connectUpdateNetwork();
|
||||
enable();
|
||||
//net->mesh.sendBroadcast("my ip:" + WiFi.localIP().toString(), true);
|
||||
}
|
||||
}
|
||||
void setup(Scheduler* userScheduler, Network* network){
|
||||
// connect done in network class
|
||||
// connect done in network class?
|
||||
//connectUpdateNetwork(network);
|
||||
net = static_cast<MeshNet*>(network);
|
||||
// setup task
|
||||
scheduler = userScheduler;
|
||||
otaTask.set(TASK_MILLISECOND * 100, TASK_FOREVER, [](){
|
||||
@@ -72,7 +76,6 @@ class OtaTcpPlugin : public Plugin {
|
||||
else if (error == OTA_RECEIVE_ERROR) Serial.println("OTA: Receive Failed");
|
||||
else if (error == OTA_END_ERROR) Serial.println("OTA: End Failed");
|
||||
});
|
||||
enable();
|
||||
}
|
||||
void disable(){
|
||||
otaTask.disable();
|
||||
|
||||
Reference in New Issue
Block a user