Azure-Samples / iot-hub-c-m0wifi-getstartedkit

Get started with the Adafruit Feather M0 Wifi Azure IoT Starter Kit
MIT License
5 stars 8 forks source link

Device in server.js consumes all C2D messages #34

Closed caseyhagen closed 8 years ago

caseyhagen commented 8 years ago

The 'device' in server.js consumes the LED messages so the board never gets them.

AttunixCorp commented 8 years ago

The device in config.json needs to point to a device. The code is tested and sends the information to Azure properly given the correct inputs.

caseyhagen commented 8 years ago

No it doesn't work. The message that is created from the buttons is properly sent to the IoT Hub.... However the message is then consumed within node. Once the message is consumed it is dequeued. The message will never make it back to the hardware. There are two consumers but only one will receive the message. If you comment out the device stuff in server.js then it works.

/* deviceClient.open(function(err, result) { if (err) { console.log('could not connect: ' + err.message); return; } console.log('client connected');

deviceClient.on('message', function(msg) {
    console.log('Id: ' + msg.messageId + ' Body: ' + JSON.stringify(msg.data));
    deviceClient.complete(msg, completedCallback);
});

deviceClient.on('error', function(err) {
    console.error('Error: ' + err.message);
})

deviceClient.on('disconnect', function() {
    console.log('client disconnected');
    deviceClient.removeAllListeners();
    deviceClient.connect(connectCallback);
});

}); */