Back to Parent

void handledelay(const char *event, const char *data) {
    
    // Serial.println("Received delayPublish event:");
    Serial.println(data);  // Log the raw JSON string

    StaticJsonDocument<256> doc;
    DeserializationError error = deserializeJson(doc, data);

    if (error) {
        // Serial.print("JSON deserialization failed: ");
        // Serial.println(error.c_str());
        return;
    }

    // Extract the array from the JSON object
    JsonArray array = doc["breathecountlist"];
    if (!array.isNull()) {
        // Serial.println("Parsed values:");
        for (JsonVariant v : array) {
            int value = v.as<int>();  // Convert each element to an integer
            if (listSize < MAX_LIST_SIZE) {
                breathreceiveList[listSize] = v.as<int>();
                listSize++;
                // Serial.println(listSize);
            }
            Serial.println(value);   // Log the value
        }
    } else {
        Serial.println("breathecountlist is null!");
    }
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0