8000 fix OTA example build and build tests for esp8266 examples · thebigG/arduinoWebSockets@82c357c · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 82c357c

Browse files
committed
fix OTA example build and build tests for esp8266 examples
1 parent d9a5c62 commit 82c357c

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ jobs:
3636
echo -en "::set-output name=matrix::"
3737
echo -en "["
3838
39-
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp8266 esp8266 1.8.19 esp8266com:esp8266:generic:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,ResetMethod=nodemcu,CrystalFreq=26,FlashFreq=80,FlashMode=qio,eesz=4M2M,led=2,sdk=nonosdk_190703,ip=lm2f,dbg=Serial1,lvl=SSL,wipe=none,baud=115200
39+
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp8266_pico esp8266 1.8.19 esp8266com:esp8266:generic:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,ResetMethod=nodemcu,CrystalFreq=26,FlashFreq=80,FlashMode=qio,eesz=4M2M,led=2,sdk=nonosdk_190703,ip=lm2f,dbg=Serial1,lvl=SSL,wipe=none,baud=115200
4040
echo -en ","
4141
42-
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp8266 esp8266 1.8.19 esp8266com:esp8266:generic:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,ResetMethod=nodemcu,CrystalFreq=26,FlashFreq=80,FlashMode=qio,eesz=4M2M,led=2,sdk=nonosdk_190703,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200
42+
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp8266_pico esp8266 1.8.19 esp8266com:esp8266:generic:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,ResetMethod=nodemcu,CrystalFreq=26,FlashFreq=80,FlashMode=qio,eesz=4M2M,led=2,sdk=nonosdk_190703,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200
4343
echo -en ","
4444
4545
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp32 esp32 1.8.19 espressif:esp32:esp32:FlashFreq=80

examples/esp8266_pico/WebSocketClientOTA/WebSocketClientOTA.ino

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,27 @@
1010

1111
#if defined(ESP8266)
1212
#include <ESP8266WiFi.h>
13+
#include <ESP8266WiFiMulti.h>
1314
#include <ESP8266mDNS.h>
1415
#include <Updater.h>
16+
#include <Hash.h>
17+
18+
ESP8266WiFiMulti WiFiMulti;
1519
#elif defined(ESP32)
16-
#include "WiFi.h"
20+
#include <WiFi.h>
21+
#include <WiFiMulti.h>
1722
#include "ESPmDNS.h"
1823
#include <Update.h>
24+
25+
WiFiMulti WiFiMulti;
1926
#else
2027
#error Unsupported device
2128
#endif
2229

2330
#include <WiFiUdp.h>
24-
#include <ESP8266WiFiMulti.h>
25-
2631
#include <WebSocketsClient.h>
2732

28-
#include <Hash.h>
2933

30-
ESP8266WiFiMulti WiFiMulti;
3134
WebSocketsClient webSocket;
3235

3336
#define USE_SERIAL Serial
@@ -49,19 +52,12 @@ uint32_t maxSketchSpace = 0;
4952
int SketchSize = 0;
5053
bool ws_conn = false;
5154

52-
String IpAddress2String(const IPAddress& ipAddress)
53-
{
54-
return String(ipAddress[0]) + String(".") +
55-
String(ipAddress[1]) + String(".") +
56-
String(ipAddress[2]) + String(".") +
57-
String(ipAddress[3]);
58-
}
5955

6056
void greetings_(){
6157
StaticJsonDocument<200> doc;
6258
doc["type"] = "greetings";
6359
doc["mac"] = WiFi.macAddress();
64-
doc["ip"] = IpAddress2String(WiFi.localIP());
60+
doc["ip"] = WiFi.localIP().toString();
6561
doc["version"] = version;
6662
doc["name"] = name;
6763
doc["chip"] = chip;
@@ -89,7 +85,7 @@ typedef struct {
8985
CALLBACK_FUNCTION func;
9086
} RESPONSES_STRUCT;
9187

92-
void OTA(JsonDocument &msg){
88+
void OTA_RESPONSES(JsonDocument &msg){
9389
USE_SERIAL.print(F("[WSc] OTA mode: "));
9490
const char* go = "go";
9591
const char* ok = "ok";
@@ -114,17 +110,17 @@ void OTA(JsonDocument &msg){
114110
}
115111
}
116112

117-
void STATE(JsonDocument &msg){
113+
void STA_RESPONSES(JsonDocument &msg){
118114
// Do something with message
119115
}
120116

121117
// Count of responses handled by RESPONSES_STRUCT
122118
// increase increase if another response handler is added
123-
int nrOfResponses = 2;
119+
const int nrOfResponses = 2;
124120

125-
RESPONSES_STRUCT responses[] = {
126-
{"ota", OTA},
127-
{"state", STATE},
121+
RESPONSES_STRUCT responses[nrOfResponses] = {
122+
{"ota", OTA_RESPONSES},
123+
{"state", STA_RESPONSES},
128124
};
129125

130126
void text(uint8_t * payload, size_t length){

0 commit comments

Comments
 (0)
0