2017-02-24 21 views
0

に登録することはできませんがRasberryPiと呼ばれ、私は、次のコードを使用して、その影に登録しようとしています:AWS IOT:私はAWSのIoTでものを作成した影

var awsIot = require('aws-iot-device-sdk'); 

var thingShadows = awsIot.thingShadow({ 
    keyPath: "./certs/private.pem.key", 
    certPath: "./certs/certificate.pem.crt", 
    caPath: "./certs/root-CA.crt", 
    clientId: "RasberryPi1", 
    region: "eu-west-1", 
    port: "8883", 
    debug: true 
}); 

thingShadows.on('connect', function() { 

    console.log('connected'); 

    thingShadows.register('RasberryPi1', function() { 
     console.log('registered'); 
... 

私は正常に接続が、私は登録したことがありません。つまり、2番目のconsole.logステートメントは決して実行されません。誰も私の間違いについて助言してもらえますか?私はAWS IoTの新機能です。私の間違いはおそらく非常に基本的なものです。

感謝

答えて

0

それは本当に混乱するかもしれませんが、それは理由のドキュメントです。あなたがここにドキュメントを読んだときhttps://github.com/aws/aws-iot-device-sdk-js#thing-shadow-class

// 
// After connecting to the AWS IoT platform, register interest in the 
// Thing Shadow named 'RGBLedLamp'. 
// 
thingShadows.register('RGBLedLamp', function() { 
    // Your code here 
} 

しかし:あなたは、おそらくここのような例は以下の通りですhttps://github.com/aws/aws-iot-device-sdk-js#awsiotthingshadowregisterthingname-options-callback-あなたはレジスタ機能がない第二引数としてではなく第三としてコールバックを取ることがわかります

(!)ただ、このようにそれを呼び出す:

thingShadows.register('RGBLedLamp', {}, function() { 
    // Your code here 
} 

をし、それが魅力のように動作します

関連する問題