Flic Home

    Community

    • Login
    • Search
    • Popular
    • Users
    1. Home
    2. cs.durak
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    cs.durak

    @cs.durak

    0
    Reputation
    17
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    cs.durak Unfollow Follow

    Latest posts made by cs.durak

    • Syntax error: Unterminated statement error after running a loop for a long time

      I have set up 10 Flic Hubs to run a code that sends a ping to my API. The code runs in an infinite loop with 1 hour sleep so I've had a ping every hour from every device.

      All seemed perfect until all of the devices stopped working around the same time.

      I've got below error on the SDK:

      SyntaxError: unterminated statement (line 2)
          at [anon] (root/heartbeat/main.js:2) internal
          at [anon] (duktape.c:71822) internal
          at loadAndCompileUserModule () native strict preventsyield
          at require (init.js:122)
          at [anon] (init.js:139) preventsyield
          at runInit () native strict preventsyield
          at handlePacket (pipe_communication.js:48)
          at readCallback (pipe_communication.js:93) preventsyield
      

      Line to corresponds to either of below lines:

      var buttonManager = require("buttons");
      var buttons = buttonManager.getButtons();
      

      Here is how my code looks like:

      // Heartbeat.js
      var buttonManager = require("buttons");
      var buttons = buttonManager.getButtons();
      var http = require("http");
      
      var url = "my_api_url";
      var DEVICE_ID = 'hub_id'
      
      function myLoop() {
          setTimeout(function() {
              for (var i = 0; i < buttons.length; i++) {
                  var button = buttons[i];
                  http.makeRequest({
                      url: url,
                      method: "POST",
                      headers: {
                          "Content-Type": "application/json"
                      },
                      content: JSON.stringify({
                          'pressedAt': Date.now(),
                          'batteryStatus': button.batteryStatus,
                          'button_sn': button.serialNumber,
                          'activeDisconnect': button.activeDisconnect,
                          'connected': button.connected,
                          'batteryStatus': button.batteryStatus,
                          'uuid': button.uuid,
                          'flicVersion': button.flicVersion,
                          'firmwareVersion': button.firmwareVersion,
                          'key': button.key,
                          'passiveMode': button.passiveMode,
                          'device_sn': DEVICE_ID,
                          'dataType': 'heartbeat'
                      }),
                  }, function(err, res) {
                      console.log("request status: " + JSON.stringify(res));
                  });
              }
      
              myLoop();
          }, 1000 * 60 * 60)
      }
      
      myLoop();
      console.log("Started");
      

      Anyone have any ideas?
      Thanks.

      posted in Developers
      cs.durak
      cs.durak
    • RE: Flic Hub can't establish working connection over Ethernet

      I've had a similar problem today. I connected my Flic Hub to the Ethernet port while being connected to wifi. Then I disconnected wifi from the mobile app.

      I clicked on Test Connection and confirmed the Internet access however Ethernet was showing not connected in the app however I couldn't log in to the SDK.

      While the Flic Hub was powered, I removed the ethernet cable and plugged back in and it reassigned the IP. Then it worked.

      posted in General Discussion
      cs.durak
      cs.durak