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.6KB

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