You are reading a single comment by @SergeP and its replies. Click here to read the full conversation.
  • Hi!
    I try to implement better BlueTooth control of my greenhouse and I have a few problems with EspruinoHub.
    First of all, when I try to send stringifyed JSON from node-red I have a crash of EspruinoHub. It is because of the function in its code in mqttclient.js:

    function convertMessage(data) {
      data = data.toString();
      try {
        data = JSON.parse(data);
      } catch (e) {
        // if it's not parseable, we just use the string as-is
      }
      return data;
    }
    

    The code converts string to string (nothing happens), then converts it back to JSON, and then the JSON can not be sent. My JSON is created from {c:{w:20,a:1},id:2}
    My workaround is to comment JSON.parse().

    Second problem is that EspruinoHub often stops to connect to device without any resonable log. I do not know why. Usually I can see that after device reprogramming. When I try to send something to device nothing happens. There is nothing like that:

    Scanning stopped.
     dc:0f:df:1e:d4:72: Connecting...
     Connected.
     dc:0f:df:1e:d4:72: Getting Service...
     dc:0f:df:1e:d4:72: found service: fffe
     dc:0f:df:1e:d4:72: found characteristic: 1
     dc:0f:df:1e:d4:72: Written.
     dc:0f:df:1e:d4:72: Disconnecting due to lack of use (after 10 secs)
     dc:0f:df:1e:d4:72: Disconnecting.
     dc:0f:df:1e:d4:72: Disconnected
     Restarting scan
     Scanning started.
    

    I've added logging to start of write processing (after 'if (path[1]=="write") {') and I can see that it is called with correct data. But there is nothing after that.
    After it happens EspruinoHub come to state when it will not send anything to device.
    After restart EspruinoHub returns to working state.

    Third problem is packet reassembling at device. I'd want to propose some change in EspruinoHub logic. Now when EspruinoHub sends more then 20 bytes of data to BLE characteristic it split the data to 20 bytes chunks. And It is hard to check on device if everything is already sent. It will be quite easier if Espruinohub always sends last chunk of smaller size. It may be zero size if data size is multiple of 20.
    The logic is similar to USB. I've implemented that. It makes packet reassembling very simple.

About

Avatar for SergeP @SergeP started