Jump to content

nodeJS Bindings v2.1.32 - ReferenceError: callbackFormats is not defined


Recommended Posts

Hallo zusammen, 

heute habe ich das Tinkerforge NPM-Paket (nodeJS) in meiner Software von Version 2.1.31 auf 2.1.32  aktualisiert. Leider kommt es nun während der Callback-Konfiguration zu folgender Fehlermeldung

"ERROR: ReferenceError: callbackFormats is not defined"

Dies tritt nach kurzem Test mit folgenden Bricklets auf:

  • Outdoor Weather
  • Temperature 2.0

Die beiden Scripts, die die Konfiguration bei mir übernehmen, sind unten angefügt.

Nach Rollback zu Version 2.1.31 läuft alles wieder problemfrei. In der Online-Dokumentation der API habe ich keine Änderung gefunden. Habe ich da eine wichtige Änderung bei der Callback-Konfiguration verpasst?

 

Viele Grüße

Sebastian Alexander Schäfer

 

Temperature 2.0

const DEBUG_configCallbacksTempV2_1 = false;
const DEBUG_configCallbacksTempV2_2 = false;

var configCallbacksTempV2 = function(item) {
    DEBUG_configCallbacksTempV2_1 && console.log('configCallbacksTempV2() started for ' + item.UID + ' ...');

    const interval = 1 * 60 * 1000; // every 1 min, 60 s/min, 1000 ms/s

    completeJSON.session.bricklets.wiredTemp.UID = item.UID; // Save bricklet UID to completeJSON.session

    var t = new Tinkerforge.BrickletTemperatureV2(item.UID, ipcon);

    // Configure Bricklet
    t.setStatusLEDConfig(0);
    t.setHeaterConfiguration(0);
    t.setTemperatureCallbackConfiguration(interval, false, "x", -100 * 30, +100 * 50);

    // Handle Callbacks
    t.on(Tinkerforge.BrickletTemperatureV2.CALLBACK_TEMPERATURE,
      function (temp) {
        DEBUG_configCallbacksTempV2_2 && console.log('Receiving CALLBACK_TEMPERATURE by BrickletTemperatureV2.');

        completeJSON.session.bricklets.wiredTemp.act = getToFixed(temp / 100, 1);

        // Only launch control loop if wired sensor was chosen in config
        if (completeJSON.config.webApp.userSettings.temp.sensor == 'wired') {
          ctlHeating(completeJSON.session.temp.mode);
        };

        DEBUG_configCallbacksTempV2_2 && console.log('BrickletTemperatureV2.CALLBACK_TEMPERATURE: ' + temp/100 + ' °C');
        // logAddRecordEvent('Wired Temp ' + item.UID + ' ausgelesen');
    });

    DEBUG_configCallbacksTempV2_2 && console.log('Wired temperature sensor callback initiated: ' + t.DEVICE_DISPLAY_NAME + '.');
};

if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
  // console.log('Working server side. Exposing function through module.exports')
  module.exports = configCallbacksTempV2;
} else {
  // console.log('Working client side. Exposing function through window.*')
  window.configCallbacksTempV2 = configCallbacksTempV2;
};

 

Outdoor Weather

const DEBUG_configCallbacksOutdoorWeather_1 = true;
const DEBUG_configCallbacksOutdoorWeather_2 = true;

var configCallbacksOutdoorWeather = function(item) {
    DEBUG_configCallbacksOutdoorWeather_1 && console.log('configCallbacksOutdoorWeather() started for ' + item.UID + ' ...');

    completeJSON.session.bricklets.wirelessTemp.UID = item.UID; // Save bricklet UID to completeJSON.session

    var ow = new Tinkerforge.BrickletOutdoorWeather(item.UID, ipcon); // Create device object

    // Configure Bricklet
    ow.setStatusLEDConfig(0)
    ow.setSensorCallbackConfiguration(true);

    // What do do if callbacks arrive
    ow.on(Tinkerforge.BrickletOutdoorWeather.CALLBACK_SENSOR_DATA,
      function (identifier, temperature, humidity, lastChange) {
          DEBUG_configCallbacksOutdoorWeather_2 && console.log('Receiving CALLBACK_SENSOR_DATA by BrickletOutdoorWeather.')
          // Store current settings to completeJSON.session, whenever there's a callback
          //completeJSON.session.temp.set = parseInt(document.getElementById("slider1").value)
          
          // Check if lastChange is less than 5 s old
          if (lastChange < 10) {
            DEBUG_configCallbacksOutdoorWeather_2 && console.log('BrickletOutdoorWeather sent callback too early. Tossing data this time!')
          } else {
            completeJSON.session.bricklets.wirelessTemp.act = getToFixed(temperature / 10, 1);
            completeJSON.session.bricklets.wirelessTemp.hum = getToFixed(humidity, 0);

            // Only launch control loop sensor if wired sensor was chosen in config
            if (completeJSON.config.webApp.userSettings.temp.sensor == 'wireless') {
              ctlHeating(completeJSON.session.temp.mode);
            };

            DEBUG_configCallbacksOutdoorWeather_2 && console.log('BrickletOutdoorWeather.CALLBACK_SENSOR_DATA: ' + temperature/10 + ' °C');
            // logAddRecordEvent('Sensor ' + identifier + '@' + item.UID + ' ausgelesen');
          };
      }
    );

    // DEBUG_configCallbacksOutdoorWeather_2 && console.log('Wireless temperature sensor callback initiated: ' + ow.DEVICE_DISPLAY_NAME + '.');
};

if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
  // console.log('Working server side. Exposing function through module.exports')
  module.exports = configCallbacksOutdoorWeather;
} else {
  // console.log('Working client side. Exposing function through window.*')
  window.configCallbacksOutdoorWeather = configCallbacksOutdoorWeather;
}

 

Link to comment
Share on other sites

Es gibt keine Änderungen zwischen 2.1.31 und 2.1.32, die das Problem erklären könnten. Überhaupt sind die Änderungen zwischen 2.1.31 und 2.1.32 sehr minimal.

Ich habe gerade ein Callback Beispiel in Node.js 12.20.1 mit Bindings 2.1.31 und 2.1.32 getestet. Diese funktionieren wie erwartet.

Tritt das Problem nur in deinem Programm auf, oder auch wenn wenn du z.B. das Callback Beispiel des Temperature Bricklet 2.0 testest?

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...