# yefito_yfc01 **Repository Path**: i3cloud/yefito_yfc01 ## Basic Information - **Project Name**: yefito_yfc01 - **Description**: yefito_yfc01 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-10-26 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Yfc01 接口文档 版本: 版本 | 日期 |操作人 --- |---|--- v1.0 | 2020-10-25|Ting ## MQTT服务器 ### 设备连接 MQTT地址:47.115.184.239:1883 用户名密码:无 keeplive:10秒 ClidentID命名规则:设备ID(MAC) 设备订阅TOPIC: yefiot/yfn01/设备ID(MAC)/get/# 设备发布TOPIC: access/yefiot/yfv01/设备ID(MAC)/post 消息主体格式:JSON ### 设备端--接收 #### 设备端--接收--消息内容 方法 | 设备ID |消息ID |时间戳 |data | ---------|---------|-----------|-----------|---------| action |device |message_id |timestamp |请求内容 | #### 设备端接收--示例 ``` { "action":"open_box", "device":"xxxxxxxx", "message_id":"12345678", "timestamp":"1603184736000", "data":["1","2" ] } ``` #### 设备端--接收--方法列表 方法名称|请求内容|说明| ------------|------------|-----------| status|[]|请求所有柜门状态| open_box|[]|打开柜门 data 为柜子内部编号数组| open_door|[]|开门 data 为空| _offer|[{"from_info":"呼叫者信息"},{"desc":"offer数据"}]|呼叫请求| _answer|[{"desc":"answer数据"}]|_answer请求| 其他|...|类webrtc流程| ### 设备端--发送 #### 设备端--发送--消息内容 状态码 |方法 | 设备ID |消息ID(接收原样返回) |时间戳 |data | -------|---------|-----------|--------------------|-----------|---------| code |action |device_id |message_id |timestamp |请求内容 | #### 设备端--发送--示例 ``` { "code":"0", "action":"open_door", "device_id":"xxxxxxxx", "message_id":"12345678", "timestamp":"1603184736000", "data":[] } ``` #### 设备端--接收--方法列表 方法名称|请求内容|说明| ------------|------------|-----------| status|[{"box_id":"2","msg":"没有打开"}...]|柜门状态跟新| 其他|...|类webrtc流程| ## 1、设备升级检测接口 ### 1.1接口url #### https://smart.yefiot.com/api/yefiot/v1/ota/check ### 1.2请求方式 HTTP POST ### 1.3请求头 参数 |类型 |是否必传 |说明 | 示例 | -------- |---------|--------|----------|---------| ### 1.4参数说明 参数 |类型 |是否必传 |说明 | 示例 | ----------------|----------|------- |----------------------|---------| device_id | string |是 |设备ID |xxxxxxxx| ver | string |是 |当前版本号 |1.1.0 | ### 1.5返回结果 ``` { "code": 0, "version": "1.2.1", "md5": "xxxxxxxxxxxxxxxx", "url": "http://xxx.com/ota_1_2_1.apk" } ``` ### 1.6返回说明 code - 0 有更新 1无更新 md5 - 文件校验值 url - 更新文件下载地址 ## 附录 webrtc 旧api ### 登陆 请求 ```js {"access_key":"access_key","action":"login","auth":"auth","cid":"cid","device_id":"mac","timestamp":1578294191031,"wid":"wid","sign":"sign"} ``` - wid `connect获取到的wid` - cid `connect获取到的cid` - access_key `商户access_key` - auth `商户账号` - device_id `设备唯一码` - timestamp `当前时间戳` - sign `签名数值(附录 签名算法)` ### 呼叫 请求 ```js {"action":"call","device_id":"device_id","auth":"auth","call_access":"call_access"} ``` - device_id `被叫端设备唯一码` - auth `商户账号` - call_access `被叫端设备的access_key` ### 心跳 请求 ```js {"action":"ping"} ``` ### _offer 请求 ```js {"action": "_offer","answer_device_id": "answer_device_id","offer_device_id": "offer_device_id","desc": "desc",} ``` - answer_device_id `answer设备唯一码` - offer_device_id `offer设备唯一码` - desc `offer数据` ### _answer 请求 ```js {"action": "_answer","answer_device_id": "answer_device_id","offer_device_id": "offer_device_id","desc": "desc",} ``` - answer_device_id `answer设备唯一码` - offer_device_id `offer设备唯一码` - desc `answer数据` ### offer_ice_candidate 请求 ```js {"action": "offer_ice_candidate","answer_device_id": "answer_device_id","offer_device_id": "offer_device_id","candidate": "candidate",} ``` - answer_device_id `answer设备唯一码` - offer_device_id `offer设备唯一码` - candidate `offer_ice_candidate数据` ### answer_ice_candidate 请求 ```js {"action": "answer_ice_candidate","answer_device_id": "answer_device_id","offer_device_id": "offer_device_id","candidate": "candidate",} ``` - answer_device_id `answer设备唯一码` - offer_device_id `offer设备唯一码` - candidate `answer_ice_candidate数据` ### 挂断 请求 ```js {"action": "endcall","end_device_id": "end_device_id","my_device_id": "my_device_id"} ``` - end_device_id `对方设备唯一码` - my_device_id `自己设备唯一码` ## 通讯流程 #### 呼叫端 - 连接信令服务器 - getUserMedia 取本地视频流 - login 请求登陆 - call 请求呼叫 - 发送 offer_ice_candidate 请求 - setLocalDescription 保存desc信息到本地 - 发送 _offer 请求 - 接收 _answer 请求 - setRemoteDescription 保存desc信息到本地 - 接收 answer_ice_candidate 请求 - addIceCandidate 保存candidate信息到本地 - onaddstream 检测到媒体流连接到本地 输出 #### 应答端 - 连接信令服务器 - getUserMedia 取本地视频流 - login 请求登陆 - 接收 _offer 请求 - 发送 answer_ice_candidate 请求 - setRemoteDescription 保存desc信息到本地 - 发送 _answer 请求 - setLocalDescription 保存desc信息到本地 - 接收 offer_ice_candidate 请求 - addIceCandidate 保存candidate信息到本地 - onaddstream 检测到媒体流连接到本地 输出