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.
iot_user a32da7eda3 删除验证用的Key和Secret преди 4 години
AiBrushBleSDKDemo 删除验证用的Key和Secret преди 4 години
AiBrushBleSDKBleSDK - iOS_English.docx First version преди 5 години
AiBrushBleSDKBleSDK - iOS中文.docx First version преди 5 години
README.md 修改说明文档 преди 5 години
README_CN.md 123 преди 5 години

README.md

AiBrushBleSDk Intructions

中文版

Version Update time Author Update information
v1.0 2019/07/08 JosonXiong Initial version

A、Conditions of Use

  • 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; ```

C、Connecting device

1.Determine if the phone Bluetooth is available

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;

2.Start scanning

[[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.

3.Stop scanning

    [[AiBrushBleManager shareManager] stopScan];

4.Connecting device

[[AiBrushBleManager shareManager] connectPeripheral:peripheral];

Peripheral is a CBPeripheral object, which can obtain the corresponding attribute of the corresponding model by scanning the callback device.

5.Confirm connection

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.

6.Connection succeeded

After the connection is successful, the light of the device will remain on.

7.Disconnect

   [[AiBrushBleManager shareManager] disconnectPeripheral];

D、Interact with the device

1.Set brushing mode

   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:

  1. 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 }

Specifically as follows

  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];
            }
        }
    }

3.If [AiBrushBleManager shareManager].isWorking == YES, the device is working and the working mode cannot be set at this time.

2. Query work status 

-(void)queryWorkState;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveWorkState:(AiBrushWorkStateModel *)model;

3. Query power status 

-(void)queryBatteryState;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveBatteryStateModel:(AiBrushBatteryStateModel *)model;

4. Switching work status

-(void)changeWorkState;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveWorkState:(AiBrushWorkStateModel *)model;

5. Query device time

-(void)querySystemTime;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveSystemTime:(int)time;

6.Set system time

-(void)setSystemTime;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveSetTimeResult:(int)result;

7. Reading historical data

-(void)queryHistoryData;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveHistoryDataCount:(int)count;
-(void)brushBleManagerReceiveHistoryDataModel:(AiBrushWorkDataModel *)model;

8. Cancel reading historical data

-(void)cancelReadHistoryData;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveCancelReadHistoryDataResult:(int)result;

9. Delete historical data:

-(void)deleteHistoryData;
The corresponding proxy callback method:
-(void)brushBleManagerReceiveDeleteHistoryDataResult:(int)result;

10.Request gear information

-(void)queryGear;
The corresponding proxy callback method:
- (void)brushBleManagerReturnOneGearMode:(NSArray<NSNumber *> *)oneGear twoGearMode:(NSArray<NSNumber *> *)twoGear;

11.Set theid:0~65535, please refer to “蓝牙电动牙刷厂商型号列表”

-(void)setDID:(int)did;
The corresponding proxy callback method:
-(void)brushBleManagerReturnSetDIDResult:(BOOL)result;

12.Set the Bluetooth name

-(void)setName:(NSString *)name;
The corresponding proxy callback method:
-(void)brushBleManagerReturnSetNameResult:(BOOL)result;

Note: The name cannot exceed 16 bytes.

13. OTA upgrade

 @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.

14.Restart the device after the upgrade is successful

- (void)rebootDevice;
The corresponding proxy callback method:
without

E、Other agent callback

1.When the device presses the enter key to establish a connection with the app, the following method will be called back.

 /**
 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;

2.After the device works, it will actively upload the work data, and call back the following methods.

/**
 Callback work data

 @param model Data model
 */
-(void)brushBleManagerReceiveWorkDataModel:(AiBrushWorkDataModel *)model;

3.The device used for testing may call back the following methods

/**
 Reporting Sensor data

 @param model 
 */
-(void)brushBleManagerReceiveGsensorDataModel:(AiBrushGsensorModel *)model;

/**
 Reporting strength data

 @param model 
 */
-(void)brushBleManagerReceiveStrengthDataModel:(AiBrushStrengthModel *)model;

F、Contact us

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