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.

ELSDKHeader.h 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. //
  2. // ELSDKHeader.h
  3. // AILinkSDKDemo
  4. //
  5. // Created by iot_user on 2019/5/10.
  6. // Copyright © 2019 IOT. All rights reserved.
  7. //
  8. #ifndef ELSDKHeader_h
  9. #define ELSDKHeader_h
  10. #import "ELExSupportDeviceType.h"
  11. //Bluetooth command type(蓝牙指令类型)
  12. typedef NS_ENUM(NSUInteger, ELInetBleDataType) {
  13. ELInetBleDataPackHead_A6 = 0xA6,
  14. ELInetBleDataPackTail_6A = 0x6A,
  15. ELInetBleDataPackHead_A7 = 0xA7,
  16. ELInetBleDataPackTail_7A = 0x7A,
  17. };
  18. //The type of instruction acquired by Inet(Inet获取的指令类型)
  19. typedef NS_ENUM(NSUInteger, ELInetGetCmdType) {
  20. ELInetGetCmdTypeGetName = 0x02, //-Get the Bluetooth name(获取蓝牙名称)
  21. ELInetGetCmdTypeGetBroadcastInterval = 0x06, //-Get broadcast interval (unit: ms)(获取广播间隔时间(单位:ms))
  22. ELInetGetCmdTypeGetConnectedInterval = 0x08, //-Get Bluetooth connection interval(获取蓝牙连接间隔)
  23. ELInetGetCmdTypeGetTransmittingPower = 0x0A, //-Get Bluetooth transmit power(获取蓝牙发射功率)
  24. ELInetGetCmdTypeGetSerialPortbaudRate = 0x0C, //-Get the serial port baud rate(获取串口波特率)
  25. ELInetGetCmdTypeGetMACAddress = 0x0D, //-Read MAC address value(读取MAC地址值)
  26. ELInetGetCmdTypeGetBMVersion = 0x0E, //-Read the BM module software and hardware version number(读取BM模块软硬件版本号)
  27. ELInetGetCmdTypeGetMCUVersion = 0x10, //-Obtain the MCU software and hardware version number(获取MCU软硬件版本号)
  28. ELInetGetCmdTypeGetMACAddressType = 0x12, //-Get the big endian or little endian of the Mac address in the broadcast manufacturer's custom data(获取广播厂家自定义数据中Mac地址的大端序或小端序)
  29. ELInetGetCmdTypeGetUUID = 0x14, //-Get service and feature UUID(获取服务和特征UUID)
  30. ELInetGetCmdTypeGetMCUMode = 0x16, //-Get master-slave mode(获取主从模式)
  31. ELInetGetCmdTypeGetAutoSleepTime = 0x18, //-Get automatic sleep time value(获取自动睡眠时间值)
  32. ELInetGetCmdTypeGetMCUDate = 0x1C, //-Get the current time of the system(获取系统当前时间)
  33. ELInetGetCmdTypeGetC_V_P_ID = 0x1E, //-Read CID, VID, PID(读取CID、VID、PID)
  34. ELInetGetCmdTypeGetCommunicationMode = 0x20, //-Get module communication mode(获取模块通信模式)
  35. ELInetGetCmdTypeGetConnectState = 0x26, //-Get Bluetooth and WiFi connection status(获取蓝牙和WiFi连接状态)
  36. ELInetGetCmdTypeGetConnectStateFailCode = 0xAB, //- WiFi connection error 连接失败原因
  37. ELInetGetCmdTypeGetBatteryState = 0x28, //-Get MCU battery status(获取MCU电池状态)
  38. ELInetGetCmdTypeGetHandshake = 0x24, //-Encrypted handshake data returned by Bluetooth(蓝牙返回的加密的握手数据)
  39. ELInetGetCmdTypeGetBodyFatScaleA6Data = 0x2B, //-Body fat scale 0x2B stands for A6 protocol (see the second level instructions for details)(体脂秤0x2B代表A6协议(具体见二级指令))
  40. ELInetGetCmdTypeReadDeviceSupportUnit = 0x2C, //-APP reads the MCU end unit instruction(APP读取MCU端单位指令)
  41. ELInetGetCmdTypeGetSendKeyState = 0x31, //-APP reads the result of sending the decoding key(APP读取下发解码秘钥的结果)
  42. ELInetGetCmdTypeGetSmartLockA6Data = 0x34, //-Door lock 0x34 represents the A6 protocol (see the second level command for details)(门锁0x34代表A6协议(具体见二级指令))
  43. ELInetGetCmdTypeGetBasicInfoData = 0x36, //Obtain basic device information data(获取设备基本信息数据)
  44. ELInetGetCmdTypeSyncMCUNowDate = 0x38, //MCU request sync the current time of the system(MCU请求设置手机时间给MCU)
  45. ELInetGetCmdTypeGetBMVersionPro = 0x46, //增强版-Read the BM module software and hardware version number(读取BM模块软硬件版本号)
  46. #pragma mark ============ Begin 蓝牙Wifi ==============
  47. ELInetGetCmdTypeBleWifiGetNearbyWifi = 0x80, //Get nearby Wifi(获取附近Wifi)
  48. ELInetGetCmdTypeBleWifiReceiveWifiName = 0x81, //Reply to wifi name(回复wifi名字)
  49. ELInetGetCmdTypeBleWifiReceiveWifiMac = 0x82, //Reply to wifi mac(回复wifi mac)
  50. ELInetGetCmdTypeBleWifiReceiveScanResult = 0x83, //Reply to scan Wifi result(回复扫描Wifi结果)
  51. ELInetGetCmdTypeBleWifiGetWifiMac = 0x85, //Get Wifi Mac address(获取Wifi的Mac地址)
  52. ELInetGetCmdTypeBleWifiGetWifiPwd = 0x87, //Get Wifi password(获取Wifi密码)
  53. ELInetGetCmdTypeBleWifiGetDTIMInterval = 0x8A, //Get DTIM interval(获取DTIM间隔)
  54. ELInetGetCmdTypeBleWifiSetIpAddress = 0x8B, //Set the access ip address(设置访问的ip地址
  55. ELInetGetCmdTypeBleWifiGetURL = 0x8C, //Get visited sites(获取访问的网站)
  56. ELInetGetCmdTypeBleWifiSetPort = 0x8D, //set acces port number
  57. ELInetGetCmdTypeBleWifiGetPort = 0x8E, //Get access port number(获取访问的端口号)
  58. ELInetGetCmdTypeBleWifiGetSNNumber = 0x93, //Get SN number (session code:deviceId)(获取SN号(会话码:设备ID))
  59. ELInetGetCmdTypeBleWifiName = 0x94, //获取wifi名称
  60. ELInetGetCmdTypeBleWifiSetPathAddress = 0x96, //Set access path(设置访问的路径
  61. ELInetGetCmdTypeBleWifiGetPathAddress = 0x97, //get access path
  62. #pragma mark ============End 蓝牙Wifi ==============
  63. ELInetGetCmdTypeRequestAuthorize = 0x7F, //Request device authorization (请求设备授权)
  64. ELInetGetCmdTypeToothbrushA6Data = 0xC0, //A6 data for toothbrush(牙刷专用A6数据,详情请见协议的2级指令)(See the second order for details)
  65. #pragma mark ============ mqtt ==============
  66. ELInetGetCmdTypeCheckMqttState = 0xC5, //查询mqtt链接状态 CMD=0xC5
  67. ELInetGetDevOfflineHistory = 0xF1, //获取离线历史记录
  68. };
  69. //Instruction type set by Inet(Inet设置的指令类型)
  70. typedef NS_ENUM(NSUInteger, ELInetSetCmdType) {
  71. ELInetSetCmdTypeSetName = 0x01, //Set the broadcast name(设置广播名称)
  72. ELInetSetCmdTypeSetBroadcastInterval = 0x05, //Set the broadcast interval(设置广播间隔时间)
  73. ELInetSetCmdTypeSetConnectedInterval = 0x07, //Set the connection interval(设置连接间隔)
  74. ELInetSetCmdTypeSetTransmittingPower = 0x09, //Set the transmit power(设置发射功率)
  75. ELInetSetCmdTypeSetSerialPortbaudRate = 0x0B, //Set the serial port baud rate(设置串口波特率)
  76. ELInetSetCmdTypeSetMCUVersion = 0x0F, //Set the MCU software and hardware version number(设置MCU软硬件版本号)
  77. ELInetSetCmdTypeSetMACAddressType = 0x11, //Set the big endian or little endian of the Mac address in the broadcast manufacturer's custom data.(设置广播厂家自定义数据中Mac地址的大端序或小端序)
  78. ELInetSetCmdTypeSetUUID = 0x13, //Set the module's service and feature UUID(设置模块的服务和特征UUID)
  79. ELInetSetCmdTypeSetMCUMode = 0x15, //Set the master-slave mode of the module(设置模块的主从模式)
  80. ELInetSetCmdTypeSetAutoSleepTime = 0x17, //Set the module's automatic sleep time without connection(设置模块无连接的自动休眠时间)
  81. ELInetSetCmdTypeSetGotoSleep = 0x19, //Set to sleep(设置进入睡眠)
  82. ELInetSetCmdTypeSetMCUWakeUp = 0x1A, //Set module wake up(设置模块唤醒)
  83. ELInetSetCmdTypeSyncBleNowDate = 0x1B, //Set the current time of the system(设置手机时间给蓝牙模块Type:1B、1C)
  84. ELInetSetCmdTypeSetC_V_P_ID = 0x1D, //Set CID, VID, PID(设置CID、VID、PID)
  85. ELInetSetCmdTypeSetCommunicationMode = 0x1F, //Set module serial port mode, I2C mode, SPI mode(设置模块串口模式、I2C模式、SPI模式)
  86. ELInetSetCmdTypeSetMCURestart = 0x21, //Set module restart(设置模块重启)
  87. ELInetSetCmdTypeSetFactoryDataReset = 0x22, //Set factory reset(设置恢复出厂设置)
  88. ELInetSetCmdTypeSetHandshake = 0x23, //Encrypted handshake data returned by Bluetooth(蓝牙返回的加密的握手数据)
  89. ELInetSetCmdTypeSetConnectState = 0x25, //Set the Bluetooth connection status(设置蓝牙连接状态)
  90. ELInetSetCmdTypeSetMCUPowerState = 0x27, //上报电池状态
  91. ELInetSetCmdTypeSetKey = 0x31, //APP sends the decoding key(APP下发解码秘钥)
  92. ELInetSetCmdTypeSetSmartLockA6Data = 0x34, //Door lock 0x34 represents the A6 protocol (see the second level command for details)(门锁0x34代表A6协议(具体见二级指令))
  93. ELInetSetCmdTypeSetBasicInfoData = 0x35, //Obtain basic device information data(获取设备基本信息数据)
  94. ELInetSetCmdTypeSyncMCUNowDate = 0x37, //Sync the current time of the system(设置手机时间给MCU)
  95. #pragma mark ============ 蓝牙Wifi ==============
  96. ELInetSetCmdTypeBleWifiSetWifiMac = 0x84, //设置WIFI Mac地址
  97. ELInetSetCmdTypeBleWifiSetWifiPwd = 0x86, //设置WIFI 密码
  98. ELInetSetCmdTypeBleWifiSetConnectWifi = 0x88, //设置设备连接WIFI
  99. ELInetSetCmdTypeBleWifiSetDTIMInterval = 0x89, //设置DTIM间隔
  100. ELInetSetCmdTypeBleWifiSetWifiURL = 0x8B, //设置访问的URL
  101. ELInetSetCmdTypeBleWifiSetWifiPort = 0x8D, //设置端口号
  102. };
  103. //Response to Bluetooth after device(给蓝牙进行设置后的响应)
  104. typedef NS_ENUM(NSUInteger, ELSetBluetoothResponseType) {
  105. ELSetBluetoothResponseTypeSuccess =0 , //success(成功)
  106. ELSetBluetoothResponseTypeFailure =1 , //failure(失败)
  107. ELSetBluetoothResponseTypeNoSupport =2 , //not support(不支持)
  108. };
  109. //Communication mode(通信模式)
  110. typedef NS_ENUM(NSInteger, ELCommunicationModeType) {
  111. ELCommunicationModeTypeSerialPort = 0, //Serial port mode(串口模式)
  112. ELCommunicationModeTypeI2C = 1, //I2C mode(I2C模式)
  113. ELCommunicationModeTypeSPI = 2, //SPI mode( SPI模式)
  114. };
  115. //Battery charge status (电池充电状态)
  116. typedef NS_ENUM(NSUInteger, ELBatteryChargingState) {
  117. ELBatteryChargingStateDefault = 0x00, //No charging (default)(没有充电(默认))
  118. ELBatteryChargingStateWorking = 0x01, //charging(充电中)
  119. ELBatteryChargingStateComplete = 0x02, //full charge(充满电)
  120. ELBatteryChargingStateException = 0x03, //Abnormal charging(充电异常)
  121. ELBatteryChargingStatePowerLow = 0x04, //Low battery(电量过低)
  122. };
  123. //CID,VID,PID
  124. struct ELDIDStruct {
  125. ELSupportDeviceType deviceType; //CID
  126. int vendorID; //VID
  127. int productID; //PID
  128. };
  129. //Battery charging state and power structur(电池充电状态和电量的结构体)
  130. struct ELBatteryStruct {
  131. ELBatteryChargingState state; //charging(充电状态)
  132. int power; //Electricity(电量)(0—100%)
  133. };
  134. //Connection interval structure(连接间隔时间的结构体)
  135. struct ELConnectIntervalStruct {
  136. int interval; //Connection interval, unit: ms; range: 20-2000(连接间隔,单位:ms;范围:20-2000)
  137. int latency; //Slave delay, value: 0-4(从设备延时,取值:0-4)
  138. int timeout; //Connection timeout, unit: ms; Range: 1000~6000(连接超时,单位:ms; 范围: 1000~6000)
  139. };
  140. struct ELUUIDStruct {
  141. char *serviceUUID; //Service UUID(服务UUID)
  142. char *writeUUID; //For APP to send data to MCU (write)(用于 APP 下发数据到 MCU(write))
  143. char *notifyUUID; //Used for MCU data transfer to APP (notify)(用于 MCU 数据传输到 APP (notify))
  144. };
  145. struct ELAutoSleepTimeStruct {
  146. int sleepTime; //Automatic sleep time, unit: s(自动睡眠时间,单位:s)
  147. int open; //Whether to enable low frequency broadcast after sleep: 0: not open, 1: open(睡眠后是否开启低频广播: 0:不开启 ,1:开启)
  148. int interval; //Low frequency broadcast interval, unit: ms; range 20~2000(低频广播间隔,单位 :ms ;范围 20~2000)
  149. };
  150. //WiFi连接状态
  151. typedef NS_ENUM(NSUInteger, BleWiFiConnectState) {
  152. /// 0:没配网,没有连接,0: No connection
  153. BleWiFiConnectStateNoWiFi = 0,
  154. /// 1:尝试连接热点,但是失败1: Attempt to connect to the hotspot, but failed
  155. BleWiFiConnectStateConnectFail = 1 ,
  156. /// 2:连接热点,热点无网络,2: Connected to the hotspot, the hotspot has no network
  157. BleWiFiConnectStateNoNetwork = 2 ,
  158. /// 3:连接热点,热点有网络,3: Connected to the hotspot, the hotspot has a network
  159. BleWiFiConnectStateSuccess = 3 ,
  160. /// 4:有热点信息,未连接,4: There is hotspot information, not connected
  161. BleWiFiConnectStateNoConnect = 4 ,
  162. /// 5:ap信号差,连接失败
  163. BleWiFiConnectStatePoorApSignal = 5 ,
  164. /// 6:密码错误
  165. BleWiFiConnectStatePasswordWrong = 6 ,
  166. /// 7:获取不到IP,连接失败
  167. BleWiFiConnectStateCantGetIP = 7 ,
  168. };
  169. //连网失败原因,对于温湿度计来说,如果 BleWiFiConnectState 状态为1,则需要判断该值,牙刷的话byte位够长,可以直接判断BleWiFiConnectState
  170. typedef NS_ENUM(NSUInteger, BleWiFiConnectServerFaildState) {
  171. BleWiFiConnectServerFaildState_Unknow = 0 ,
  172. BleWiFiConnectServerFaildState_ApSignal = 1 ,
  173. BleWiFiConnectServerFaildState_PwdWrong = 2 ,
  174. BleWiFiConnectServerFaildState_CantGetIP = 3 ,
  175. };
  176. struct ELMCUStateStruct {
  177. int connectState; //Connection status: 0: no connection 1: connected(蓝牙连接状态: 0:无连接 1:已连接 2:配对完成)
  178. BleWiFiConnectState wifiState; //
  179. int workState; //Working status: 0: Wake 1: Go to sleep 2: Module is ready(工作状态: 0:唤醒 1:进入休眠 2:模块准备就绪)
  180. BleWiFiConnectServerFaildState faildState;
  181. };
  182. //重构
  183. //BLE状态
  184. typedef NS_ENUM(Byte, WMBleState) {
  185. WMBleStateNoConnection = 0,//无连接
  186. WMBleStateConnected = 1,//已连接
  187. WMBleStatePaired = 2,//配对完成
  188. WMBleStateMax = 0xFF
  189. };
  190. //wifi状态
  191. typedef NS_ENUM(Byte, WMWiFiState) {
  192. WMWiFiStateNotSetAP = 0, //未配置AP
  193. WMWiFiStateConnectAPFail = 1, //连接AP失败,连接时密码错误、AP信号不好、主动断开都会是这个状态
  194. WMWiFiStateConnectServerFail = 2, //与服务器通讯失败
  195. WMWiFiStateConnectedAP = 3, //成功连接上AP
  196. WMWiFiStateConnectingAP = 4, //正在连接AP
  197. WMWiFiStateMax = 0xFF
  198. };
  199. //工作状态
  200. typedef NS_ENUM(Byte, WMWorkState) {
  201. WMWorkStateWakeup = 0,//唤醒
  202. WMWorkStateSleep = 1,//进入休眠
  203. WMWorkStateReady = 2,//模块准备就绪
  204. WMWorkStateMax = 0xFF
  205. };
  206. //WiFi连接失败原因
  207. typedef NS_ENUM(Byte, WMWorkStateFailCode) {
  208. WMWorkStateFailCodeUnknow = 0,//未知原因
  209. WMWorkStateFailCodeAPSignalBad = 1,//AP信号差
  210. WMWorkStateFailCodeWrongPassword = 2,//密码错误
  211. WMWorkStateFailCodeNoIP = 3,//获取不到IP
  212. WMWorkStateFailCodeMax = 0xFF
  213. };
  214. typedef struct {
  215. WMBleState bleState;
  216. WMWiFiState wifiState;
  217. WMWorkState workState;
  218. WMWorkStateFailCode failCode;
  219. } ELWMStateStruct, ELWMStateStruct;
  220. #pragma mark - AiLink unit
  221. /** Type key of unit string(单位字符串的type key) */
  222. #define ELDeviceUnitTypeKey @"type"
  223. /** supportUnit key */
  224. #define ELDeviceUnitSupportUnitKey @"supportUnit"
  225. /** Ailink unit */
  226. typedef NS_ENUM(NSInteger, ELDeviceUnitType) {
  227. /** Weight(重量) */
  228. ELDeviceUnitType_Weight = 1 ,
  229. /** length(长度) */
  230. ELDeviceUnitType_Height = 2 ,
  231. /** temperature(温度) */
  232. ELDeviceUnitType_Temperature = 3 ,
  233. /** Pressure(血压) */
  234. ELDeviceUnitType_BloodPressure = 4 ,
  235. /** Tire pressure(轮胎胎压压力) */
  236. ELDeviceUnitType_Pressure = 5 ,
  237. /**Blood sugar(血糖单位)*/
  238. ELDeviceUnitType_BloodSugar = 6 ,
  239. /**体积(体积单位)*/
  240. ELDeviceUnitType_Volume = 7 ,
  241. /**营养秤专用单位*/
  242. ELDeviceUnitType_Nutrition = 8 ,
  243. };
  244. #define AiLinkBleWeightUnit_KG_Str @"kg"
  245. #define AiLinkBleWeightUnit_Jin_Str @"斤"
  246. #define AiLinkBleWeightUnit_LB_OZ_Str @"lb:oz"
  247. #define AiLinkBleWeightUnit_OZ_Str @"oz"
  248. #define AiLinkBleWeightUnit_ST_LB_Str @"st:lb"
  249. #define AiLinkBleWeightUnit_G_Str @"g"
  250. #define AiLinkBleWeightUnit_LB_Str @"lb"
  251. #define AiLinkBleWeightUnit_ML_Str @"ml"
  252. #define AiLinkBleWeightUnit_FL_OZ_Str @"fl.oz"
  253. #define AiLinkBleWeightUnit_CC_Str @"cc"
  254. #define AiLinkBleWeightUnit_L_Str @"l"
  255. #define AiLinkBleWeightUnit_GAL_Str @"gal"
  256. #define AiLinkBleWeightUnitStrDic(key) [@{AiLinkBleWeightUnit_KG_Str:@(ELDeviceWeightUnit_KG),AiLinkBleWeightUnit_Jin_Str:@(ELDeviceWeightUnit_JIN),AiLinkBleWeightUnit_LB_OZ_Str:@(ELDeviceWeightUnit_LB_OZ),AiLinkBleWeightUnit_OZ_Str:@(ELDeviceWeightUnit_OZ),AiLinkBleWeightUnit_ST_LB_Str:@(ELDeviceWeightUnit_ST_LB),AiLinkBleWeightUnit_G_Str:@(ELDeviceWeightUnit_G),AiLinkBleWeightUnit_LB_Str:@(ELDeviceWeightUnit_LB)}[key] integerValue]
  257. //#define AiLinkBleWeightUnitDic @{@(ELDeviceWeightUnit_KG):AiLinkBleWeightUnit_KG_Str,@(ELDeviceWeightUnit_JIN):AiLinkBleWeightUnit_Jin_Str,@(ELDeviceWeightUnit_LB_OZ):AiLinkBleWeightUnit_LB_OZ_Str,@(ELDeviceWeightUnit_OZ):AiLinkBleWeightUnit_OZ_Str,@(ELDeviceWeightUnit_ST_LB):AiLinkBleWeightUnit_ST_LB_Str,@(ELDeviceWeightUnit_G):AiLinkBleWeightUnit_G_Str,@(ELDeviceWeightUnit_LB):AiLinkBleWeightUnit_LB_Str}
  258. #define AiLinkBleWeightUnitDic @{@(ELDeviceWeightUnit_KG):AiLinkBleWeightUnit_KG_Str,@(ELDeviceWeightUnit_JIN):AiLinkBleWeightUnit_Jin_Str,@(ELDeviceWeightUnit_LB_OZ):AiLinkBleWeightUnit_LB_OZ_Str,@(ELDeviceWeightUnit_OZ):AiLinkBleWeightUnit_OZ_Str,@(ELDeviceWeightUnit_ST_LB):AiLinkBleWeightUnit_ST_LB_Str,@(ELDeviceWeightUnit_G):AiLinkBleWeightUnit_G_Str,@(ELDeviceWeightUnit_LB):AiLinkBleWeightUnit_LB_Str, @(ELDeviceWeightUnit_ML):AiLinkBleWeightUnit_ML_Str, @(ELDeviceWeightUnit_FLOZ):AiLinkBleWeightUnit_FL_OZ_Str, @(ELDeviceWeightUnit_CC):AiLinkBleWeightUnit_CC_Str, @(ELDeviceWeightUnit_L):AiLinkBleWeightUnit_L_Str, @(ELDeviceWeightUnit_GAL):AiLinkBleWeightUnit_GAL_Str}
  259. /** AiLink Weight unit(体重单位)*/
  260. typedef NS_ENUM(NSInteger, ELDeviceWeightUnit) {
  261. /** kg */
  262. ELDeviceWeightUnit_KG = 0x00 ,
  263. /** 斤 */
  264. ELDeviceWeightUnit_JIN = 0x01 ,
  265. /** lb:oz */
  266. ELDeviceWeightUnit_LB_OZ = 0x02 ,
  267. /** oz */
  268. ELDeviceWeightUnit_OZ = 0x03 ,
  269. /** st:lb */
  270. ELDeviceWeightUnit_ST_LB = 0x04 ,
  271. /** g */
  272. ELDeviceWeightUnit_G = 0x05 ,
  273. /** lb */
  274. ELDeviceWeightUnit_LB = 0x06 ,
  275. //体积 咖啡秤有ml单位 所以协议增加体积部分
  276. /** ml */
  277. ELDeviceWeightUnit_ML = 0x10 ,
  278. /** fl.oz */
  279. ELDeviceWeightUnit_FLOZ = 0x20 ,
  280. /** cc */
  281. ELDeviceWeightUnit_CC = 0x30 ,
  282. /** l */
  283. ELDeviceWeightUnit_L = 0x40 ,
  284. /** gal */
  285. ELDeviceWeightUnit_GAL = 0x50 ,
  286. /** Unsupported unit */
  287. ELDeviceWeightUnit_Fail = 0xFF ,
  288. };
  289. #define AiLinkBleHeightUnit_CMStr @"cm"
  290. #define AiLinkBleHeightUnit_InchStr @"inch"//@"in"//
  291. #define AiLinkBleHeightUnit_FeetStr @"feet"//@"ft"//
  292. #define AiLinkBleHeightUnitDic @{@(ELDeviceHeightUnit_CM):AiLinkBleHeightUnit_CMStr,@(ELDeviceHeightUnit_Inch):AiLinkBleHeightUnit_InchStr,@(ELDeviceHeightUnit_FT_IN):AiLinkBleHeightUnit_FeetStr}
  293. /** AiLink Length unit(长度单位) */
  294. typedef NS_ENUM(NSInteger, ELDeviceHeightUnit) {
  295. /** cm */
  296. ELDeviceHeightUnit_CM = 0x00 ,
  297. /** inch */
  298. ELDeviceHeightUnit_Inch = 0x01 ,
  299. /** feet:inch */
  300. ELDeviceHeightUnit_FT_IN = 0x02 ,
  301. //
  302. ELDeviceHeightUnit_M = 0x03 ,
  303. /** Unsupported unit */
  304. ELDeviceHeightUnit_Fail = 0xFF ,
  305. };
  306. #define AiLinkBleSpeedUnit_M_S @"m/s"
  307. #define AiLinkBleSpeedUnit_KM_H @"km/h"
  308. #define AiLinkBleSpeedUnit_FT_Min @"ft/min"
  309. #define AiLinkBleSpeedUnit_Knots @"knots"
  310. #define AiLinkBleSpeedUnit_MPH @"MPH"
  311. #define AiLinkBleSpeedUnitDic @{@(ELDeviceSpeedUnit_M_S):AiLinkBleSpeedUnit_M_S,@(ELDeviceSpeedUnit_KM_H):AiLinkBleSpeedUnit_KM_H,@(ELDeviceSpeedUnit_FT_Min):AiLinkBleSpeedUnit_FT_Min,@(ELDeviceSpeedUnit_Knots):AiLinkBleSpeedUnit_Knots,@(ELDeviceSpeedUnit_MPH):AiLinkBleSpeedUnit_MPH}
  312. /** AiLink速度单位 */
  313. typedef NS_ENUM(NSInteger, ELDeviceSpeedUnit) {
  314. /** m/s */
  315. ELDeviceSpeedUnit_M_S = 0x00 ,
  316. /** km/h */
  317. ELDeviceSpeedUnit_KM_H = 0x01 ,
  318. /** ft/min */
  319. ELDeviceSpeedUnit_FT_Min = 0x02 ,
  320. /** knots(节,海里/小时,1节=1海里/小时=1.852公里/小时) */
  321. ELDeviceSpeedUnit_Knots = 0x03 ,
  322. /** MPH(1 迈= 1.609344 千米/小时) */
  323. ELDeviceSpeedUnit_MPH = 0x04 ,
  324. /** Unsupported unit */
  325. ELDeviceSpeedUnit_Fail = 0xFF ,
  326. };
  327. #define AiLinkBleTempUnit_CStr @"℃"
  328. #define AiLinkBleTempUnit_FStr @"℉"
  329. #define AiLinkBleTempUnitDic @{@(ELDeviceTemperatureUnit_C):AiLinkBleTempUnit_CStr,@(ELDeviceTemperatureUnit_F):AiLinkBleTempUnit_FStr}
  330. /** AiLink Temperature unit(温度单位)*/
  331. typedef NS_ENUM(NSInteger, ELDeviceTemperatureUnit) {
  332. /** ℃ */
  333. ELDeviceTemperatureUnit_C = 0x00 ,
  334. /** ℉ */
  335. ELDeviceTemperatureUnit_F = 0x01 ,
  336. /** Unsupported unit */
  337. ELDeviceTemperatureUnit_Fail = 0xFF ,
  338. };
  339. #define AiLinkBloodUnit_mmHgStr @"mmHg"
  340. #define AiLinkBloodUnit_kPaStr @"kPa"
  341. #define AiLinkBloodUnitDic @{\
  342. @(ELDeviceBloodPressureUnit_mmhg):AiLinkBloodUnit_mmHgStr,\
  343. @(ELDeviceBloodPressureUnit_kPa):AiLinkBloodUnit_kPaStr\
  344. }
  345. /** AiLink Blood pressure unit(血压单位) */
  346. typedef NS_ENUM(NSInteger, ELDeviceBloodPressureUnit) {
  347. /** mmhg */
  348. ELDeviceBloodPressureUnit_mmhg = 0x00 ,
  349. /** kPa */
  350. ELDeviceBloodPressureUnit_kPa ,
  351. /** Unsupported unit */
  352. ELDeviceBloodPressureUnit_Fail ,
  353. };
  354. #define AiLinkBlePressureUnit_BarStr @"Bar"
  355. #define AiLinkBlePressureUnit_PsiStr @"Psi"
  356. #define AiLinkBlePressureUnit_KpaStr @"Kpa"
  357. #define AiLinkBlePressureUnitDic @{@(ELDevicePressureUnit_Bar):AiLinkBlePressureUnit_BarStr,@(ELDevicePressureUnit_Psi):AiLinkBlePressureUnit_PsiStr,@(ELDevicePressureUnit_kPa):AiLinkBlePressureUnit_KpaStr}
  358. /** AiLink Tire tire pressure unit(轮胎胎压单位) */
  359. typedef NS_ENUM(NSInteger, ELDevicePressureUnit) {
  360. /** kPa */
  361. ELDevicePressureUnit_kPa = 0x00 ,
  362. /** Psi */
  363. ELDevicePressureUnit_Psi = 0x01 ,
  364. /** Bar */
  365. ELDevicePressureUnit_Bar = 0x02 ,
  366. /** Unsupported unit */
  367. ELDevicePressureUnit_Fail ,
  368. };
  369. #define AiLinkBleBloodSugarUnit_mmolStr @"mmol/L"
  370. #define AiLinkBleBloodSugarUnit_mgStr @"mg/dL"
  371. #define AiLinkBleBloodSugarUnitDic @{@(ELDeviceBloodSugarUnit_mmol_L):AiLinkBleBloodSugarUnit_mmolStr,@(ELDeviceBloodSugarUnit_mg_dL):AiLinkBleBloodSugarUnit_mgStr,}
  372. typedef NS_ENUM(NSUInteger, ELDeviceBloodSugarUnit) {
  373. ELDeviceBloodSugarUnit_mmol_L = 0x01,//mmol/L 毫摩尔/升
  374. ELDeviceBloodSugarUnit_mg_dL = 0x02,//mg/dL 毫克/分升
  375. ELDeviceBloodSugarUnit_Fail ,
  376. };
  377. #define AiLinkBleVolumeUnit_mlStr @"ml"
  378. #define AiLinkBleVolumeUnit_flozStr @"fl.oz"
  379. #define AiLinkBleVolumeUnit_ccStr @"cc"
  380. #define AiLinkBleVolumeUnit_lStr @"l"
  381. #define AiLinkBleVolumeUnit_galStr @"gal"
  382. #define AiLinkBleVolumeUnitDic @{@(ELDeviceVolumeUnit_ML):AiLinkBleVolumeUnit_mlStr, @(ELDeviceVolumeUnit_FLOZ):AiLinkBleVolumeUnit_flozStr, @(ELDeviceVolumeUnit_CC):AiLinkBleVolumeUnit_ccStr, @(ELDeviceVolumeUnit_L):AiLinkBleVolumeUnit_lStr, @(ELDeviceVolumeUnit_GAL):AiLinkBleVolumeUnit_galStr}
  383. /** AiLink Temperature unit(温度单位)*/
  384. typedef NS_ENUM(NSInteger, ELDeviceVolumeUnit) {
  385. /** ml */
  386. ELDeviceVolumeUnit_ML = 0x00 ,
  387. /** fl.oz */
  388. ELDeviceVolumeUnit_FLOZ = 0x01 ,
  389. /** cc */
  390. ELDeviceVolumeUnit_CC = 0x02 ,
  391. /** l */
  392. ELDeviceVolumeUnit_L = 0x03 ,
  393. /** gal */
  394. ELDeviceVolumeUnit_GAL = 0x04 ,
  395. /** Unsupported unit */
  396. ELDeviceVolumeUnit_Fail = 0xFF ,
  397. };
  398. /** AiLink Nutrition unit(营养秤专用单位)*/
  399. typedef NS_ENUM(NSInteger, ELDeviceNutritionUnit) {
  400. /** g */
  401. ELDeviceNutritionUnit_G = 0x00 ,
  402. /** ml */
  403. ELDeviceNutritionUnit_ML = 0x01 ,
  404. /** lb.oz */
  405. ELDeviceNutritionUnit_LBOZ = 0x02 ,
  406. /** oz */
  407. ELDeviceNutritionUnit_OZ = 0x03 ,
  408. /** kg */
  409. ELDeviceNutritionUnit_KG = 0x04 ,
  410. /** jin */
  411. ELDeviceNutritionUnit_JIN = 0x05 ,
  412. /** 牛奶ml */
  413. ELDeviceNutritionUnit_MILK_ML = 0x06 ,
  414. /** 水ml */
  415. ELDeviceNutritionUnit_WATER_ML = 0x07 ,
  416. /** 牛奶floz */
  417. ELDeviceNutritionUnit_MILK_FLOZ = 0x08 ,
  418. /** 水floz */
  419. ELDeviceNutritionUnit_WATER_FLOZ = 0x09 ,
  420. /** lb. */
  421. ELDeviceNutritionUnit_LB = 0x0A ,
  422. /** Unsupported unit */
  423. ELDeviceNutritionUnit_Fail = 0xFF ,
  424. };
  425. #pragma mark ============ 枚举 ==============
  426. typedef NS_ENUM(NSUInteger, ELBluetoothState) {
  427. ELBluetoothStateUnavailable, //Bluetooth is not available(蓝牙不可用)0
  428. ELBluetoothStateAvailable, //Bluetooth available(蓝牙可用)1
  429. ELBluetoothStateStopScan, //Stop scanning(停止扫描)2
  430. ELBluetoothStateScaning, //Scanning(正在扫描)3
  431. ELBluetoothStateWillConnect, //Will connect(将要连接)4
  432. ELBluetoothStateDidConnect, //Already connected(已经连接)5
  433. ELBluetoothStateConnectFail, //Connection error(连接出错)6
  434. ELBluetoothStateDidDiscoverCharacteristics, //Peripheral feature callback(外设特征回调)7
  435. ELBluetoothStateDidDisconnect, //Disconnect(断开连接)8
  436. ELBluetoothStateDidValidationPass, //approved(通过验证)9
  437. ELBluetoothStateFailedValidation, //Failed verification(未通过验证)10
  438. ELBluetoothStateUnauthorized = 0XFF , //No Bluetooth permission (没有蓝牙权限)
  439. };
  440. //sex(性别)
  441. typedef NS_ENUM(NSUInteger, ELBluetoothUserSex) {
  442. ELBluetoothUserSex_Woman = 0x00,//female(女)
  443. ELBluetoothUserSex_Man = 0x01,//male(男)
  444. };
  445. //设备授权结果
  446. typedef NS_ENUM(NSUInteger, ELBluetoothDeviceAuthorizeResult) {
  447. ELBluetoothDeviceAuthorizeResultNoAuth =0,//No(没有)
  448. ELBluetoothDeviceAuthorizeResultAuthorized ,//Authorized(已经授权)
  449. ELBluetoothDeviceAuthorizeResultNoNeed ,//No authorization required(不需要授权)
  450. ELBluetoothDeviceAuthorizeResultSuccess ,//Authorization succeeded(授权成功)
  451. };
  452. #endif /* ELSDKHeader_h */