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 27KB

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