Compare commits

..

1 Commits

Author SHA1 Message Date
samuelbles07
844674d8ee Working feature ce using coap 2025-12-17 11:44:26 +07:00
3 changed files with 6 additions and 12 deletions

View File

@@ -998,7 +998,7 @@ void initializeNetwork() {
delay(2500); delay(2500);
} }
if (!agClient->begin(ag->deviceId().c_str())) { if (!agClient->begin(ag->deviceId().c_str(), AirgradientClient::ONE_OPENAIR)) {
oledDisplay.setText("Client", "initialization", "failed"); oledDisplay.setText("Client", "initialization", "failed");
delay(5000); delay(5000);
oledDisplay.showRebooting(); oledDisplay.showRebooting();
@@ -1057,7 +1057,7 @@ void initializeNetwork() {
return; return;
} }
std::string config = agClient->httpFetchConfig(); std::string config = agClient->coapFetchConfig();
configSchedule.update(); configSchedule.update();
// Check if fetch configuration failed or fetch succes but parsing failed // Check if fetch configuration failed or fetch succes but parsing failed
if (agClient->isLastFetchConfigSucceed() == false || if (agClient->isLastFetchConfigSucceed() == false ||
@@ -1086,7 +1086,7 @@ static void configurationUpdateSchedule(void) {
return; return;
} }
std::string config = agClient->httpFetchConfig(); std::string config = agClient->coapFetchConfig();
if (agClient->isLastFetchConfigSucceed()) { if (agClient->isLastFetchConfigSucceed()) {
configuration.parse(config.c_str(), false); configuration.parse(config.c_str(), false);
} }
@@ -1428,7 +1428,7 @@ void postUsingCellular(bool forcePost) {
xSemaphoreGive(mutexMeasurementCycleQueue); xSemaphoreGive(mutexMeasurementCycleQueue);
// Attempt to send // Attempt to send
if (agClient->httpPostMeasures(payload, extendPmMeasures) == false) { if (agClient->coapPostMeasures(payload) == false) {
// Consider network has a problem, retry in next schedule // Consider network has a problem, retry in next schedule
Serial.println("Post measures failed, retry in next schedule"); Serial.println("Post measures failed, retry in next schedule");
return; return;

View File

@@ -953,13 +953,7 @@ bool Configuration::parse(String data, bool isLocal) {
String(value ? "true" : "false")); String(value ? "true" : "false"));
jconfig[jprop_extendedPmMeasures] = value; jconfig[jprop_extendedPmMeasures] = value;
} }
} } else {
else if (JSON.typeof_(root[jprop_extendedPmMeasures]) == "null" and !isLocal) {
// So if its not available on the json and json comes from aigradient server
// then set its value to default (false)
jconfig[jprop_extendedPmMeasures] = jprop_extendedPmMeasures_default;
}
else {
if (jsonTypeInvalid(root[jprop_extendedPmMeasures], "boolean")) { if (jsonTypeInvalid(root[jprop_extendedPmMeasures], "boolean")) {
failedMessage = jsonTypeInvalidMessage( failedMessage = jsonTypeInvalidMessage(
String(jprop_extendedPmMeasures), "boolean"); String(jprop_extendedPmMeasures), "boolean");