|
пре 4 година | |
---|---|---|
AiBrushBleSDKDemo | пре 4 година | |
AiBrushBleSDKBleSDK - iOS_English.docx | пре 5 година | |
AiBrushBleSDKBleSDK - iOS中文.docx | пре 5 година | |
README.md | пре 5 година | |
README_CN.md | пре 5 година |
Version | Update time | Author | Update information |
---|---|---|---|
v1.0 | 2019/07/08 | JosonXiong | Initial version |
- Minimum version iOS 8.0
The Bluetooth version used by the device requires 4.0 and above
B、Start using
[1] Apply for the key and secret of sdk, application address: http://sdk.aicare.net.cn;
[2] Set “Privacy-Bluetooth Always Usage Description” in the info.plist file;
[3] Import AiBrushBleSDK.framework into the Xcode project;
[4] Add the following code to AppDelegate: ```
import
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [AiBrushBleManager setAppKey:@“key” appSecret:@“secret”]; return YES; }
5.Import #import <AiBrushBleSDK/AiBrushBleManager.h> in the controller.m you need to use, and follow the <AiBrushBleManagerDelegate> protocol. 6.Set proxy
[AiBrushBleManager shareManager].delegate = self;
1.Implementing proxy method
/** Callback Bluetooth current status
@param state Bluetooth status */ -(void)brushBleManagerUpdateBleState:(AiBrushBleState)state;
/** Callback to all peripherals scanned
@param peripheralList Peripheral list */ -(void)brushBleManagerScanedPeripherals:(NSArray *)peripheralList;
/** Reporting setup mode results
@param result */ -(void)brushBleManagerReceiveSetModeResult:(AiBrushSetModeResult)result;
/** Reporting work status
@param model Working state model */ -(void)brushBleManagerReceiveWorkState:(AiBrushWorkStateModel *)model;
/** Report power status
@param model Power state model */ -(void)brushBleManagerReceiveBatteryStateModel:(AiBrushBatteryStateModel *)model;
/** Confirm receipt of disconnected Bluetooth connection request */ -(void)brushBleManagerReceiveDisconnectResult;
/** Reporting device time
@param time */ -(void)brushBleManagerReceiveSystemTime:(int)time;
/** Return to set device time results @param result 1:Set device time to succeed 2:Setting device time failed */ -(void)brushBleManagerReceiveSetTimeResult:(int)result;
/** Returns the number of historical data
@param count Total historical data */ -(void)brushBleManagerReceiveHistoryDataCount:(int)count;
/** Cancel the reading of historical data operation results
@param result 1:Cancel the read successfully 2:Cancel read failed */ -(void)brushBleManagerReceiveCancelReadHistoryDataResult:(int)result;
/** Delete historical data
@param result 1:successfully 2:failed */ -(void)brushBleManagerReceiveDeleteHistoryDataResult:(int)result;
/** Callback historical data
@param model Historical data model */ -(void)brushBleManagerReceiveHistoryDataModel:(AiBrushWorkDataModel *)model;
/** Callback work data
@param model Data model */ -(void)brushBleManagerReceiveWorkDataModel:(AiBrushWorkDataModel *)model;
/** Reporting Sensor data
@param model */ -(void)brushBleManagerReceiveGsensorDataModel:(AiBrushGsensorModel *)model;
/** Reporting strength data
@param model */ -(void)brushBleManagerReceiveStrengthDataModel:(AiBrushStrengthModel *)model;
/** Report button to confirm the app connection status 1----Key action confirmation App connection is valid, 2----App requires button confirmation, 3----App is valid without key confirmation @param state */ -(void)brushBleManagerReceiveConnectState:(int)state; /** Callback brushing mode gear @param oneGear @param twoGear */
- (void)brushBleManagerReturnOneGearMode:(NSArray *)oneGear twoGearMode:(NSArray *)twoGear;
/** Set DID results @param result YES:successfully NO:failed */ -(void)brushBleManagerReturnSetDIDResult:(BOOL)result;
/** Set the Name result @param result YES:successfully NO:failed */ -(void)brushBleManagerReturnSetNameResult:(BOOL)result;
/** Return to OTA upgrade progress
@param progress */ -(void)brushBleManagerReturnOTAUpdateProgress:(double)progress;
/** Return OTA upgrade results
@param result */ -(void)brushBleManagerOTAUpdateResult:(BOOL)result; ```
Proxy method:
/**
Callback Bluetooth current status
@param state Bluetooth status
*/
-(void)brushBleManagerUpdateBleState:(AiBrushBleState)state;
Or
[AiBrushBleManager shareManager].state;
Get the current Bluetooth status, Also available
[AiBrushBleManager shareManager].isOn;
Get current Bluetooth enabled is available;
[[AiBrushBleManager shareManager] startScan];
Callback method:
/**
Callback to all peripherals scanned
@param peripheralList Peripheral list
*/
-(void)brushBleManagerScanedPeripherals:(NSArray<AiBrushPeripheralModel *> *)peripheralList;
The scanned device can be obtained by this proxy callback method.
[[AiBrushBleManager shareManager] stopScan];
[[AiBrushBleManager shareManager] connectPeripheral:peripheral];
Peripheral is a CBPeripheral object, which can obtain the corresponding attribute of the corresponding model by scanning the callback device.
When the app first requests to connect to the device, it needs to confirm the device. Please press the button within 15 seconds to confirm.
After the connection is successful, the light of the device will remain on.
[[AiBrushBleManager shareManager] disconnectPeripheral];
For details on the mode settings, please see the agreement description.
@param byte Must pass 4 bytes of data
-(void)setBrushModeWithByte:(Byte[_Nonnull])byte;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveSetModeResult:(AiBrushSetModeResult)result;
Note:
- Before device mode, you need to determine what device type is [AiBrushBleManager shareManager].versionType, and also get the mode supported by the device [AiBrushBleManager shareManager].oneGearArray and [AiBrushBleManager shareManager].twoGearArray, if mode = 0x07 , 0x08, 0x09, 0x0A, 0x0B, you need to first determine whether the first mode of the toothbrush is supported. If it is supported, set {mode, 0x00, 0x00, time}. If not, judge [AiBrushBleManager shareManager].versionType is AiBrushVersionTypeBY01 , AiBrushVersionTypeBY02, AiBrushVersionTypeBY03, AiBrushVersionTypeBY04, if it is the above type, set {0x05, modeID, 0x00, time}; otherwise [AiBrushBleManager shareManager].versionType is AiBrushVersionTypeBY05, AiBrushVersionTypeBY06, AiBrushVersionTypeBYOther, then set {0x06, frequency, duty cycle, time }
if (mode == 0x06){
Byte b[4] = {0x06,0x02,0x03,0x16};
[[AiBrushBleManager shareManager] setBrushModeWithByte:b];
}else{
if ([[AiBrushBleManager shareManager].oneGearArray containsObject:[NSNumber numberWithChar:mode]]) {
Byte dataByte[] = {mode,0x00,0x00,0x16};
[[AiBrushBleManager shareManager] setBrushModeWithByte:dataByte];
}else{
if (mode == 0x07 || mode == 0x08 || mode == 0x09 || mode == 0x0A || mode == 0x0B ) {
if ([AiBrushBleManager shareManager].versionType == AiBrushVersionTypeBY01 || [AiBrushBleManager shareManager].versionType == AiBrushVersionTypeBY02 || [AiBrushBleManager shareManager].versionType == AiBrushVersionTypeBY03 || [AiBrushBleManager shareManager].versionType == AiBrushVersionTypeBY04) {
Byte modeIDByte=0x00;
if (mode == 0x07) {
modeIDByte = 0x01;
}else if (mode == 0x08){
modeIDByte = 0x02;
}else if (mode == 0x09){
modeIDByte = 0x03;
}else if (mode == 0x0A){
modeIDByte = 0x04;
}else if (mode == 0x0B){
modeIDByte = 0x05;
}
Byte dataByte[] = {0x05,modeIDByte,0x00,0x16};
[[AiBrushBleManager shareManager] setBrushModeWithByte:dataByte];
}else{
Byte dataByte[] = {mode,0x00,0x00,0x16};
[[AiBrushBleManager shareManager] setBrushModeWithByte:dataByte];
}
}else{
Byte dataByte[] = {mode,0x00,0x00,0x16};
[[AiBrushBleManager shareManager] setBrushModeWithByte:dataByte];
}
}
}
-(void)queryWorkState;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveWorkState:(AiBrushWorkStateModel *)model;
-(void)queryBatteryState;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveBatteryStateModel:(AiBrushBatteryStateModel *)model;
-(void)changeWorkState;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveWorkState:(AiBrushWorkStateModel *)model;
-(void)querySystemTime;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveSystemTime:(int)time;
-(void)setSystemTime;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveSetTimeResult:(int)result;
-(void)queryHistoryData;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveHistoryDataCount:(int)count;
-(void)brushBleManagerReceiveHistoryDataModel:(AiBrushWorkDataModel *)model;
-(void)cancelReadHistoryData;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveCancelReadHistoryDataResult:(int)result;
-(void)deleteHistoryData;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveDeleteHistoryDataResult:(int)result;
-(void)queryGear;
The corresponding proxy callback method:
- (void)brushBleManagerReturnOneGearMode:(NSArray<NSNumber *> *)oneGear twoGearMode:(NSArray<NSNumber *> *)twoGear;
-(void)setDID:(int)did;
The corresponding proxy callback method:
-(void)brushBleManagerReturnSetDIDResult:(BOOL)result;
-(void)setName:(NSString *)name;
The corresponding proxy callback method:
-(void)brushBleManagerReturnSetNameResult:(BOOL)result;
Note: The name cannot exceed 16 bytes.
@param fileStr file path
*/
- (void)OTAUpdate:(NSURL *)fileStr;
The corresponding proxy callback method:
-(void)brushBleManagerReturnOTAUpdateProgress:(double)progress;
-(void)brushBleManagerOTAUpdateResult:(BOOL)result;
Note: Not all devices support OTA upgrades, but devices with the “FEF5” feature service are supported.
- (void)rebootDevice;
The corresponding proxy callback method:
without
/**
Report button to confirm the app connection status
1----Key action confirmation App connection is valid, 2----App requires button confirmation, 3----App is valid without key confirmation
@param state
*/
-(void)brushBleManagerReceiveConnectState:(int)state;
/**
Callback work data
@param model Data model
*/
-(void)brushBleManagerReceiveWorkDataModel:(AiBrushWorkDataModel *)model;
/**
Reporting Sensor data
@param model
*/
-(void)brushBleManagerReceiveGsensorDataModel:(AiBrushGsensorModel *)model;
/**
Reporting strength data
@param model
*/
-(void)brushBleManagerReceiveStrengthDataModel:(AiBrushStrengthModel *)model;
Thank you for using the product network SDK for product development. If you have any questions during the use, please feel free to contact us. Helping companies achieve rapid and intelligent product is our driving force. Web: www.inet-tek.com Email : iot.support@inet-tek.com