Avatar for SergeP

SergeP

Member since Nov 2016 • Last active Sep 2020
  • 17 conversations
  • 98 comments

Most recent activity

  • in Puck.js, Pixl.js and MDBT42
    Avatar for SergeP

    It works! Wonderful! Thank you, @Gordon!
    I choose good time for upgrade :) I've used v1.92 without the timeout bug and now I am using pre-v2.06, again without the bug. SPI is now working with TLE94112, too.
    Now I still have 2 problems only: temperature is readed not every time by OneWire (about 1 reading of 100 is unsuccessful, while it was very stable at v1.92, I've never seen that last 3 years, or about 1 500 000 x 4 reads) and EspruinoHub often does something strange (but I have another topic to discuss that). And, of course, unstable connection in EspruinoWebIDE: usually I should restart IDE server 2 or 3 times before I can connect to device, but the problem is development stage only, so it is not so significant.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for SergeP

    I've got cutting edge v2.05.107 and it looks like working! Wow!
    Tomorrow I'll check it in my greenhouse.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for SergeP

    Yes. The stripped version works when I remove the setTimeout. But my full version is based on Timeouts from Timeouts from Timeouts etc... Usually I do not ever know if some function is called from timeout or not.
    Is it possible to use timeouts from timeouts safely? Or the only way is to wait for update? I have only one setInterval in the program and it can be removed easily, if that is significant.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for SergeP

    I'm not entirely sure about the reasoning for that anyway?

    It's just to make an update of full BLE advertizing, while there are many calls of updateAdv in many functions. So I can call updateAdv in every place where I change some part of advertizing data but actually I have only one update where all these fields are changed. It is update aggregator.
    I use similar code in many places. For example, in my big clock there may be few additional info, and it is resonable to update screen one time, after all data is redrawed to screenbuffer.
    Ok, I'll try to turn it off and check.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for SergeP

    I especially like the MQTT idea, but can this run also on a windows10 machine in case I have to use one?

    I do not know. May be, but it is a question to somebody who have tried already. I use bananapi M64 board as a server, and both EspruinoHub and mosquitto (and BlueTooth) on the server. May be it may be started at Windows 10, too. And yes, EspruinoHub converts BLE messages to MQTT messages. What is good for me is that I can implement some tree.js controller in 10 minutes.

    Any idea how to implement a good reliable distance measuring

    May be it will be interesting for you to measure smaller distance (0.02-1 m) with better resolution? You can use VL53L0X in the case. I've used it and have found not bad. It may be used at longer distances, too. But conditions are not usual, as far as I remember.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for SergeP

    Full code of my greenhouse controller can work at standalone Puck.js. I can add it here. But it is too complex, I think. So I've cropped it. Now it is small part of code but still has the effect in setTimeout. I've just test it and results are: 1266 seconds by getTime() while only 139 with setTimeout in dump(). So the code is here. Last setTimeout is for the test.
    I've observed that it depends on setInterval (there is only one in my code) which is calles NRF.setAdvertizing(). If I remove setInterval, setTimeout looks like work correctly (I'm not sure). If I do not disconnect from device in EspruinoWebIDE It may be works correctly, too.

    Upd: I can not upload file (do not know why) so code is below:

    var Day = true;
    
    // usage types: 0 - unused, 1 - watering, 2 - anti-overheat fog
    // wateringTime is in minutes (after start), while startHour is in hours after dawn
    var channels = [
      {wateringStartedAt: 0 },
      {wateringStartedAt: 0 },
      {wateringStartedAt: 0 },
      {wateringStartedAt: 0 },
      {wateringStartedAt: 0 },
      {wateringStartedAt: 0 },
    ];
    
    
    var VArr = new Uint8Array(4);
    
    let updatePending = false;
    function updateAdv() {
      if (!updatePending) {
        updatePending = true;
        setTimeout(function () {
          updatePending = false;
          let pack = 0;
          for (let i = 0; i < channels.length; i++)
            pack = (pack << 1) + (channels[channels.length - 1 - i].wateringStartedAt ? 1 : 0);
          VArr[2] = (Day << 7) + pack;
          VArr[3] = 255;
          NRF.setAdvertising({
            0x1813: VArr
          }, {
            name: "Green", // The name of the device
            showName: true, // include full name, or nothing
            interval: 600 // Advertising interval in msec
          });
        }, 0);
      }
    }
    NRF.setTxPower(4);
    setInterval(function () {
      VArr[1] = Puck.light() * 255;
      updateAdv();
    }, 120000);
    
    
    setTimeout((s)=>console.log(s),7200000,"­wwee11");
    
  • in Interfacing
    Avatar for SergeP

    I've just made a tweak that should make your old code work fine though.

    Great! I've changed EspruinoHub to my code can work, but it is good to use regular one. Because the problem may be not only my problem.

    If you go to http://yourdevice:1888/status do you still see the device you're trying to connect to shown? Maybe for whatever reason it isn't seeing it in the advertising data?

    It seems to me, device is in place and advertizes carefully :) But string 'Scanning stopped' and subsequent strings will not appears anymore before EspruinoHub restart. I'll try to mine additional info.

    So the only actual change would be if packet size =20 it'd send a blank packet?

    Exactly! If last packet chunk size =20, send a blank packet after. It is like USB works (I'm not sure that USB3.2 uses the same, but up to 3.0 it uses the method to reassemble data). I've implemented that in EspruinoHub (but my code is ugly while correct) and I'm happy. I think it may be useful not only for me.

    • 4 comments
    • 387 views
Actions