作家
登录

当JavaScript 遇上物联网(IoT)

作者: 来源: 2017-09-11 15:05:44 阅读 我要评论

  •  
  • var port = 1883 
  •  
  • var host = productKey + '.iot-as-mqtt.cn-shanghai.aliyuncs.com' 
  •  
  •   
  •  
  • var clientId = os.hostname(); 
  •  
  • var timestamp = (new Date()).valueOf() 
  •  
  • var mqttClientId = clientId + "|securemode=3,signmethod=hmacsha1,timestamp=" + timestamp + "|"
  •  
  • var mqttUsername = deviceName + "&" + productKey 
  •  
  • var content = 'clientId' + clientId + 'deviceName' + deviceName + 'productKey' + productKey + 'timestamp' + timestamp 
  •  
  •   
  •  
  • // var forge = require('forge'
  •  
  • // var hmac = forge.hmac.create(); 
  •  
  • // hmac.start('sha1', deviceSecret); 
  •  
  • // hmac.update(content); 
  •  
  • // var mqttPassword = hmac.digest().toHex(); 
  •  
  • // console.log(mqttPassword) 
  •  
  • // 今朝ruff上无法应用crypto等包,可以自行实现一个hmac sha1加密 
  •  
  • var mqttPassword = '生成的秘文' 
  •   
  •  
  • var puburl = "/" + productKey + "/" + deviceName + "/update" 
  •  
  • var suburl = "/" + productKey + "/" + deviceName + "/get"  
  •   
  •  
  • var tsl_options = { 
  •  
  •   port: port, 
  •  
  •   host: host, 
  •  
  •   rejectUnauthorized: false
  •  
  •   keepalive: 100, 
  •  
  •   clientId: mqttClientId, 
  •  
  •   username: mqttUsername, 
  •  
  •   password: mqttPassword 
  •  
  •   
  •  
  • $.ready(function (error) { 

      推荐阅读

      决策树分类预测过程可视化

    #决定计划树可视化 dot_data = tree.export_graphviz(clf, out_file=None, feature_names=vec.get_feature_names(), class_names=clf.classes_, filled=True, rounded=True, special_characters=True) graph =>>>详细阅读


    本文标题:当JavaScript 遇上物联网(IoT)

    地址:http://www.17bianji.com/lsqh/37302.html

  • 关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)