iOS AILinkBleSDK - 蓝牙SDK
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ELBluetoothManager.h 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. //
  2. // ELBluetoothManager.h
  3. // Elink
  4. //
  5. // Created by iot_user on 2019/4/22.
  6. // Copyright © 2019 iot_iMac. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "ELPeripheralModel.h"
  10. #import "ELSDKHeader.h"
  11. #import "ELBlePublicTool.h"
  12. #import "ELBleWifiDetailModel.h"
  13. //MARK: Broadcast Equipment Protocol(广播设备协议)
  14. @protocol ELBleBroadcastDelegate <NSObject>
  15. @optional
  16. /// Callback broadcast device data(回调广播设备数据)
  17. /// @param cid cid
  18. /// @param vid vid
  19. /// @param pid pid
  20. /// @param mac mac地址
  21. /// @param data Custom data(自定义数据)
  22. -(void)bleBroadcastWithCid:(int)cid vid:(int)vid pid:(int)pid mac:(NSString *_Nonnull)mac data:(NSData *_Nonnull)data;
  23. @end
  24. //MARK:Bluetooth Wifi protocol(蓝牙Wifi协议)
  25. @protocol ElBleWifiDelegate <NSObject>
  26. @optional
  27. /**
  28. Callback Wifi details(回调Wifi详情)
  29. @param model 模型
  30. */
  31. -(void)bleWifiReceiveWifiDetailModel:(ELBleWifiDetailModel *_Nonnull)model;
  32. /**
  33. Scan nearby wifi results(扫描附近wifi结果)
  34. @param count Number of nearby wifi(附近wifi数量)
  35. */
  36. -(void)bleWifiReceiveScanedWifiCount:(int)count;
  37. /**
  38. Callback Wifi MAC address(回调Wifi MAC地址)
  39. @param macData mac
  40. */
  41. -(void)bleWifiReceiveWifiMacData:(NSData *_Nullable)macData;
  42. /**
  43. Callback WIFI password(回调WIFI密码)
  44. @param pwd password(密码)
  45. */
  46. -(void)bleWifiReceiveWifiPwd:(NSString *_Nonnull)pwd;
  47. /**
  48. Get DTIM interval (unit: ms)(获取DTIM间隔(单位:ms))
  49. @param interval Interval (unit: ms)(间隔(单位:ms))
  50. */
  51. -(void)bleWifiReceiveWifiDTIMInterval:(NSInteger)interval;
  52. /**
  53. Returns the visited URL(返回访问的url)
  54. @param url url
  55. */
  56. -(void)bleWifiReceiveWifiAccessURL:(NSString *_Nonnull)url;
  57. /**
  58. Call back wifi port number(回调wifi的端口号)
  59. @param port 端口号
  60. */
  61. -(void)bleWifiReceiveWifiPort:(int)port;
  62. /**
  63. Set or query the callback of the instruction execution result(设置指令蓝牙WIFI响应回调方法)
  64. 只支持蓝牙Wifi部分枚举
  65. @param type Type of setting (设置的类型)
  66. @param result Set result(设置的结果)
  67. */
  68. -(void)bleWifiReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result;
  69. /**
  70. 获取会话码(deviceId)
  71. @param code (deviceId) deviceId(0 means no:为0时表示不存在)
  72. */
  73. -(void)bleWifiReceiveWifiSNCode:(int)code;
  74. @end
  75. //MARK:蓝牙通用协议
  76. @protocol ELBluetoothManagerDelegate <NSObject>
  77. @optional
  78. //Callback Bluetooth status(回调蓝牙状态)
  79. -(void)bluetoothManagerUpdateBleState:(ELBluetoothState)state;
  80. //Callback to scanned device(回调扫描到的设备)
  81. -(void)bluetoothManagerScanedPeripherals:(NSArray<ELPeripheralModel *> *_Nonnull)peripherals;
  82. //Special devices that can be bound in the callback, such as door locks(回调中扫描到的可以绑定的特殊设备,如门锁)
  83. -(void)bluetoothManagerScanedCanBindSpecialPeripherals:(NSArray<ELPeripheralModel *> *_Nonnull)peripherals;
  84. //Call back the scanned broadcast device(回调扫描到的广播设备)
  85. -(void)bluetoothManagerScanedBroadcastPeripherals:(NSArray<ELPeripheralModel *> *_Nonnull)peripherals;
  86. //Callback decrypted transparent data (A7 decrypted payload data)(回调解密后的数据(A7解密后payload数据))
  87. -(void)bluetoothManagerReceiveData:(NSData *_Nonnull)data deviceType:(ELSupportDeviceType)type;
  88. /**
  89. Callback transparent transmission data(回调透传数据)
  90. @param data Transparent data transmission (this data cannot start with A6 or A7)(透传数据(此数据不能以A6或A7开头))
  91. */
  92. -(void)bluetoothManagerReceivePassData:(NSData *_Nullable)data;
  93. #pragma mark ============ A6 Set or query the callback of the instruction execution result(设置或查询指令执行结果的回调) ==============
  94. /**
  95. Set or query the callback of the instruction execution result(设置指令蓝牙响应回调方法(握手指令除外))
  96. @param type Type of setting (设置的类型)
  97. @param result Set result(设置的结果)
  98. */
  99. -(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result;
  100. /**
  101. Query module status callback(查询模块状态的回调)
  102. @param stateStrct 结构体
  103. */
  104. -(void)bluetoothManagerReceiveMCUConnectedState:(struct ELMCUStateStruct)stateStrct;
  105. /**
  106. Query the callback of the communication mode(查询通信模式的回调)
  107. @param type communication mode(通信模式)
  108. */
  109. -(void)bluetoothManagerReceiveCommunicationMode:(ELCommunicationModeType)type;
  110. /**
  111. Query the callback of automatic sleep time(查询自动睡眠时间的回调)
  112. @param sleetStrct Automatic sleep time(自动睡眠时间)
  113. */
  114. -(void)bluetoothManagerReceiveAutoSleepTime:(struct ELAutoSleepTimeStruct)sleetStrct;
  115. /**
  116. Query master-slave mode callback(查询主从模式回调)
  117. @param mode 模式
  118. 0:Slave mode(从机模式)
  119. 1:Host mode(主机模式)
  120. */
  121. -(void)bluetoothManagerReceiveMCUMode:(int)mode;
  122. /**
  123. Query the callback of UUID information(查询UUID信息的回调)
  124. @param uuid ELUUIDStruct
  125. */
  126. -(void)bluetoothManagerReceiveUUID:(struct ELUUIDStruct)uuid;
  127. /**
  128. Query the callback of the MAC address size endian(查询MAC地址大小端序的回调)
  129. @param type 类型
  130. 0:Little endian(小端序)
  131. 1:Big endian (大端序)
  132. */
  133. -(void)bluetoothManagerReceiveMacAddressType:(int)type;
  134. /**
  135. Query the callback of the Bluetooth serial port baud rate(查询蓝牙串口波特率的回调)
  136. @param rate Serial port baud rate(串口波特率)
  137. 0:9600
  138. 1:19200
  139. 2:38400
  140. 3:57600
  141. 4:115200
  142. 5:921600
  143. */
  144. -(void)bluetoothManagerReceiveSerialPostBaudRate:(int)rate;
  145. /**
  146. Query the callback of Bluetooth transmit power(查询蓝牙发射功率的回调)
  147. @param dbm Transmit power(发射功率)
  148. */
  149. -(void)bluetoothManagerReceiveTransmittingPower:(int)dbm;
  150. /**
  151. Query the callback of the Bluetooth connection interval(查询蓝牙连接间隔的回调)
  152. @param intervalStrct connection interval
  153. */
  154. -(void)bluetoothManagerReceiveConnectInterval:(struct ELConnectIntervalStruct)intervalStrct;
  155. /**
  156. Query the callback of the Bluetooth name(查询蓝牙名称的回调)
  157. @param name Bluetooth name(蓝牙名称)
  158. */
  159. -(void)bluetoothManagerReceiceName:(NSString *_Nullable)name;
  160. /**
  161. Query the callback of the Bluetooth broadcast interval(查询蓝牙广播间隔的回调)
  162. @param interval broadcast interval(广播间隔)
  163. */
  164. -(void)bluetoothManagerReceiveBroadcastInterval:(int)interval;
  165. /**
  166. Query the callback of the Bluetooth MAC address(查询蓝牙MAC地址的回调)
  167. @param macAddress MAC
  168. */
  169. -(void)bluetoothManagerReceiveMACAddress:(NSString *_Nonnull)macAddress;
  170. /**
  171. Query the callback of the software and hardware version number of the BM module(查询BM模块软硬件版本号的回调)
  172. @param bmVersion BM module software and hardware version number(BM模块软硬件版本号)
  173. */
  174. -(void)bluetoothManagerReceiveBMVersion:(NSString *_Nonnull)bmVersion;
  175. /**
  176. Query the callback of the MCU software and hardware version number(查询MCU软硬件版本号的回调)
  177. @param mcuVersion Callback of MCU software and hardware version number(MCU软硬件版本号的回调)
  178. */
  179. -(void)bluetoothManagerReceiveMCUVersion:(NSString *_Nonnull)mcuVersion;
  180. /**
  181. Query the callback of Bluetooth time(查询蓝牙时间的回调)
  182. @param date yyyy-MM-dd HH:mm:ss
  183. @param effective Time is invalid(时间有无效)
  184. 0:effective(系统时间无效)
  185. 1:invalid(系统时间有效)
  186. */
  187. -(void)bluetoothManagerReceiveBluetoothDate:(NSString * _Nonnull)date effective:(BOOL)effective;
  188. /**
  189. Query CID, VID, PID callback(查询CID,VID,PID的回调)
  190. @param did CID,VID,PID
  191. */
  192. -(void)bluetoothManagerReceiveDID:(struct ELDIDStruct)did;
  193. /**
  194. Query the callback of the battery status(查询电池状态的回调)
  195. @param battery Structure of battery charge status and charge percentage(电池充电状态和电量百分比的结构体)
  196. */
  197. -(void)bluetoothManagerReceiveBattery:(struct ELBatteryStruct)battery;
  198. /**
  199. * Query the callback of the device support unit(查询设备支持单位的回调)
  200. */
  201. - (void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *_Nullable)weightArray
  202. Height:(NSArray<NSNumber *> *_Nullable)heightArray
  203. Temperature:(NSArray<NSNumber *> *_Nullable)temperatureArray
  204. BloodPressure:(NSArray<NSNumber *> *_Nullable)bloodPressureArray
  205. Pressure:(NSArray<NSNumber *> *_Nullable)pressureArray;
  206. /// Blood glucose units supported by callback supported devices(回调支持的设备支持的血糖单位)
  207. /// @param bloodSugarUnitArray Blood glucose unit array(血糖单位数组)
  208. -(void)bluetoothManagerReceiveSupportBloodSugarUnitArray:(NSArray<NSNumber *>* _Nullable)bloodSugarUnitArray;
  209. /**
  210. Set the result of the decoding key(设置解码密钥的结果)
  211. @param result 结果
  212. */
  213. -(void)bluetoothManagerReceiveSetKeyResult:(BOOL)result;
  214. /// Device authorization result(设备授权结果)
  215. /// @param result 结果
  216. -(void)bluetoothManagerReceiveDeviceAuthorizeResult:(ELBluetoothDeviceAuthorizeResult)result;
  217. @end
  218. NS_ASSUME_NONNULL_BEGIN
  219. @interface ELBluetoothManager : NSObject
  220. @property (nonatomic, assign, readonly) BOOL isOn;
  221. //Bluetooth status(蓝牙状态)
  222. @property (nonatomic, assign, readonly) ELBluetoothState state;
  223. //version number(版本号)
  224. @property (nonatomic, copy, readonly) NSString *bmVersion;
  225. /**
  226. Save the model corresponding to the currently connected device
  227. 保存当前连接的设备对应的模型
  228. */
  229. @property (nonatomic, strong, readonly) ELPeripheralModel *peripheralModel;
  230. //Bluetooth proxy(蓝牙代理)
  231. @property (nonatomic, weak) id<ELBluetoothManagerDelegate> delegate;
  232. //Bluetooth wifi proxy(蓝牙wifi代理)
  233. @property (nonatomic, weak) id<ElBleWifiDelegate> bleWifiDelegate;
  234. //Bluetooth Broadcast Device Protocol(蓝牙广播设备协议)
  235. @property (nonatomic, weak) id<ELBleBroadcastDelegate> broadDelegate;
  236. //设置appkey和secret
  237. +(void)setAppKey:(NSString *)key appSecret:(NSString *)secret;
  238. //
  239. +(__kindof ELBluetoothManager * _Nonnull)shareManager;
  240. /**
  241. Get the SDK version number
  242. 获取SDK版本号
  243. */
  244. -(NSString *)sdkVersion;
  245. //Start scanning(开始扫描)
  246. -(void)startScan;
  247. //Stop scanning(停止扫描)
  248. -(void)stopScan;
  249. //Connecting device(连接设备)
  250. -(void)connectPeripheral:(ELPeripheralModel *)peripheralModel;
  251. //Disconnect device(断开设备)
  252. -(void)disconnectPeripheral;
  253. #pragma mark ============ 发送指令的3种方法 ==============
  254. /**
  255. Shortcut method to send A6 data to BLE(发送A6数据给BLE的快捷方法)
  256. @param data The stitched payload part(拼接好的payload部分)
  257. */
  258. -(void)sendCmdToMCUWithA6PayloadData:(NSData *)data;
  259. /**
  260. Shortcut method of sending A7 data to MCU(发送A7数据给MCU的快捷方法)
  261. @param data The stitched payload part(拼接好的payload部分)
  262. @param type Equipment type(设备类型)
  263. */
  264. -(void)sendCmdToMCUWithA7PayloadData:(NSData *)data deviceType:(ELSupportDeviceType)type;
  265. /**
  266. General method of sending data (support data transparent transmission)(发送数据通用方法(支持数据透传))
  267. @param data 数据
  268. */
  269. -(void)sendData:(NSData *)data;
  270. #pragma mark ============ Please rewrite the following methods in the subclass(请在子类重写以下方法) BEGIN==============
  271. -(void)bluetoothUpdateState:(ELBluetoothState)state;
  272. -(void)bluetoothScanPeripherals:(NSArray *)peripherals;
  273. /**
  274. Callback decrypted A7 transparent data (payload part), type device type( 回调解密后的A7透传数据(payload部分),type设备类型)
  275. */
  276. -(void)bluetoothReceiveData:(NSData *)playload deviceType:(ELSupportDeviceType)type;
  277. /**
  278. The special A6 data will only be received by the supported devices, and the complete A6 data (A6 is not encrypted) is passed to the subclass resolution.
  279. 特殊的A6数据,只有支持的设备才会收到,将完整A6数据(A6不加密)传给子类解析
  280. ELSupportDeviceType support:
  281. ELSupportDeviceTypeBodyFatScale
  282. ELSupportDeviceTypeSmartLock
  283. */
  284. -(void)bluetoothBackA6Data:(NSData *)data withClassId:(ELSupportDeviceType)type;
  285. /**
  286. Callback to scan special devices that can be bound, such as door locks(回调扫描到的可以绑定的特殊设备,如门锁)
  287. */
  288. -(void)bluetoothScanCanBindSpecialPeripherals:(NSArray *)peripherals;
  289. //Call back the scanned broadcast device(回调扫描到的广播设备)
  290. -(void)bluetoothScanBroadcastPeripherals:(NSArray *)peripherals;
  291. /**
  292. Callback device basic information(回调设备基本信息)
  293. @param data Device basic information payload data (length is 16 bytes)(设备基本信息payload数据(长度为16个byte))
  294. */
  295. -(void)bluetoothReceiveBasicInfoPayloadData:(NSData *)data;
  296. ///Callback transparent transmission data(回调透传数据)
  297. /// @param data Transparent data(透传数据)
  298. -(void)bluetoothReceivePassData:(NSData *)data;
  299. //Broadcast equipment dedicated(广播设备专用)
  300. /// Broadcast device data
  301. /// @param cid cid
  302. /// @param vid vid
  303. /// @param pid pid
  304. /// @param mac mac
  305. /// @param data custom data(自定义数据)
  306. -(void)bluetoothReceiveBroadcastDataWithCid:(int)cid vid:(int)vid pid:(int)pid mac:(NSString *_Nonnull)mac data:(NSData *_Nonnull)data;
  307. #pragma mark ============ Please rewrite the following methods in the subclass(子类重写方法) END==============
  308. #pragma mark ============ A6 Set or query instructions(设置或查询指令) ==============
  309. /**
  310. Get Bluetooth information(获取蓝牙信息)
  311. @param type ELInetGetCmdType (ELInetGetCmdTypeGetHandshake除外)
  312. */
  313. -(void)getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdType)type;
  314. /**
  315. Set the Bluetooth name(设置蓝牙名称)
  316. @param name Name, less than 14 bytes(名称,小于14个byte)
  317. */
  318. -(void)setBluetoothName:(NSString * _Nonnull)name;
  319. /**
  320. Set the broadcast interval(设置广播间隔时间)
  321. @param interval 20~2000
  322. */
  323. -(void)setBroadcastInterval:(int)interval;
  324. /**
  325. Set the connection interval 10(设置连接间隔)
  326. @param interval The interval range is 20~2000ms.(interval范围是20~2000ms)
  327. @param timeout The timeout range is 1000~6000ms(timeout范围是1000~6000ms)
  328. @param latency The latency range is 0~4(latency范围是0〜4)
  329. */
  330. -(void)setConnectedInterval:(int)interval timeout:(int)timeout Latency:(int)latency;
  331. /**
  332. Set the transmit power(设置发射功率)
  333. @param power The range of power is 0~10(power的范围是0~10)
  334. */
  335. -(void)setTransmittingPower:(int)power;
  336. /**
  337. Set the serial port baud rate(设置串口波特率)
  338. @param rate The range of rate is 0~5(rate的范围是0~5)
  339. 0:9600
  340. 1:19200
  341. 2:38400
  342. 3:57600
  343. 4:115200
  344. 5:921600
  345. */
  346. -(void)setSerialPortbaudRate:(int)rate;
  347. /**
  348. Set the MCU software and hardware version number(设置MCU软硬件版本号)
  349. @param hardware 硬件
  350. @param software 软件
  351. 如果是:S1.1,S11.1,S111.1, .....
  352. 请传:11,111,1111, ....
  353. @param type Manufacturer's own definition(厂家自己定义)
  354. @param year 年
  355. @param month 月
  356. @param day 日
  357. */
  358. -(void)setMCUVersion:(unsigned int)hardware software:(unsigned int)software mcuType:(unsigned int)type year:(unsigned int)year month:(unsigned int)month day:(unsigned int)day;
  359. /**
  360. Set the big endian or little endian of the Mac address in the broadcast manufacturer's custom data.(设置广播厂家自定义数据中Mac地址的大端序或小端序)
  361. @param type type
  362. 0:Little endian (default)(小端序 (默认))
  363. 1:Big endian(大端序)
  364. */
  365. -(void)setSetMACAddressType:(int)type;
  366. /**
  367. Set up the module's service and feature services(设置模块的服务和特征服务)
  368. @param serverUUIDData server
  369. @param charateristicUUIDData charateristic
  370. @param type UUID length:
  371. 0 : 16 bytes(default)
  372. 1:2 bytes
  373. */
  374. -(void)setBluetoothServerUUID:(NSData *)serverUUIDData charateristicUUID:(NSData *)charateristicUUIDData UUIDType:(int)type;
  375. /**
  376. Set the master-slave mode of the module(设置模块的主从模式)
  377. @param type Value:
  378. 0:Slave mode (default)(从机模式(默认))
  379. 1:Host mode(主机模式)
  380. */
  381. -(void)setMCUModel:(int)type;
  382. /**
  383. Set the module's automatic sleep time without connection(设置模块无连接的自动休眠时间)
  384. @param open Automatic sleep flag(自动睡眠标志位):
  385. 0:Do not turn on automatic sleep(不开启自动休眠)
  386. 1:Turn on auto sleep, the module is not connected(开启自动休眠,模块没有连接)
  387. @param time Automatic sleep time (ms)(自动睡眠时间(ms))
  388. @param radio Whether to enable low frequency broadcast after sleep: (unit: ms)(睡眠后是否开启低频广播:(单位:ms))
  389. 0:Not open(不开启)
  390. 1:Open(开启)
  391. @param interval 低频广播间隔时间,20~2000ms
  392. */
  393. -(void)setAutoSleepTimeIsOpen:(BOOL)open autoSleepTime:(unsigned int)time isRadio:(BOOL)radio radioInterval:(int)interval;
  394. /**
  395. Set to sleep(设置进入睡眠)
  396. @param radio Whether to enable low frequency broadcast after sleep: (in ms)(睡眠后是否开启低频广播:(单位 ms))
  397. 0:Not open(不开启)
  398. 1:Open(开启)
  399. @param interval 低频广播间隔时间,20~2000ms
  400. */
  401. -(void)setGotoSleepIsRadio:(BOOL)radio interval:(int)interval;
  402. /**
  403. Set module wake up(设置模块唤醒)
  404. */
  405. -(void)setMCUWakeUp;
  406. /**
  407. Set the current time of the system(设置系统当前时间)
  408. @param enable
  409. NO: In addition to the ability to turn off the time function, you can save part of the current (default)(除能,关闭时间功能,可省部分电流(默认))
  410. YES:Enable, turn on the timer function timer(使能,开启计时功能定时器)
  411. */
  412. -(void)setMCUNowDateWithEnable:(BOOL)enable;
  413. /**
  414. Setting CID, VID, PID(设置CID、VID、PID)
  415. @param setC Whether to set the CID(是否设置CID)
  416. @param setV Whether to set the VID(是否设置VID)
  417. @param setP Whether to set the PID(是否设置PID)
  418. @param cid Product Type ID: Less than 65536(产品类型ID:小于65536)
  419. @param vid Manufacturer ID: less than 65536(厂家ID:小于65536)
  420. @param pid Product ID: Less than 65536(产品ID:小于65536)
  421. */
  422. -(void)setC_V_P_IDWithIsSetCID:(BOOL)setC isSetVID:(BOOL)setV isSetPID:(BOOL)setP CID:(unsigned int)cid VID:(unsigned int)vid PID:(unsigned int)pid;
  423. /**
  424. Set module communication mode
  425. 设置模块通信模式
  426. @param mode communication mode(通信模式)
  427. */
  428. -(void)setCommunicationMode:(ELCommunicationModeType)mode;
  429. /**
  430. Set module restart
  431. 设置模块重启
  432. */
  433. -(void)setMCURestart;
  434. /**
  435. Set factory reset
  436. 设置恢复出厂设置
  437. */
  438. -(void)setFactoryDataReset;
  439. /**
  440. Set the Bluetooth connection status(设置蓝牙连接状态)
  441. @param disconnect Active disconnect flag(主动断开连接标志位)
  442. 1:Disconnect immediately(立刻断开连接)
  443. 0:Not disconnected(不断开连接)
  444. */
  445. -(void)setDisconnected:(BOOL)disconnect;
  446. /**
  447. Send decoding key(发送解码密钥)
  448. @param data The length of the decoding key is 19, the first 16 are keys, and the last 3 are random texts. You need to save this value on the app and MCU to generate a one-time password. (解码密钥的长度为19,前16个为密钥,后3个为随机文,需要在app端和MCU端保存这个值,用于生成一次性密码)
  449. */
  450. - (void)setKeyWithData:(NSData *)data;
  451. /// Request device authorization(请求设备授权)
  452. /// @param interval 时间截
  453. -(void)requestDeviceAuthorization:(NSInteger)interval;
  454. #pragma mark ============ Bluetooth WIFI calling method(蓝牙WIFI调用方法) ==============
  455. /**
  456. WIFI initiate connection and disconnect(WIFI 发起连接、断开连接)
  457. @param connect YES: initiate connection NO: disconnect(YES:发起连接 NO:断开连接)
  458. */
  459. -(void)bleWifiSetupWifiConnect:(BOOL)connect;
  460. /**
  461. Set WIFI access URL(设置WIFI访问URL)
  462. @param url url(Not more than 56chars(不超过56chars))
  463. */
  464. -(void)bleWifiSetWifiURL:(NSString *)url;
  465. /**
  466. Set Wifi access port number(设置Wifi访问端口号)
  467. @param port 端口号
  468. */
  469. -(void)bleWifiSetPort:(int)port;
  470. /**
  471. Set DTIM interval(设置DTIM间隔)
  472. @param interval 间隔
  473. */
  474. -(void)bleWifiSetDTIMInterval:(int)interval;
  475. /**
  476. Set WIFI password(设置WIFI密码)
  477. @param pwd WIFI password (8 ~ 56 chars)(WIFI密码(8~56 个chars))
  478. */
  479. -(void)bleWifiSetWifiPwd:(NSString *)pwd;
  480. /**
  481. Set up connected WIFI(设置连接的WIFI)
  482. @param macData wifi MAC (little endian)(wifi的MAC(小端序))
  483. */
  484. -(void)bleWifiSetConnectWifiMac:(NSData *)macData;
  485. @end
  486. NS_ASSUME_NONNULL_END