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.

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