Merge commit '5dc2e7b0ca1354b54f50e6db6db99acad67003ac'
This commit is contained in:
commit
8d85881047
@ -109,4 +109,48 @@ bool StartWifi(const char *wifiSsid, const char *wifiPassword,
|
|||||||
|
|
||||||
return (!hotSpotEnabled);
|
return (!hotSpotEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheckFirmware(String url, String FIRMWARE_NAME, int FIRMWARE_VERSION) {
|
||||||
|
Serial.println("Checking for firmware updates.");
|
||||||
|
|
||||||
|
WiFiClient client;
|
||||||
|
HTTPClient httpClient;
|
||||||
|
String versionURL = url + FIRMWARE_NAME + ".version";
|
||||||
|
httpClient.begin(client, versionURL);
|
||||||
|
int httpCode = httpClient.GET();
|
||||||
|
if (httpCode == 200) {
|
||||||
|
String newFWVersion = httpClient.getString();
|
||||||
|
|
||||||
|
Serial.print("Current firmware version: ");
|
||||||
|
Serial.println(FIRMWARE_VERSION);
|
||||||
|
Serial.print("Available firmware version: ");
|
||||||
|
Serial.println(newFWVersion);
|
||||||
|
|
||||||
|
int newVersion = newFWVersion.toInt();
|
||||||
|
|
||||||
|
if (newVersion > FIRMWARE_VERSION) {
|
||||||
|
Serial.println("Preparing to update firmware.");
|
||||||
|
|
||||||
|
String firmwareURL = url + FIRMWARE_NAME + ".bin";
|
||||||
|
t_httpUpdate_return ret = ESPhttpUpdate.update(client, firmwareURL);
|
||||||
|
switch (ret) {
|
||||||
|
case HTTP_UPDATE_FAILED:
|
||||||
|
Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s",
|
||||||
|
ESPhttpUpdate.getLastError(),
|
||||||
|
ESPhttpUpdate.getLastErrorString().c_str());
|
||||||
|
break;
|
||||||
|
case HTTP_UPDATE_NO_UPDATES:
|
||||||
|
Serial.println("HTTP_UPDATE_NO_UPDATES");
|
||||||
|
break;
|
||||||
|
case HTTP_UPDATE_OK:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Serial.println("No Firmware update necessary.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Serial.print("Http Error: ");
|
||||||
|
Serial.println(httpCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
@ -30,8 +30,8 @@ Participant::Participant(int port) {
|
|||||||
|
|
||||||
this->participants.push_back(this);
|
this->participants.push_back(this);
|
||||||
|
|
||||||
int randomPort = (rand() % (65535 - 49152 + 1)) + 49152;
|
// int randomPort = (rand() % (65535 - 49152 + 1)) + 49152;
|
||||||
this->localPort = randomPort;
|
this->localPort = port;
|
||||||
// SetupUDP(randomPort, ipAddress, port);
|
// SetupUDP(randomPort, ipAddress, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,8 +41,8 @@ Participant::Participant(const char *ipAddress, int port) {
|
|||||||
|
|
||||||
this->participants.push_back(this);
|
this->participants.push_back(this);
|
||||||
|
|
||||||
int randomPort = (rand() % (65535 - 49152 + 1)) + 49152;
|
// int randomPort = (rand() % (65535 - 49152 + 1)) + 49152;
|
||||||
this->localPort = randomPort;
|
this->localPort = port; // randomPort;
|
||||||
// SetupUDP(randomPort, ipAddress, port);
|
// SetupUDP(randomPort, ipAddress, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,6 +90,7 @@ void Participant::Update(unsigned long currentTimeMs) {
|
|||||||
this->ReceiveUDP();
|
this->ReceiveUDP();
|
||||||
|
|
||||||
this->UpdateAll(currentTimeMs);
|
this->UpdateAll(currentTimeMs);
|
||||||
|
this->UpdateAll(currentTimeMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Participant::ReceiveUDP() {
|
void Participant::ReceiveUDP() {
|
||||||
|
2
Thing.h
2
Thing.h
@ -73,7 +73,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
/// @brief The type of Thing
|
/// @brief The type of Thing
|
||||||
unsigned char type = 0;
|
unsigned char type = 0;
|
||||||
char *name = nullptr;
|
const char *name = nullptr;
|
||||||
const char *modelUrl = nullptr;
|
const char *modelUrl = nullptr;
|
||||||
float modelScale = 1;
|
float modelScale = 1;
|
||||||
// protected Sensor sensor;
|
// protected Sensor sensor;
|
||||||
|
@ -17,7 +17,7 @@ void UdpArduino::Setup(int localPort, const char *remoteIpAddress,
|
|||||||
std::cout << "No network available!\n";
|
std::cout << "No network available!\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
udp.begin(this->remotePort);
|
udp.begin(this->localPort);
|
||||||
|
|
||||||
std::cout << "Wifi sync started to port " << this->remotePort << "\n";
|
std::cout << "Wifi sync started to port " << this->remotePort << "\n";
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user