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.

iFreshSDK.h 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. //
  2. // iFreshSDK.h
  3. // iFreshSDK
  4. //
  5. // Created by zhang on 16/9/9.
  6. // Copyright © 2016年 taolei. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "iFreshModel.h"
  10. typedef NS_ENUM(NSUInteger, AiFrushDeviceType) {
  11. AiFrushDeviceTypeUnknown , //When not connected(未连接时)
  12. AiFrushDeviceTypeAC04 , //AC04 scale does not support KG(AC04的秤不支持KG)
  13. AiFrushDeviceTypeAC05 , //Some AC05 scales support KG(部分AC05的秤支持KG)
  14. };
  15. //咖啡定时功能
  16. typedef NS_ENUM(NSUInteger, BleCoffeeTimingWorkType) {
  17. BleCoffeeTimingWorkTypeStart = 1 , //Starting time(正计时开始)
  18. BleCoffeeTimingWorkTypePositivePause = 2 , //Positive timing pause(正计时暂停)
  19. BleCoffeeTimingWorkTypeReset = 3 , //reset(重置)
  20. BleCoffeeTimingWorkTypeCountdownPause = 4 , //Countdown pause(倒计时暂停)
  21. };
  22. typedef enum : NSUInteger {
  23. UNIT_g = 0, //g
  24. UNIT_ml = 1, //
  25. UNIT_lb = 2, //lb:oz
  26. UNIT_oz = 3, //oz
  27. UNIT_kg = 4, //kg
  28. UNIT_jin = 5, //斤
  29. UNIT_LB = 10,//lb
  30. } GN_UnitEnum;
  31. typedef enum : NSUInteger {
  32. bleOpen = 0,
  33. bleOff,
  34. bleConnect,
  35. bleBreak
  36. } GN_BleStatus;
  37. @protocol BleReturnValueDelegate <NSObject>
  38. @optional
  39. /**
  40. ble Penetrate Data(蓝牙透传数据)
  41. @param data Penetrate data(透传数据)
  42. */
  43. -(void)bluetoothManagerReturePenetrateData:(NSData *)data;
  44. /**
  45. * Model model: value ble returns the value (model模型:value ble返还数值)
  46. *
  47. * @param model Global Bluetooth model data(全局蓝牙模型数据)
  48. */
  49. - (void)bleReturnValueModel:(iFreshModel*)model;
  50. /**
  51. * Proxy method triggered by end switching unit(称端切换单位触发的代理方法)
  52. * GN_UnitEnum Unit enumeration(单位枚举)
  53. * unitChang Switched unit(切换后的单位)
  54. */
  55. - (void)changeUnitWithBle:(GN_UnitEnum)unitChange;
  56. /**
  57. * Proxy method for changing Bluetooth connection status(蓝牙连接状态改变的代理方法)
  58. * GN_BleStatus Bluetooth status enumeration(蓝牙状态枚举)
  59. * bleStatus Current Bluetooth status(当前蓝牙状态)
  60. */
  61. - (void)bleStatusupdate:(GN_BleStatus)bleStatus;
  62. /**
  63. *Callback Bluetooth device type(回调蓝牙设备类型)
  64. *deviceType:Bluetooth device type, default AiFrushDeviceTypeUnknown when no device is connected(蓝牙设备类型,未连接设备时,默认AiFrushDeviceTypeUnknown)
  65. */
  66. - (void)bleReturnDeviceType:(AiFrushDeviceType)deviceType;
  67. #pragma mark ============ Coffee scale callback(咖啡秤回调) ==============
  68. /**
  69. *Coffee scale support agent callback(咖啡秤支持的代理回调)
  70. *workType:Coffee scale operation instructions(咖啡秤的操作指令)
  71. */
  72. -(void)bluetoothManagerCoffeeTimingWork:(BleCoffeeTimingWorkType)workType;
  73. /**
  74. *Coffee scale return time(咖啡秤返回的时间)
  75. *min:minute(分)
  76. *sec:second(秒)
  77. *countdown:Whether it is countdown, YES: countdown, NO: timing(是否是倒计时,YES:倒计时,NO:正计时)
  78. */
  79. -(void)bluetoothManagerCoffeeTime:(int )min second:(int)sec isCountdown:(BOOL)countdown;
  80. /**
  81. *Coffee scale countdown starts(咖啡秤倒计时开始)
  82. *min:minute(分)
  83. *sec:second(秒)
  84. */
  85. -(void)bluetoothManagerCoffeeCountdownStartTime:(int )min second:(int)sec;
  86. /**
  87. Bluetooth pause timing callback(蓝牙暂停计时的回调)
  88. @param type Pause type(暂停类型)
  89. @param min minute(分钟)
  90. @param sec second(秒)
  91. */
  92. -(void)bluetoothManagerCoffeePauseType:(BleCoffeeTimingWorkType)type minute:(int)min second:(int)sec;
  93. /**
  94. 设备发送停止报警指令
  95. */
  96. -(void)bluetoothManagerCoffeeReceiveStopAlarm;
  97. @end
  98. @interface iFreshSDK : NSObject
  99. /// Whether to link to Bluetooth(是否链接上蓝牙)
  100. @property (nonatomic, assign) BOOL isBle_Link;
  101. @property (nonatomic, assign, readonly) GN_UnitEnum unitEnum;
  102. @property (nonatomic, assign , readonly) AiFrushDeviceType deviceType;
  103. //
  104. +(void)setAppKey:(NSString *)key appSecret:(NSString *)secret;
  105. /**
  106. * shareManager
  107. */
  108. + (instancetype)shareManager;
  109. /*
  110. * write data to ble(写入数据)
  111. */
  112. - (void)sendDataToBle:(NSData *)data;
  113. /**
  114. * start scaning(开始扫描)
  115. */
  116. - (void)bleDoScan;
  117. /**
  118. * stop connect device(停止连接设备)
  119. */
  120. - (void)closeBleAndDisconnect;
  121. /**
  122. * Follow the protocol call(遵循协议的调用)
  123. */
  124. - (void)setbleReturnValueDelegate:(id<BleReturnValueDelegate>)delegate;
  125. /**
  126. * setting unit(设置单位)
  127. *
  128. * @param unit Write units according to GN_UnitEnum enumeration(根据GN_UnitEnum枚举写入单位)
  129. */
  130. - (void)insertTheUnit:(GN_UnitEnum)unit;
  131. /**
  132. * Return to zero(归零)
  133. */
  134. - (void)zeroWriteBle;
  135. /*
  136. Setting weight(设置重量)
  137. */
  138. - (void)setWeight:(NSInteger)weight;
  139. /*
  140. * Set a single calorie(设置单项卡路里)
  141. */
  142. - (void)setCalorie:(NSInteger)calories;
  143. /*
  144. * Set total calories(设置总卡路里)
  145. */
  146. - (void)setTotalCalorie:(NSInteger)toatlCalories;
  147. /*
  148. * Set total fat(设置总脂肪)
  149. */
  150. - (void)setTotalFat:(NSInteger)fat;
  151. /*
  152. * Set total protein(设置总蛋白质)
  153. */
  154. - (void)setTotalProtein:(NSInteger)protein;
  155. /*
  156. * Set total carbohydrates(设置总碳水化合物)
  157. */
  158. - (void)setTotalCarbohydrates:(NSInteger)carbohydertes;
  159. /*
  160. * Set total fat fiber(设置总脂肪纤维)
  161. */
  162. - (void)setTotalFiber:(NSInteger)fiber;
  163. /*
  164. * Set total cholesterol(设置总胆固醇)
  165. */
  166. - (void)setTotalCholesterd:(NSInteger)cholesterd;
  167. /*
  168. * Set total sodium content(设置总钠含量)
  169. */
  170. - (void)setTotalSodium:(NSInteger)sodium;
  171. /*
  172. * Set total sugar content(设置总糖含量)
  173. */
  174. - (void)setTotalSugar:(NSInteger)sugar;
  175. /*
  176. *Setting fat(设置脂肪)
  177. */
  178. - (void)setFat:(NSInteger)fat;
  179. /*
  180. *Set protein(设置蛋白质)
  181. */
  182. - (void)setProtein:(NSInteger)protein;
  183. /*
  184. *Set carbohydrates(设置碳水化合物)
  185. */
  186. - (void)setCarbohydrates:(NSInteger)carbohydertes;
  187. /*
  188. *Setting dietary fiber(设置膳食纤维)
  189. */
  190. - (void)setFiber:(NSInteger)fiber;
  191. /*
  192. *Set cholesterol(设置胆固醇)
  193. */
  194. - (void)setCholesterd:(NSInteger)cholesterd;
  195. /*
  196. *Set sodium content(设置钠含量)
  197. */
  198. - (void)setSodium:(NSInteger)sodium;
  199. /*
  200. *Setting the sugar content(设置糖含量)
  201. */
  202. - (void)setSugar:(NSInteger)sugar;
  203. /*
  204. * Shutdown command(关机指令)
  205. *
  206. */
  207. - (void)turnOffDevice;
  208. #pragma mark ============ Coffee scale(咖啡秤) ==============
  209. //start the timer(开始计时)
  210. -(void)bluetoothCoffeeStartTime;
  211. //pause(暂停)
  212. -(void)bluetoothCoffeePauseType:(BleCoffeeTimingWorkType)type minute:(int)min second:(int)sec;
  213. //reset(重置)
  214. -(void)bluetoothCoffeeResetTime;
  215. //Countdown starts(倒计时开始)
  216. -(void)bluetoothCoffeeCountdownStartTime:(int)min second:(int)sec;
  217. //APP reply stop alarm command(APP 回复停止报警指令)
  218. -(void)bluetoothManagerSendStopAlarm;
  219. @end