• Simple programs such as blink seem to transfer and run just fine, but I'm working with some Wifi and Http code that is significantly longer and it doesn't seem to transfer correctly. Log is below. The hardware is relatively new, but it worked correctly for about a day.

    Steps I've tried so far to resolve:

    • Unplugged it and plugged it back in again (yea, I worked in IT, gotta start there)
    • Used another USB cable
    • Turned on "Throttle Send" in the settings
    • Commented out large chunks, and the error moved to another line

    Environment:

    • Espruino Web IDE used as Chrome App
    • Mac OSX 10.12.6

      >
      Connected
      >echo(1)
      =undefined
      >< << {"VERSION":"1v91","BUILD_DATE":"Jan 12 2017","BUILD_TIME":"10:55:52","GIT_COMMI­T":"a6300790b771b7afffdb2bb2d8c5d0607f79­77ef","BOARD":"ESPRUINOWIFI","CHIP":"STM­32F411CEU6","CHIP_FAMILY":"STM32F4","FLA­SH":524288,"RAM":131072,"SERIAL":"43001d­00-0b513532-39333638","CONSOLE":"USB","E­XPORTS":{"jsvLock":336089,"jsvLockAgainS­afe":336075,"jsvUnLock":336049,"jsvSkipN­ame":184381,"jsvMathsOp":141949,"jsvMath­sOpSkipNames":141995,"jsvNewFromFloat":3­36405,"jsvNewFromInteger":336441,"jsvNew­FromString":339205,"jsvNewFromBool":3364­25,"jsvGetFloat":184749,"jsvGetInteger":­180485,"jsvGetBool":185337,"jspeiFindInS­copes":145525,"jspReplaceWith":154073,"j­speFunctionCall":150877,"jspGetNamedVari­able":145585,"jspGetNamedField":146857,"­jspGetVarNamedField":146449,"jsvNewWithF­lags":336245}} >> >
      >
      =undefined
      >
      _____                 _
      |   __|___ ___ ___ _ _|_|___ ___
      |   __|_ -| . |  _| | | |   | . |
      |_____|___|  _|_| |___|_|_|_|___|
            |_| http://espruino.com
      1v91 Copyright 2016 G.Williams
      >Connecting to sensor
      >Starting Wifi connection
      Uncaught SyntaxError: Got '(' expected ','
      at line 1 col 22
      function start(equire('http');
                       ^
      ERROR: Prompt not detected - upload failed. Trying to recover...
      =undefined
      >echo(1)
      =undefined
      Connected!
      Uncaught Error: Function "start" not found!
      at line 6 col 3
      start() 
      
      // Constants
      var DEVICE_ID = "1234";
      var WIFI_NAME = "*********";
      var WIFI_OPTIONS = {
      password : "*********"
      };
      var SERVER_ADDRESS = '*********';
      var SERVER_PORT = 3000;
      
      // Connect to Sensor
      var ow = new OneWire(A0);
      var sensor;
      console.log('Connecting to sensor');
      try {
      sensor = require("DS18B20").connect(ow);
      } catch (e) {
      console.log('Unable to connect to sensor \n', e.message); 
      }
      
      // Connect to Wifi
      console.log('Starting Wifi connection');
      var wifi = require("EspruinoWiFi");
      wifi.connect(WIFI_NAME, WIFI_OPTIONS, function(err) {
      if (err) {
      console.log("Wifi Connection error: "+err);
      return;
      }
      console.log("Connected!");
      start();
      });
      
      var http;
      function start() {
      http = require('http');
      if (sensor) {
      getTemp();
      //setInterval(getTemp, 60000);
      } else {
      // TODO: Report failure to somewhere
      }
      }
      
      function getTemp() {
      sensor.getTemp(function(temp) {
      console.log("Temp is "+temp+"°C"); 
      sendTemp(temp);
      });
      }
      
      function sendTemp(temp) {
      
      var postData = {
      value: {
       temperature: temp,
       unit: 'celsius'
      },
      };
      
      var reqPath= '/api/devices/' + DEVICE_ID;
      
      var req = http.request({
      host: SERVER_ADDRESS,
      port: SERVER_PORT,
      path: reqPath,
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      }
      }, function(res) {
      console.log("STATUS: " + res.statusCode);
      console.log("HEADERS: " + JSON.stringify(res.headers));
      res.setEncoding('utf8');
      res.on('data', function(data) {
        console.log("HTTP> "+data);
      });
      res.on('close', function(data) {
        console.log("Connection closed");
      });
      });
      req.on('error', function(e) {
      console.log("ERROR: problem with request: " + e.message);
      });
      req.write(postData);
      req.end();
      }
      
      
      
About

Avatar for KevinJ @KevinJ started