You are reading a single comment by @Coder2012 and its replies. Click here to read the full conversation.
  • So i've read the docs and I do indeed have console logs in my code, so my plan is to remove those, but I've somehow hit another issue. When I try to send code to my board i'm getting the following error.

    New interpreter error: FIFO_FULL
    Connection error: No 'ready' after AT+RST
    

    This is odd as it has been working from the web IDE just fine recently. Here's the source. I have a raspberry pi4 running nodered which reads sensors around the house, some of these send data via MQTT which i'm picking up with the Espruino Wifi.

    const neo = require('neopixel');
    const wifi = require('Wifi');
    const WIFI_NAME = 'BTHub6-3TFX';
    const WIFI_OPTIONS = { password : 'xxxxxxxx' };
    
    let delay = 0;
    let rgb = new Uint8ClampedArray(36);
    
    
    function onInit() {
      setSleepIndicator(LED1);
      const server = '192.168.1.64';
      const options = {
        client_id : 'random',
        keep_alive: 60,         // keep alive time in seconds
        port: 1883,             // port number
        clean_session: true,
        username: 'username',   // default is undefined
        password: 'password',   // default is undefined
        protocol_name: 'MQTT',  // or MQIsdp, etc..
        protocol_level: 4,      // protocol level
      };
      const mqtt = require('MQTT').create(server, options /*optional*/);
    
      mqtt.on('connected', () => {
        console.log('connected to broker');
    
        mqtt.subscribe('doorOpen');
        mqtt.subscribe('doorClosed');
        mqtt.subscribe('heartbeat');
      });
    
      mqtt.on('publish', (pub) => {
        console.log('topic: '+pub.topic);
        console.log('message: '+pub.message);
    
        switch(pub.topic) {
          case 'doorOpen':
            console.log('doorOpen');
            doorOpen();
            break;
    
          case 'doorClosed':
            console.log('doorClosed');
            doorClosed();
            break;
    
          case 'heartbeat':
            if(parseInt(pub.message) > 1) {
              heartbeat();
            }else{
              motion();
            }
            break;
    
          default:
            neo.write(B15, lights({r: 0, g: 0, b: 0}));
            break;
        }
    
      });
    
      wifi.connect(WIFI_NAME, WIFI_OPTIONS, (err) => {
        if (err) {
          console.log('Connection error: '+err);
          return;
        }
        console.log('Connected!');
        mqtt.connect();
      });
    
      function lights(colors) {
        for (let i = 0; i < rgb.length;) {
          rgb[i++] = colors.g;
          rgb[i++] = colors.r;
          rgb[i++] = colors.b;
        }
        return rgb;
      }
    
      function doorOpen() {
        neo.write(B15, lights({r: 0, g: 0, b: 0}));
        update({r: 255, g: 0, b: 0});
      }
    
      function doorClosed() {
        neo.write(B15, lights({r: 0, g: 0, b: 0}));
        update({r: 0, g: 255, b: 0});
      }
    
      function heartbeat() {
        neo.write(B15, lights({r: 0, g: 0, b: 0}));
        update({r: 0, g: 0, b: 255});
      }
    
      function motion() {
        neo.write(B15, lights({r: 0, g: 0, b: 0}));
        update({r: 0, g: 255, b: 0});
      }
    
      function update(color) {
        neo.write(B15, lights(color));
        delay = setTimeout(() => {
          neo.write(B15, lights({r: 0, g: 0, b: 0}));
        }, 1000);
      }
    }
    
    onInit();
    
About

Avatar for Coder2012 @Coder2012 started