# intel **Repository Path**: mrbian/intel ## Basic Information - **Project Name**: intel - **Description**: intel板子比赛 - **Primary Language**: NodeJS - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2016-04-23 - **Last Updated**: 2025-12-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # intel ## todo 完善api ## 全局配置 ***Host*** : 139.129.42.180 ***Port*** : 5000 ## 通用返回格式 ``` { "status" : INT // 1表示正常,0表示失败 "msg" : "" //信息 } ``` ***注意 Attention*** : - 所有的请求都有前缀 : /intel - 路由前带有token的需要在headers里面加上 token : token - 服务器的地址改变,请注意 ## 客户端新版API列表 ### 获得计划 **Url** : "/plan/collection" **Method** : GET **Need Param** : ``` null ``` ***Example*** : ``` /state?equipment=intelAir&type=wind ``` ***Return*** : ``` [ { "equipment":"intelBody", "type":"plan", "value":"{\"target\":\"intelPatch\",\"result\":{\"on\":\"111\",\"off\":\"000\"}}" } ] ``` ### 设置计划 **Url** : "/plan" **Method** : POST **Need Param** : ``` equipment : ["intelBody"]中的一个 value : { target : "intelPatch", // intelBody目标 result : { on : "111", // 人在房间内的时候 off : "000" // 人不在房间内的时候 } } ``` ***Return*** : ``` { "status":1, "msg":"ok" } ``` ### socket 连接 host : 139.129.42.180 port : 5000 连接时需要带上的参数 : ``` { name : "phone" } ``` 你需要监听的指令的key值分别为 phoneDoorBell, phoneBody,js代码示例: ``` phoneClient.socket.on("phoneDoorBell",function(data){ // 门铃 console.log(data); console.log(data.value); // 值在value里面,开是0,关是1,string类型 }); phoneClient.socket.on("phoneBody",function(data){ // 人体感应 console.log(data); console.log(data.value); // 值在value里面,有是1,没有是0,string类型 }); ``` ### 得到设备状态 **Url** : "/state" **Method** : GET **Need Param** : ``` equipment : STRING // 必须是["intelAir","intelPatch","intelBody"]中的一个 type : STRING // 必须是["wind","temperature","state"]中的一个 ``` ***Example*** : ``` /state?equipment=intelAir&type=wind ``` ***Return*** : ``` { "status":1, "msg":{ "id":203, "value":"10", "type":"wind", "equipment":"intelAir", "createdAt":"2016-09-08T07:21:57.245Z", "updatedAt":"2016-09-08T07:21:57.245Z", "DeviceID":1 } } ``` ### 得到数据 **Url** : "/data" **Method** : GET **Need Param** : ``` equipment : STRING // 必须是["intelSensor","intelDoorBell"]中的一个 type : STRING // 必须是["temperature","humidity","json"]中的一个 limit : INT // 你想要获得数据的个数 time : Unix Timestamp // Unix时间戳,一般是当前的时间的Unix时间戳 duration : INT // 多少时间之前以内的数据,单位是秒,得到的数据就是time - duration这个时间区间内的数据 ``` ***Example*** : ``` /state?equipment=intelSensor&type=temperature&limit=1&time=1473327340137&duration=3600 ``` ***Return*** : ``` { "status":1, "msg":[ { "id":100, "value":"16", "type":"temperature", "equipment":"intelSensor", "createdAt":"2016-09-08T07:21:51.895Z", "updatedAt":"2016-09-08T07:21:51.895Z", "DeviceID":1 } ] ``` ### 设置插线板和空调状态 **Url** : "/setState" **Method** : POST **Need Param** : ``` equipment : STRING // 必须是["intelAir","intelPatch"]中的一个 type : STRING // 必须是["state","wind","temperature"] 中的一个 value : STRING // 设置的状态,如插线板是001,代表第一个和第二个关,第三个开,空调就是把温度设置成这个state的数值 ``` ***Example*** : ``` /state?equipment=intelPatch&type=state post 的数据 : { value : 001 } ``` ***Return*** : ``` { "status":1, "msg":"ok" ``` ## 客户端旧版API列表 ### 注册 **Url** : "/register" **Method** : POST **Need Param** : ``` { phone : STRING pwd : STRING verification : verification //验证码 } ``` **Return** : ``` { "status":-1, "msg":"{\"status\":468}" //信息 } ``` **说明** : status -1 代表验证码错误或验证码相关其他错误, status 0 代表用户已经存在 status 1 代表注册成功 ### 登录 **Url** : "/login" **Method** : POST **Need Param** : ``` { phone : STRING pwd : STRING } ``` **Return** : ``` { "status":1, "msg":{ "token":"XnjjiY1azfOA4iqMHomfSvhS+Cc=" } } ``` **说明** : token 就是必须在header里面加入的token ### 得到当前所有链接设备的名称 **Url** : "/token/getConnectlist" **Method** : GET || POST **Need Param** : ``` null ``` **Return** : ``` { "status":1, "msg":{ "list":["intel iot"] } } ``` ### 得到搜集到的所有的温度数据列表 **Url** : "/token/getTemperature" **Method** : GET || POST **Need Param** : ``` null ``` **Return** : ``` { "status":1, "msg":{ "list":[ {"id":34,"temperature":"12","createdAt":"2016-05-12T01:04:43.371Z","updatedAt":"2016-05-12T01:04:43.371Z"} ] } } ``` ## 硬件API列表 采用tcp长链接,host和port一致 ### 设备登录 Emit: "login", Data: {name:设备名称} Return Emit : "login:logined", Return Data: NULL ### 传输温度数据 Emit: "temperature", Data : {temperature : 温度} Return Emit : "data" Return Data : ``` { status:0, msg: err } ```