Added JSON IP query parameters
This commit is contained in:
parent
de1eb48f78
commit
1f28bb7d5d
Binary file not shown.
|
@ -330,6 +330,7 @@ void setup() {
|
||||||
NVstore.load();
|
NVstore.load();
|
||||||
|
|
||||||
initMQTTJSONmoderator(); // prevents JSON for MQTT unless requested
|
initMQTTJSONmoderator(); // prevents JSON for MQTT unless requested
|
||||||
|
initIPJSONmoderator(); // prevents JSON for IP unless requested
|
||||||
initTimerJSONmoderator(); // prevents JSON for timers unless requested
|
initTimerJSONmoderator(); // prevents JSON for timers unless requested
|
||||||
|
|
||||||
|
|
||||||
|
@ -742,7 +743,8 @@ void loop()
|
||||||
|
|
||||||
ScreenManager.reqUpdate();
|
ScreenManager.reqUpdate();
|
||||||
}
|
}
|
||||||
updateFilteredData();
|
if(bHasHtrData)
|
||||||
|
updateFilteredData();
|
||||||
updateJSONclients(bReportJSONData);
|
updateJSONclients(bReportJSONData);
|
||||||
CommState.set(CommStates::Idle);
|
CommState.set(CommStates::Idle);
|
||||||
NVstore.doSave(); // now is a good time to store to the NV storage, well away from any blue wire activity
|
NVstore.doSave(); // now is a good time to store to the NV storage, well away from any blue wire activity
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
||||||
|
AfterburnerCRC.cpp is used to append a CRC-16 value to the
|
||||||
|
compiled binary file.
|
||||||
|
|
||||||
|
This CRC is used to confirm the binary image uploaded to the
|
||||||
|
Afterburner was genuinely intended for the Afterburner.
|
||||||
|
|
||||||
|
Naively attempting to upload the direct compiled output binary
|
||||||
|
will result in rejection of the upload attempt.
|
||||||
|
|
||||||
|
You will need to compile Afterburner.cpp and copy the resultant
|
||||||
|
executable to the repository root (adjacent to plaformio.ini)
|
|
@ -330,6 +330,7 @@ void setup() {
|
||||||
NVstore.load();
|
NVstore.load();
|
||||||
|
|
||||||
initMQTTJSONmoderator(); // prevents JSON for MQTT unless requested
|
initMQTTJSONmoderator(); // prevents JSON for MQTT unless requested
|
||||||
|
initIPJSONmoderator(); // prevents JSON for IP unless requested
|
||||||
initTimerJSONmoderator(); // prevents JSON for timers unless requested
|
initTimerJSONmoderator(); // prevents JSON for timers unless requested
|
||||||
|
|
||||||
|
|
||||||
|
@ -742,7 +743,8 @@ void loop()
|
||||||
|
|
||||||
ScreenManager.reqUpdate();
|
ScreenManager.reqUpdate();
|
||||||
}
|
}
|
||||||
updateFilteredData();
|
if(bHasHtrData)
|
||||||
|
updateFilteredData();
|
||||||
updateJSONclients(bReportJSONData);
|
updateJSONclients(bReportJSONData);
|
||||||
CommState.set(CommStates::Idle);
|
CommState.set(CommStates::Idle);
|
||||||
NVstore.doSave(); // now is a good time to store to the NV storage, well away from any blue wire activity
|
NVstore.doSave(); // now is a good time to store to the NV storage, well away from any blue wire activity
|
||||||
|
|
|
@ -27,16 +27,17 @@
|
||||||
#include "../RTC/TimerManager.h"
|
#include "../RTC/TimerManager.h"
|
||||||
#include "../Bluetooth/BluetoothAbstract.h"
|
#include "../Bluetooth/BluetoothAbstract.h"
|
||||||
#include "../WiFi/BTCWebServer.h"
|
#include "../WiFi/BTCWebServer.h"
|
||||||
|
#include "../WiFi/BTCWifi.h"
|
||||||
#include "../cfg/BTCConfig.h"
|
#include "../cfg/BTCConfig.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "../Protocol/Protocol.h"
|
#include "../Protocol/Protocol.h"
|
||||||
|
|
||||||
|
|
||||||
char defaultJSONstr[64];
|
char defaultJSONstr[64];
|
||||||
CModerator JSONmoderator;
|
CModerator JSONmoderator;
|
||||||
CTimerModerator TimerModerator;
|
CTimerModerator TimerModerator;
|
||||||
int timerConflict = 0;
|
int timerConflict = 0;
|
||||||
CModerator MQTTmoderator;
|
CModerator MQTTmoderator;
|
||||||
|
CModerator IPmoderator;
|
||||||
CModerator GPIOmoderator;
|
CModerator GPIOmoderator;
|
||||||
|
|
||||||
void validateTimer(int ID);
|
void validateTimer(int ID);
|
||||||
|
@ -179,6 +180,9 @@ void interpretJsonCommand(char* pLine)
|
||||||
else if(strcmp("FanSensor", it->key) == 0) {
|
else if(strcmp("FanSensor", it->key) == 0) {
|
||||||
setFanSensor(it->value.as<uint8_t>());
|
setFanSensor(it->value.as<uint8_t>());
|
||||||
}
|
}
|
||||||
|
else if(strcmp("IQuery", it->key) == 0) {
|
||||||
|
IPmoderator.reset(); // force IP params to be sent
|
||||||
|
}
|
||||||
// MQTT parameters
|
// MQTT parameters
|
||||||
else if(strcmp("MQuery", it->key) == 0) {
|
else if(strcmp("MQuery", it->key) == 0) {
|
||||||
MQTTmoderator.reset(); // force MQTT params to be sent
|
MQTTmoderator.reset(); // force MQTT params to be sent
|
||||||
|
@ -395,6 +399,26 @@ bool makeJSONStringMQTT(CModerator& moderator, char* opStr, int len)
|
||||||
return bSend;
|
return bSend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool makeJSONStringIP(CModerator& moderator, char* opStr, int len)
|
||||||
|
{
|
||||||
|
StaticJsonBuffer<800> jsonBuffer; // create a JSON buffer on the stack
|
||||||
|
JsonObject& root = jsonBuffer.createObject(); // create object to add JSON commands to
|
||||||
|
|
||||||
|
bool bSend = false; // reset should send flag
|
||||||
|
|
||||||
|
bSend |= moderator.addJson("IP_AP", getWifiAPAddrStr(), root);
|
||||||
|
bSend |= moderator.addJson("IP_APMAC", getWifiAPMACStr(), root);
|
||||||
|
bSend |= moderator.addJson("IP_STA", getWifiSTAAddrStr(), root);
|
||||||
|
bSend |= moderator.addJson("IP_STAMAC", getWifiSTAMACStr(), root);
|
||||||
|
bSend |= moderator.addJson("IP_STASSID", getSSID().c_str(), root);
|
||||||
|
bSend |= moderator.addJson("IP_OTA", NVstore.getUserSettings().enableOTA, root);
|
||||||
|
|
||||||
|
if(bSend) {
|
||||||
|
root.printTo(opStr, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bSend;
|
||||||
|
}
|
||||||
|
|
||||||
void updateJSONclients(bool report)
|
void updateJSONclients(bool report)
|
||||||
{
|
{
|
||||||
|
@ -477,6 +501,19 @@ void updateJSONclients(bool report)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// report MQTT params
|
||||||
|
{
|
||||||
|
if(makeJSONStringIP(IPmoderator, jsonStr, sizeof(jsonStr))) {
|
||||||
|
if (report) {
|
||||||
|
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
||||||
|
}
|
||||||
|
sendWebSocketString( jsonStr );
|
||||||
|
std::string expand = jsonStr;
|
||||||
|
Expand(expand);
|
||||||
|
getBluetoothClient().send( expand.c_str() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
if(makeJSONStringGPIO(GPIOmoderator, jsonStr, sizeof(jsonStr))) {
|
if(makeJSONStringGPIO(GPIOmoderator, jsonStr, sizeof(jsonStr))) {
|
||||||
if (report) {
|
if (report) {
|
||||||
|
@ -501,6 +538,7 @@ void resetJSONmoderator()
|
||||||
initTimerJSONmoderator();
|
initTimerJSONmoderator();
|
||||||
#endif
|
#endif
|
||||||
initMQTTJSONmoderator();
|
initMQTTJSONmoderator();
|
||||||
|
initIPJSONmoderator();
|
||||||
GPIOmoderator.reset();
|
GPIOmoderator.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,6 +548,12 @@ void initMQTTJSONmoderator()
|
||||||
makeJSONStringMQTT(MQTTmoderator, jsonStr, sizeof(jsonStr));
|
makeJSONStringMQTT(MQTTmoderator, jsonStr, sizeof(jsonStr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initIPJSONmoderator()
|
||||||
|
{
|
||||||
|
char jsonStr[800];
|
||||||
|
makeJSONStringIP(IPmoderator, jsonStr, sizeof(jsonStr));
|
||||||
|
}
|
||||||
|
|
||||||
void initTimerJSONmoderator()
|
void initTimerJSONmoderator()
|
||||||
{
|
{
|
||||||
char jsonStr[800];
|
char jsonStr[800];
|
||||||
|
|
|
@ -33,7 +33,9 @@ bool makeJSONTimerString(int channel, char* opStr, int len);
|
||||||
bool makeJSONStringGPIO( CModerator& moderator, char* opStr, int len);
|
bool makeJSONStringGPIO( CModerator& moderator, char* opStr, int len);
|
||||||
void updateJSONclients(bool report);
|
void updateJSONclients(bool report);
|
||||||
bool makeJSONStringMQTT(CModerator& moderator, char* opStr, int len);
|
bool makeJSONStringMQTT(CModerator& moderator, char* opStr, int len);
|
||||||
|
bool makeJSONStringIP(CModerator& moderator, char* opStr, int len);
|
||||||
void initMQTTJSONmoderator();
|
void initMQTTJSONmoderator();
|
||||||
|
void initIPJSONmoderator();
|
||||||
void initTimerJSONmoderator();
|
void initTimerJSONmoderator();
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
|
@ -298,6 +298,13 @@ const char* getWifiSTAMACStr()
|
||||||
return MACstr[0];
|
return MACstr[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getSSID()
|
||||||
|
{
|
||||||
|
wifi_config_t conf;
|
||||||
|
esp_wifi_get_config(WIFI_IF_STA, &conf);
|
||||||
|
return String(reinterpret_cast<const char*>(conf.sta.ssid));
|
||||||
|
}
|
||||||
|
|
||||||
bool isWifiConnected()
|
bool isWifiConnected()
|
||||||
{
|
{
|
||||||
return WiFi.status() == WL_CONNECTED;
|
return WiFi.status() == WL_CONNECTED;
|
||||||
|
|
|
@ -30,6 +30,7 @@ const char* getWifiAPAddrStr();
|
||||||
const char* getWifiSTAAddrStr();
|
const char* getWifiSTAAddrStr();
|
||||||
const char* getWifiAPMACStr();
|
const char* getWifiAPMACStr();
|
||||||
const char* getWifiSTAMACStr();
|
const char* getWifiSTAMACStr();
|
||||||
|
String getSSID();
|
||||||
|
|
||||||
bool isWifiConnected();
|
bool isWifiConnected();
|
||||||
bool isWifiAP();
|
bool isWifiAP();
|
||||||
|
|
Loading…
Reference in New Issue