解决方案
Product
Services
开发者
工厂客户
Register
Login
首页
文章
详情
如何用Swift语言对接智能配电箱
2022-06-09 发布
浏览:412 次
本文介绍了如何用
Swift
对接 智能配电箱 的方法: 可以通过接口实现。
智能配电箱
更多...
支持命令
开关
power
先通后断
point
先断后通
reset
产品手册
版本
对应产品手册
HTTP接口控制
以设备控制(向设备下发命令)为例
Swift
// First you need to prepare the following values // 1. AppID (in your console development settings) // 2. AppSecret (in your console development settings) // 3. ts (timestamp of the current time, seconds) // 4. YourSign = md5(md5(AppSecret)ts);(md5 is an encryption method, AppSecret is the AppSecret prepared above, ts is the timestamp prepared above, concatenate the string after the AppSecret after md5 encryption) // In simple terms, the signature is md5(md5(your developer password)concatenate the above ts timestamp value); ts is the timestamp of the current timestamp; that is, to perform one MD5 on the developer password (AppSecret), then concatenate the timestamp, and then perform one MD5 on the entire concatenated string // Core request address: api.thingboot.com/AppID/device/control/?sign=YourSign&&ts=ts; // Request needs to pass two parameters device and order: // device[string]: unique device ID, can pass multiple [separated by ,], can be viewed in the console, or pulled through the interface // order[json string]: the command to be issued, for example: // {"power":1}, usually to connect the circuit of the switch // {"power3":0}, usually to close the third line of the switch or controller // {"play:gbk:16":"hello, welcome to visit"}, let the voice speaker report the specified content // The same type of product, the command is the same, different product types of commands, please view the product manual page of each product // Note: you must replace the formal AppID and AppSecret with real-time timestamp calculation of the signature, the request must have device device ID and order command import Foundation import CommonCrypto func calculateMD5(string: String) -> String { let length = Int(CC_MD5_DIGEST_LENGTH) var digest = [UInt8](repeating: 0, count: length) if let data = string.data(using: String.Encoding.utf8) { _ = data.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) -> Void in CC_MD5(bytes.baseAddress, CC_LONG(data.count), &digest) } } var digestHex = "" for index in 0..
文章:
如何用Swift语言对接智能配电箱
相关技术文章:
怎么用Swift语言对接30W壁挂语音通知音箱
查看
怎么用Swift语言控制智能通用控制器|24路
查看
如何用Swift语言对接3路2灯1控复合开关
查看
怎样用Swift语言对接智能 20W 壁挂远程控制语音音箱
查看
如何用Swift语言控制10A 86型定时开关插座
查看