Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Schedule display
#12
(07-29-2023, 07:38 PM)iliaslamprou Wrote: Hi,

you can download the new "Schedule" example from the same link:
https://virtuino.com/downloads/virtuino_...xample.zip

The changes concern only the functions SendValue and webSocketEvent

You have to replace them with the following.
The new functions support the library ArduinoJSON that it is included in this sketch.

This example is supported by Virtuino IoT version 0.6.0 or higher. It will be available at July 31 2023

Code:
bool sendValue(const char* tag, String value){
  JSONVar myObject;
  myObject[tag] = value;
  String jsonString = JSON.stringify(myObject);
  Serial.println("Send: "+jsonString);
  return  webSocket.broadcastTXT(jsonString);
}

Code:
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {
    switch(type) {
        case WStype_DISCONNECTED:
            Serial.printf("[%u] Disconnected!\n", num);
            break;
        case WStype_CONNECTED:{
            IPAddress ip = webSocket.remoteIP(num);
            Serial.printf("[%u] New client connected - IP: %d.%d.%d.%d \n", num, ip[0], ip[1], ip[2], ip[3]);
            sendPinsStatus();         // send the initial pin and variable values to the connected clients
            break;
        }
        case WStype_TEXT:  // a new message received
            Serial.println("--- a new message received ---");
            Serial.println((char*) payload);
            JSONVar myObject = JSON.parse((char*) payload);
            if (JSON.typeof(myObject) == "undefined"){
              Serial.println("Parsing incoming Json data failed!");
              return;                    
            }
           
            JSONVar keys = myObject.keys();
            for (int i = 0; i < keys.length(); i++) {
                JSONVar value = myObject[keys[i]];
                onValueReceived((const char*)keys[i],(const char*)value);  
             }         

            break;
    }
}

Thanks a lot, but on Apple Store there is a old version 0.5.44, where i download a new versione for IOS?
Reply


Messages In This Thread
Schedule display - by marcopc - 07-11-2023, 02:25 PM
RE: Schedule display - by iliaslamprou - 07-11-2023, 10:36 PM
RE: Schedule display - by marcopc - 07-12-2023, 07:01 AM
RE: Schedule display - by iliaslamprou - 07-15-2023, 07:39 PM
RE: Schedule display - by marcopc - 07-18-2023, 06:43 AM
RE: Schedule display - by marcopc - 07-21-2023, 11:58 AM
RE: Schedule display - by iliaslamprou - 07-25-2023, 01:43 AM
RE: Schedule display - by marcopc - 07-28-2023, 06:25 AM
RE: Schedule display - by iliaslamprou - 07-29-2023, 01:58 AM
RE: Schedule display - by marcopc - 07-29-2023, 08:02 AM
RE: Schedule display - by iliaslamprou - 07-29-2023, 07:38 PM
RE: Schedule display - by marcopc - 08-02-2023, 09:34 AM
RE: Schedule display - by marcopc - 08-04-2023, 07:03 AM
RE: Schedule display - by iliaslamprou - 08-04-2023, 06:42 PM
RE: Schedule display - by marcopc - 08-05-2023, 07:06 AM
RE: Schedule display - by marcopc - 08-05-2023, 03:40 PM
RE: Schedule display - by iliaslamprou - 08-05-2023, 09:25 PM

Forum Jump:


Users browsing this thread: 4 Guest(s)