Avatar for Engineer

Engineer

Member since Nov 2018 • Last active Nov 2018
  • 4 conversations
  • 9 comments

Most recent activity

  • in ESP32
    Avatar for Engineer

    ESP32 WROOM-32 Dev Kit | firmware v2.00
    Using string UUID (16bit or 128bit representation) throws an error ERROR: empty UUID type. Integers between 0 and 0xFFFF works fine.

    NRF.setServices() docs note: UUIDs can be integers between 0 and 0xFFFF, strings of the form "ABCD", or strings of the form "ABCDABCD-ABCD-ABCD-ABCD-ABCDABCDABCD"

    NRF.setServices({
      "81b38ab0-908a-4c40-8f29-b19ed4524599" : {
        "81b38ab1-908a-4c40-8f29-b19ed4524599" : {
          value : 0x01,
          readable : true,
          writable : true,
          description: "Param1",
          onWrite : e => {
            console.log("P1 got: ", e.data);
          }
        },
        "81b38ab2-908a-4c40-8f29-b19ed4524599" : {
          value : 0x02,
          readable : true,
          writable : true,
          description: "Param2",
          onWrite : e => {
            console.log("P2 got: ", e.data);
          }
        },
        "81b38ab3-908a-4c40-8f29-b19ed4524599" : {
          value : 0x03,
          readable : true,
          writable : true,
          description: "Param3",
          onWrite : e => {
            console.log("P3 got: ", e.data);
          }
        }
      }
    });
    
  • in ESP32
    Avatar for Engineer

    Thanks Gordon for reply. I thought that I did something wrong because I could not find my esp32 with NRF Connect. But the thing was that I looked for MAC that I got from NRF.getAddress() -> "de:ad:de:ad:de:ad". In fact esp32 advertising with MAC from getSerial() -> "30aea488-a16c" -> 30:ae:a4:88:a1:6c.
    I just trying esp32, that is not mine by the way :), as starting point. So if I'll start some serious project I'll definitely buy one of your official boards to have more reliable BLE support and help the Espruino Project. But I can't afford it now.

  • in ESP32
    Avatar for Engineer

    I've tested some code without .end(). It eats memory and crashes like I described above.
    Gordon, Wilberforce thank you for help!

  • in ESP32
    Avatar for Engineer

    Hi everyone! Can anyone tell what I'm doing wrong?
    Code below returns:
    >FIXME WARNING: check error not implemented yet:0
    and sometimes:
    WARNING: update connetion params status = 0, min_int = 0, max_int = 0,conn_int = 6,latency = 0, timeout = 500

    setInterval(function() {
      NRF.setAdvertising({
        0x1809 : [95]
      });
    }, 3000);
    

    Firmware espruino_2v00_esp32 and espruino_2v00.90_esp32

  • in ESP32
    Avatar for Engineer

    Sorry, I can't post that code. I have deleted it. I believe that I didn't use .end(). So it can be the reason.
    Though there is a part of new code that works fine now:

    // On POST Request Handler
    function onPOST(req, res) {
      let data = '';
      req.on('data', d => data += d);
      req.on('end', () => {
        try {
          let obj = JSON.parse(data);
          mod = obj.mode;
          res.writeHead(200, { 'Content-Type': 'text/plain' });
          res.end('Mode Set');
        } catch (err) {
          res.writeHead(200, { 'Content-Type': 'text/plain' });
          res.end(`Error: ${err}`);
        }
      });
    }
    
  • in ESP32
    Avatar for Engineer

    Wilberforce
    Can you post your code?

    I've found what is the source of problem. If you don't put callback function (as in example below) into POST handler your memory usage increases with every POST request and program after a while crashed. With such callback everything works now, I think :)

    // This handles any received data from the POST request
    function handlePOST(req, callback) {
      var data = "";
      req.on('data', function(d) { data += d; });
      req.on('end', function() {
        // All data received from the client, so handle the url encoded data we got
        // If we used 'close' then the HTTP request would have been closed and we
        // would be unable to send the result page.
        postData = {};
        data.split("&").forEach(function(el) {
          var els = el.split("=");
          postData[els[0]] = decodeURIComponent(els[1]);
        });
        // finally our data is in postData
        console.log(postData);
        // do stuff with it!
        console.log("We got sent the text ", postData.mytext);
        digitalWrite(LED1, postData.led1);
        digitalWrite(LED2, postData.led2);
        // call our callback (to send the HTML result)
        callback();
      });
    }
    
Actions