• ESP32 module, WIFI connected.

    In C native code , I send datas to a server by a socket connection.

    JsVar *req = jswrap_net_connect(options, callback, ST_NORMAL);
    JsVar *data = jsvNewFromString("Hello world" ); ///< Create a new string
    jswrap_net_socket_write(req, data);
    

    The server receives the data correctly, then it sends a response string "hello client" to ESP32.

    bool waitForInput(JsVar *req) {
      JsVarFloat now = jshGetMillisecondsFromTime(jshGetSystemTime());
    	//unsigned long now = millis();
    	while (!jswrap_stream_available(req) && ((jshGetMillisecondsFromTime(jshGetSystemTime()) - now) < 30000UL)) { jshDelayMicroseconds(200); }
      if(jswrap_stream_available(req)){
        return true;
      }
    	return false;
    }
    

    I use waitForInput to detect response data, but it always return FASLE.

    And, should I use the following function to receive data?

    JsVar *jswrap_stream_read(JsVar *parent, JsVarInt chars);
    
About

Avatar for Aifer @Aifer started