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.

README.md 6.1KB

iFreshSDK instructions

中文版

The conditions of use

  • iOS 8.0 and above.
  • The Bluetooth version used by the device requires 4.0 and above.
  • Need to add iFreshSDK.framework package dependency;
  • Apply for the key and secret of sdk, application address: http://sdk.aicare.net.cn

    The document description

    1.iFreshSDK.framework (package name raytao.pingwang.iFreshDemo); 2.Add the following code to AppDelegate: ```

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {     // Override point for customization after application launch.     [iFreshSDK setAppKey:@“key” appSecret:@“secret”];     return YES; } ```

    The version update information

    For details, please see the “Good Nutrition SDK Release Notes.doc” document.

Start integration

  1. Import iFreshSDK.framework
  2. Add Bluetooth permissions:      Add “Privacy - Bluetooth Peripheral Usage Description” to the Info.plist file
  3. Discovery equipment
  4. Call the scan method [[iFreshSDK shareManager] bleDoScan];
  5. Compliance with the agreement “BleReturnValueDelegate”
  6. Set the proxy [[iFreshSDK shareManager] setbleReturnValueDelegate:self];
  7. Implementation method: ``` /**
  8. GlobalBLEmodel model: value ble returns the value; *
  9. @param model global Bluetooth model data */
  10. (void)bleReturnValueModel:(iFreshModel*)model;

/**

  • Proxy method triggered by the end switch unit
  • GN_UnitEnum unit enumeration
  • unitChang after switching unit */

  • (void)changeUnitWithBle:(GN_UnitEnum) unitChange;

/**

  • Proxy method for changing Bluetooth connection status
  • GN_BleStatus Bluetooth status enumeration
  • bleStatus current Bluetooth status */

  • (void)bleStatusupdate:(GN_BleStatus)bleStatus;

/**  ble Penetrate Data

 @param data Penetrate data  */ -(void)bluetoothManagerReturePenetrateData:(NSData *)data;

## Communication with equipment:

/*

  • data input */

  • (void)sendDataToBle:(NSData *)data; /**

  • Start scanning, it is recommended to put in the program entrance */

  • (void)bleDoScan;

/**

  • Stop connecting devices */
  • (void)closeBleAndDisconnect;

/**

  • Follow the protocol call */
  • (void)setbleReturnValueDelegate:(id)delegate;

/**

  • insertTheUnit insert unit *
  • @param unit Write units based on GN_UnitEnum enumeration */
  • (void)insertTheUnit:(GN_UnitEnum)unit;

/**

  • Return to zero */
  • (void)zeroWriteBle; /* Setting weight */
  • (void)setWeight:(NSInteger)weight;

/*

  • Set the maximum number of calories in a single item up to 4294967295 */
  • (void)setCalorie:(NSInteger)calories;

/*

  • Set total calories - up to 4294967295 */
  • (void)setTotalCalorie:(NSInteger)toatlCalories;

/*

  • Set total fat */
  • (void)setTotalFat:(NSInteger)fat;

/*

  • Set total protein */
  • (void)setTotalProtein:(NSInteger)protein;

/*

  • Set total carbohydrates */
  • (void)setTotalCarbohydrates:(NSInteger)carbohydertes; /*
  • Set total fat fiber */
  • (void)setTotalFiber:(NSInteger)fiber; /*
  • Set total cholesterol */
  • (void)setTotalCholesterd:(NSInteger)cholesterd; /*
  • Set the total sodium content */
  • (void)setTotalSodium:(NSInteger)sodium;

/*

  • Set the total sugar content */
  • (void)setTotalSugar:(NSInteger)sugar;

/* *Set fat */

  • (void)setFat:(NSInteger)fat;

/* *Set protein */

  • (void)setProtein:(NSInteger)protein; /* *Set carbohydrates */

  • (void)setCarbohydrates:(NSInteger)carbohydertes; /* *Set dietary fiber */

  • (void)setFiber:(NSInteger)fiber; /* *Set cholesterol */

  • (void)setCholesterd:(NSInteger)cholesterd; /* *Set the sodium content */

  • (void)setSodium:(NSInteger)sodium; /* *Set the sugar content */

  • (void)setSugar:(NSInteger)sugar;

/*

  • Shutdown command * */
  • (void)turnOffDevice;

    ## Tools and fat model "iFreshModel"
    The following data is the data returned by the proxy method after the SDK is processed:
    

    // Bluetooth callback value: @property (nonatomic, copy) NSString *value; / / Data in “g” @property (nonatomic, assign) NSInteger gValue; / / Record the last used unit (SDK internal call), @property (nonatomic,copy) NSString *Unit;

To convert data according to the unit, please call the following method: /**

  • g to lb method
  • weightvalue: the weight string passed in g
  • returned data separated by “:” */
  • (NSString *)gTolb:(NSString *)weightValue; /**
  • g to oz method
  • weightvalue: the weight string passed in g */
  • (NSString *)gTooz:(NSString *)weightVlaue; /**
  • lb to g method
  • weightvalue: the weight string passed in lb, please pass the “:” separated data */
  • (NSString *)lbTog:(NSString *)weightVlaue; /**
  • oz to g method
  • weightvalue: the weight string passed in oz */
  • (NSString *)ozTog:(NSString *) weightValue; /**
  • g to kg method
  • weightvalue: the weight string passed in g */
  • (NSString *)gToKg:(NSString *)weightValue; /**
  • g to kg method
  • weightvalue: the weight string passed in g */
  • (NSString *)gToJin:(NSString *)weightValue; /**
  • kg to g method
  • weightvalue: the weight string passed in kg */
  • (NSString *)kgTog:(NSString *)weightValue; /**
  • kg to g method
  • weightvalue: the weight string passed in kilograms */
  • (NSString *)jinTog:(NSString *)weightValue;

/**

  • kg to lb method
  • weightvalue: the weight string passed in kg */
  • (NSString *)kgTolb:(NSString *)weightValue;

    ## Coffee scale timing function
    Send instructions to Bluetooth
    

    //start -(void)bluetoothCoffeeStartTime; //pause -(void)bluetoothCoffeePauseTime; //Reset -(void)bluetoothCoffeeResetTime;

//Countdown starts -(void)bluetoothCoffeeCountdownStartTime:(int)min second:(int)sec;

Receive data sent by Bluetooth

/** *Agent callback supported by coffee scale *workType: Operation instructions for the coffee scale */ -(void)bluetoothManagerCoffeeTimingWork:(BleCoffeeTimingWorkType)workType; /** *Time returned by the coffee scale *min: minute *sec: seconds *countdown: Whether it is countdown, YES: countdown, NO: timing */ -(void)bluetoothManagerCoffeeTime:(int)min second:(int)sec isCountdown:(BOOL)countdown; /**

  • Coffee scale countdown starts *min: minute *sec: second */ -(void)bluetoothManagerCoffeeCountdownStartTime:(int)min second:(int)sec; //APP reply stop alarm command -(void)bluetoothManagerSendStopAlarm; ```