iOS AILinkBleSDK - 蓝牙SDK
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
王庭 ec782e430d 1.修改切换wifi秤的ip地址无效问题。 3 anos atrás
AILinkBleSDKDemo 1.修改切换wifi秤的ip地址无效问题。 3 anos atrás
AILinkBleSDKDemo.xcodeproj 1.修改切换wifi秤的ip地址无效问题。 3 anos atrás
AILinkBleSDKDemoUITests First version 5 anos atrás
READMD_CN.md 去除SDK验证 4 anos atrás
README.md 去除SDK验证 4 anos atrás

README.md

AILinkBleSDK instructions

English

Release Notes

Version number Update time Author Update information
v1.0.2_20200407 2020-04-09 JosonXiong Initialization
v1.0.3_20200421 2020-04-21 JosonXiong 1. Modified the problem that the state cannot be synchronized after switching Bluetooth on and off for many times;2Add the transparent transmission method of the parent class “ELBluetoothManager”, please call it in the subclass

Conditions of Use

  1. iOS 9.0 and above;
  2. Bluetooth 4.0 and above.

Preparation before use

  1. Add “Privacy-Bluetooth Always Usage Description” to the info.plist file;
  2. Download and unzip AILinkBleSDK; download address:
  3. Import the AILinkBleSDK.framework file into the project;

Start using

A. Public part

The ELBluetoothManager of the SDK is the parent class of the SDK, which is divided into the following public parts:

1. Public Properties

@property (nonatomic, assign, readonly) BOOL isOn;
//Bluetooth status
@property (nonatomic, assign, readonly) ELBluetoothState state;
//version number
@property (nonatomic, copy, readonly) NSString *bmVersion;
/**
 Save the model corresponding to the currently connected device
 */
@property (nonatomic, strong, readonly) ELPeripheralModel *peripheralModel;
//Bluetooth proxy
@property (nonatomic, weak) id<ELBluetoothManagerDelegate> delegate;
//Bluetooth wifi proxy
@property (nonatomic, weak) id<ElBleWifiDelegate> bleWifiDelegate;

2. Public methods

//
+(__kindof ELBluetoothManager * _Nonnull)shareManager;
/**
 Get the SDK version number
 */
-(NSString *)sdkVersion;

//Start scanning
-(void)startScan;
//Stop scanning
-(void)stopScan;
//Connecting device
-(void)connectPeripheral:(ELPeripheralModel *)peripheralModel;
//Disconnect device
-(void)disconnectPeripheral;

#pragma mark ============ 3 ways to send instructions ==============
/**
 Shortcut method to send A6 data to BLE
 @param data The stitched payload part
 */
-(void)sendCmdToMCUWithA6PayloadData:(NSData *)data;
/**
 Shortcut method of sending A7 data to MCU
 @param data The stitched payload part
 @param type Equipment type
 */
-(void)sendCmdToMCUWithA7PayloadData:(NSData *)data deviceType:(ELSupportDeviceType)type;

/**
 General method of sending data (support data transparent transmission)

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

#pragma mark ============ Please rewrite the following methods in the subclass BEGIN==============

-(void)bluetoothUpdateState:(ELBluetoothState)state;

-(void)bluetoothScanPeripherals:(NSArray *)peripherals;


/**
Callback decrypted A7 transparent data (payload part), type device type
 */
-(void)bluetoothReceiveData:(NSData *)playload deviceType:(ELSupportDeviceType)type;

/**
 The special A6 data will only be received by the supported devices, and the complete A6 data (A6 is not encrypted) is passed to the subclass resolution.

 ELSupportDeviceType support:
 ELSupportDeviceTypeBodyFatScale
 ELSupportDeviceTypeSmartLock
 */
-(void)bluetoothBackA6Data:(NSData *)data withClassId:(ELSupportDeviceType)type;

/**
 Callback to scan special devices that can be bound, such as door locks
 */
-(void)bluetoothScanCanBindSpecialPeripherals:(NSArray *)peripherals;

/**
 Callback device basic information

 @param data Device basic information payload data (length is 16 bytes)
 */
-(void)bluetoothReceiveBasicInfoPayloadData:(NSData *)data;

#pragma mark ============ Please rewrite the following methods in the subclass END==============



#pragma mark ============ A6 Set or query instructions ==============

/**
 Get Bluetooth information

 @param type ELInetGetCmdType (Except ELInetGetCmdTypeGetHandshake)
 */
-(void)getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdType)type;

/**
 Set the Bluetooth name

 @param name Name, less than 14 bytes
 */
-(void)setBluetoothName:(NSString * _Nonnull)name;

/**
 Set the broadcast interval

 @param interval 20~2000
 */
-(void)setBroadcastInterval:(int)interval;


/**
 Set the connection interval 10

 @param interval The interval range is 20~2000ms.
 @param timeout  The timeout range is 1000~6000ms
 @param latency  The latency range is 0~4
 */
-(void)setConnectedInterval:(int)interval timeout:(int)timeout Latency:(int)latency;

/**
 Set the transmit power

 @param power The range of power is 0~10
 */
-(void)setTransmittingPower:(int)power;

/**
 Set the serial port baud rate

 @param rate The range of rate is 0~5
 0:9600
 1:19200
 2:38400
 3:57600
 4:115200
 5:921600
 */
-(void)setSerialPortbaudRate:(int)rate;

/**
 Set the MCU software and hardware version number

 @param hardware 
 @param software 
For example: S1.1, S11.1, S111.1, ...
Please pass: 11,111,1111, ...
 @param type Manufacturer's own definition
 @param year 
 @param month 
 @param day 
 */
-(void)setMCUVersion:(unsigned int)hardware software:(unsigned int)software mcuType:(unsigned int)type year:(unsigned int)year month:(unsigned int)month day:(unsigned int)day;

/**
 Set the big endian or little endian of the Mac address in the broadcast manufacturer's custom data.

 @param type type
 0:Little endian 
 1:Big endian
 */
-(void)setSetMACAddressType:(int)type;

/**
 Set up the module's service and feature services

 @param serverUUIDData server
 @param charateristicUUIDData charateristic
 @param type UUID length:
 0 : 16 bytes(default)
 1:2 bytes
 */
-(void)setBluetoothServerUUID:(NSData *)serverUUIDData charateristicUUID:(NSData *)charateristicUUIDData UUIDType:(int)type;

/**
 Set the master-slave mode of the module

 @param type Value:
 0:Slave mode (default)(从机模式(默认))
 1:Host mode(主机模式)
 */
-(void)setMCUModel:(int)type;

/**
 Set the module's automatic sleep time without connection

 @param open Automatic sleep flag:
 0:Do not turn on automatic sleep
 1:Turn on auto sleep, the module is not connected
 @param time Automatic sleep time (ms)
 @param radio Whether to enable low frequency broadcast after sleep: (unit: ms)
 0:Not open
 1:Open
 @param interval Low frequency broadcast interval,20~2000ms
 */
-(void)setAutoSleepTimeIsOpen:(BOOL)open autoSleepTime:(unsigned int)time isRadio:(BOOL)radio radioInterval:(int)interval;

/**
 Set to sleep

 @param radio Whether to enable low frequency broadcast after sleep: (in ms)
 0:Not open
 1:Open
 @param interval Low frequency broadcast interval,20~2000ms
 */
-(void)setGotoSleepIsRadio:(BOOL)radio interval:(int)interval;

/**
 Set module wake up
 */
-(void)setMCUWakeUp;

/**
 Set the current time of the system
 @param enable
 NO: In addition to the ability to turn off the time function, you can save part of the current (default)
 YES:Enable, turn on the timer function timer
 */
-(void)setMCUNowDateWithEnable:(BOOL)enable;

/**
 Setting CID, VID, PID

 @param setC Whether to set the CID
 @param setV Whether to set the VID
 @param setP Whether to set the PID
 @param cid Product Type ID: Less than 65536
 @param vid Manufacturer ID: less than 65536
 @param pid Product ID: Less than 65536
 */
-(void)setC_V_P_IDWithIsSetCID:(BOOL)setC isSetVID:(BOOL)setV isSetPID:(BOOL)setP CID:(unsigned int)cid VID:(unsigned int)vid PID:(unsigned int)pid;

/**
 Set module communication mode

 @param mode communication mode
 */
-(void)setCommunicationMode:(ELCommunicationModeType)mode;

/**
 Set module restart
 */
-(void)setMCURestart;

/**
 Set factory reset
 */
-(void)setFactoryDataReset;

/**
 Set the Bluetooth connection status

 @param disconnect Active disconnect flag
 1:Disconnect immediately
 0:Not disconnected
 */
-(void)setDisconnected:(BOOL)disconnect;

/**
 Send decoding key

 @param data The length of the decoding key is 19, the first 16 are keys, and the last 3 are random texts. You need to save this value on the app and MCU to generate a one-time password. 
 */
- (void)setKeyWithData:(NSData *)data;



#pragma mark ============ Bluetooth WIFI calling method ==============

/**
 WIFI initiate connection and disconnect

 @param connect YES: initiate connection NO: disconnect
 */
-(void)bleWifiSetupWifiConnect:(BOOL)connect;

/**
 Set WIFI access URL
 
 @param url url
 */
-(void)bleWifiSetWifiURL:(NSString *)url;

/**
 Set Wifi access port number
 
 @param port 
 */
-(void)bleWifiSetPort:(int)port;

/**
 Set DTIM interval

 @param interval 
 */
-(void)bleWifiSetDTIMInterval:(int)interval;

/**
 Set WIFI password
 
 @param pwd WIFI password 
 */
-(void)bleWifiSetWifiPwd:(NSString *)pwd;

/**
 Set up connected WIFI

 @param macData wifi MAC (little endian)
 */
-(void)bleWifiSetConnectWifiMac:(NSData *)macData;

3.Public agreement

//MARK:Bluetooth Common Protocol
@protocol ELBluetoothManagerDelegate <NSObject>
@optional

//Callback Bluetooth status
-(void)bluetoothManagerUpdateBleState:(ELBluetoothState)state;
//Callback to scanned device
-(void)bluetoothManagerScanedPeripherals:(NSArray<ELPeripheralModel *> *_Nonnull)peripherals;
//Special devices that can be bound in the callback, such as door locks
-(void)bluetoothManagerScanedCanBindSpecialPeripherals:(NSArray<ELPeripheralModel *> *_Nonnull)peripherals;
//Callback decrypted transparent data (A7 decrypted payload data)
-(void)bluetoothManagerReceiveData:(NSData *_Nonnull)data deviceType:(ELSupportDeviceType)type;

/**
 Callback transparent transmission data

 @param data Transparent transmission of data (this data cannot start with A6 or A7)
 */
-(void)bluetoothManagerReceivePassData:(NSData *_Nullable)data;


#pragma mark ============ A6 Set or query the callback of the instruction execution result ==============
/**
 Set or query the callback of the instruction execution result

 @param type Type of setting 
 @param result Set result
 */
-(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result;

/**
 Query module status callback

 @param stateStrct 
 */
-(void)bluetoothManagerReceiveMCUConnectedState:(struct ELMCUStateStruct)stateStrct;

/**
 Query the callback of the communication mode

 @param type communication mode
 */
-(void)bluetoothManagerReceiveCommunicationMode:(ELCommunicationModeType)type;

/**
 Query the callback of automatic sleep time

 @param sleetStrct Automatic sleep time
 */
-(void)bluetoothManagerReceiveAutoSleepTime:(struct ELAutoSleepTimeStruct)sleetStrct;

/**
 Query master-slave mode callback

 @param mode 
 0:Slave mode
 1:Host mode
 */
-(void)bluetoothManagerReceiveMCUMode:(int)mode;

/**
 Query the callback of UUID information

 @param uuid ELUUIDStruct
 */
-(void)bluetoothManagerReceiveUUID:(struct ELUUIDStruct)uuid;

/**
 Query the callback of the MAC address size endian

 @param type 
 0:Little endian
 1:Big endian 
 */
-(void)bluetoothManagerReceiveMacAddressType:(int)type;

/**
 Query the callback of the Bluetooth serial port baud rate

 @param rate Serial port baud rate
 0:9600
 1:19200
 2:38400
 3:57600
 4:115200
 5:921600
 */
-(void)bluetoothManagerReceiveSerialPostBaudRate:(int)rate;

/**
 Query the callback of Bluetooth transmit power

 @param dbm Transmit power
 */
-(void)bluetoothManagerReceiveTransmittingPower:(int)dbm;

/**
 Query the callback of the Bluetooth connection interval

 @param intervalStrct connection interval
 */
-(void)bluetoothManagerReceiveConnectInterval:(struct ELConnectIntervalStruct)intervalStrct;

/**
 Query the callback of the Bluetooth name

 @param name Bluetooth name
 */
-(void)bluetoothManagerReceiceName:(NSString *_Nullable)name;

/**
 Query the callback of the Bluetooth broadcast interval

 @param interval broadcast interval
 */
-(void)bluetoothManagerReceiveBroadcastInterval:(int)interval;

/**
 Query the callback of the Bluetooth MAC address

 @param macAddress MAC
 */
-(void)bluetoothManagerReceiveMACAddress:(NSString *_Nonnull)macAddress;

/**
 Query the callback of the software and hardware version number of the BM module

 @param bmVersion BM module software and hardware version number
 */
-(void)bluetoothManagerReceiveBMVersion:(NSString *_Nonnull)bmVersion;

/**
 Query the callback of the MCU software and hardware version number
 
 @param mcuVersion Callback of MCU software and hardware version number
 */
-(void)bluetoothManagerReceiveMCUVersion:(NSString *_Nonnull)mcuVersion;

/**
 Query the callback of Bluetooth time

 @param date yyyy-MM-dd HH:mm:ss
 @param effective Time is invalid
 0:effective
 1:invalid
 */
-(void)bluetoothManagerReceiveBluetoothDate:(NSString * _Nonnull)date effective:(BOOL)effective;

/**
 Query CID, VID, PID callback

 @param did CID,VID,PID
 */
-(void)bluetoothManagerReceiveDID:(struct ELDIDStruct)did;

/**
 Query the callback of the battery status

 @param battery Structure of battery charge status and charge percentage
 */
-(void)bluetoothManagerReceiveBattery:(struct ELBatteryStruct)battery;

/**
 * Query the callback of the device support unit
 
 */
- (void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *_Nullable)weightArray
                                                 Height:(NSArray<NSNumber *> *_Nullable)heightArray
                                            Temperature:(NSArray<NSNumber *> *_Nullable)temperatureArray
                                          BloodPressure:(NSArray<NSNumber *> *_Nullable)bloodPressureArray
                                               Pressure:(NSArray<NSNumber *> *_Nullable)pressureArray;


/**
 Set the result of the decoding key

 @param result 
 */
-(void)bluetoothManagerReceiveSetKeyResult:(BOOL)result;

4.WiFi protocol
//MARK:Bluetooth Wifi protocol
@protocol ElBleWifiDelegate <NSObject>

@optional

/**
 Callback Wifi details

 @param model 
 */
-(void)bleWifiReceiveWifiDetailModel:(ELBleWifiDetailModel *_Nonnull)model;

/**
Scan nearby wifi results

 @param count Number of nearby wifi
 */
-(void)bleWifiReceiveScanedWifiCount:(int)count;

/**
 Callback Wifi MAC address

 @param macData mac
 */
-(void)bleWifiReceiveWifiMacData:(NSData *_Nullable)macData;

/**
Callback WIFI password

 @param pwd password
 */
-(void)bleWifiReceiveWifiPwd:(NSString *_Nonnull)pwd;

/**
 Get DTIM interval (unit: ms)

 @param interval Interval (unit: ms)
 */
-(void)bleWifiReceiveWifiDTIMInterval:(NSInteger)interval;

/**
 Returns the visited URL

 @param url url
 */
-(void)bleWifiReceiveWifiAccessURL:(NSString *_Nonnull)url;

/**
  Call back wifi port number

 @param port 
 */
-(void)bleWifiReceiveWifiPort:(int)port;

/**
 Set or query the callback of the instruction execution result
 Only supports Bluetooth Wifi partial enumeration
 @param type Type of setting 
 @param result Set result
 */
-(void)bleWifiReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result;

/**
 Get session code

 @param code Session code (when it is 0, it does not exist)
 */
-(void)bleWifiReceiveWifiSNCode:(int)code;

5.Explanation

There is a lot of content, you need to call what you need to call, if you are accessing the specified device, you can view four to eleven.

B、Define the protocol through yourself

1.Import the header file of the parent or child class

(1)Taking body fat scale as an example, import the header file #import (2)Set proxy:

[ELBodyFatScaleBleManager shareManager].bodyFatScaleDelegate = self;
[ELBodyFatScaleBleManager shareManager].delegate  =self;

2.Connect the device

(1)Scan to device

 [[ELBodyFatScaleBleManager shareManager] startScan];

(2)Select device and initiate connection

-(void)bodyFatScaleManagerScanDevices:(NSArray<ELBodyFatScaleDeviceModel *> *)scaleDevices{
    [[ELBodyFatScaleBleManager shareManager] connectPeripheral:device];
}

3.Send transparent data

  [[ELBodyFatScaleBleManager shareManager] sendData:data];

4.Receive transparent data

//MARK:Receive transparent transmission data (data that does not comply with the AILink protocol, customers who need to do transparent transmission can parse the data according to their own protocol, transparent transmission data cannot start with “A6” or “A7”)

-(void)bluetoothManagerReceivePassData:(NSData *)data{
    NSLog(@"bluetoothManagerReceivePassData = %@",data.description);
    
}

5.Explanation

All devices support transparent transmission. While using the AILink protocol, the custom protocol enables transparent transmission to achieve some additional functions.

1.Inherit

@interface SubBleManager : ELBluetoothManager

2.Set singleton

+(instancetype)shareManager;

3.Implement the parent class method

-(void)bluetoothUpdateState:(ELBluetoothState)state;

-(void)bluetoothScanPeripherals:(NSArray *)peripherals;

/**
Callback decrypted A7 transparent data (payload part), type device type( 回调解密后的A7透传数据(payload部分),type设备类型)
 */
-(void)bluetoothReceiveData:(NSData *)playload deviceType:(ELSupportDeviceType)type;

/**
 The special A6 data will only be received by the supported devices, and the complete A6 data (A6 is not encrypted) is passed to the subclass resolution.
 特殊的A6数据,只有支持的设备才会收到,将完整A6数据(A6不加密)传给子类解析
 ELSupportDeviceType support:
 ELSupportDeviceTypeBodyFatScale
 ELSupportDeviceTypeSmartLock
 */
-(void)bluetoothBackA6Data:(NSData *)data withClassId:(ELSupportDeviceType)type;

/**
 Callback to scan special devices that can be bound, such as door locks(回调扫描到的可以绑定的特殊设备,如门锁)
 */
-(void)bluetoothScanCanBindSpecialPeripherals:(NSArray *)peripherals;

/**
 Callback device basic information(回调设备基本信息)

 @param data Device basic information payload data (length is 16 bytes)(设备基本信息payload数据(长度为16个byte))
 */
-(void)bluetoothReceiveBasicInfoPayloadData:(NSData *)data;
///Callback transparent transmission data(回调透传数据)
/// @param data Transparent data(透传数据)
-(void)bluetoothReceivePassData:(NSData *)data{
    //Parsing transparent transmission data(解析透传数据)
}

4.Define your own agreement

@protocol SubBleManagerDelegate <NSObject>

5.Implement custom methods

/// Send data to mcu
/// @param data Protocol corresponding data
-(void)subBleSendA6Data:(NSData *)data;

/// Send data to Bluetooth
/// @param payload Partial data of the agreement
-(void)subBleSendA7Data:(NSData *)payload;

6.Transfer

Obey the agreement-“Set up the agent-” Connect the device-“Send and receive data

7.Explanation

Your own protocol name cannot have the same name as the protocol in the parent class. For specific implementation, please refer to Demo

D、Integrated baby scale

1.Import header files and follow the agreement

#import <AILinkBleSDK/ELBabyScaleBleManager.h>
@interface BabyScaleConnectViewController ()<ELBluetoothManagerDelegate,BabyScaleBleDelegate>

2.Set proxy

[ELBabyScaleBleManager shareManager].babyScaleDelegate = self;
    [ELBabyScaleBleManager shareManager].delegate  =self;

3.Scan and connect the device

[[ELBabyScaleBleManager shareManager] startScan];
-(void)babyScaleManagerScanDevices:(NSArray<ELBabyScaleDeviceModel *> *)babyScaleDevices{
    [[ELBabyScaleBleManager shareManager] connectPeripheral:device]

}

4.send data

(1)Get BM version number

[[ELBabyScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetBMVersion)];

(2)Set Bluetooth name

[[ELBabyScaleBleManager shareManager] setBluetoothName:@"AILink"];

(3)Send Hold

[[ELBabyScaleBleManager shareManager] changeHold:YES];

(4)Send peeled

[[ELBabyScaleBleManager shareManager] changeHold:NO];

(5)Edit unit

[[ELBabyScaleBleManager shareManager] changeHeightUnit:(ELDeviceHeightUnit_CM) AndWeightUnit:(ELDeviceWeightUnit_KG)];

5.Receive data

-(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{
    if (type == ELInetSetCmdTypeSetName) {
        if (result == ELSetBluetoothResponseTypeSuccess) {
            [self addLog:@"Set name Success "];
        }else if (result == ELSetBluetoothResponseTypeFailure){
            [self addLog:@"Set name failure "];
        }else if (result == ELSetBluetoothResponseTypeNoSupport){
            [self addLog:@"Set name unsupport "];
        }

    }

}

//MARK:Units supported by the device
-(void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *)weightArray Height:(NSArray<NSNumber *> *)heightArray Temperature:(NSArray<NSNumber *> *)temperatureArray BloodPressure:(NSArray<NSNumber *> *)bloodPressureArray Pressure:(NSArray<NSNumber *> *)pressureArray{
// The weight and height units here
// When setting up the unit, you need to set up the unit supported by the device
    
}

-(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{
    [self addLog:bmVersion];
}

//Error
-(void)babyScaleBackDeviceErrorCode:(BabyScaleDeviceErrorCode)code{
    [self addLog:[NSString stringWithFormat:@"error code = %ld",code]];
}
//Weight
-(void)babyScaleManagerReceiveWeightModel:(ELBabyScaleBleWeightModel *)model{
    [self addLog:[NSString stringWithFormat:@"weight = %ld unit=%@ point = %ld",model.weight,model.unitStr,model.weightPoint]];
}
//Height
-(void)babyScaleManagerHeightModel:(ELBabyScaleBleHeightModel *)model{
    [self addLog:[NSString stringWithFormat:@"height = %ld unit=%@ point = %ld",model.height,model.unitStr,model.heightPoint]];
}
-(void)babyScaleBackCtrlType:(NSInteger)type Results:(BabyScaleResultType)result{
//    0去皮,1锁定)
    if (type == 0) {
        if (result == BabyScaleResultType_Succeed) {
            [self addLog:@"Zero Unit success"];
        }else if (result == BabyScaleResultType_Failure){
            [self addLog:@"Zero Unit failure"];
        }else if (result == BabyScaleResultType_Unsupported){
            [self addLog:@"Zero Unit unsupported"];
        }
    }else{
        if (result == BabyScaleResultType_Succeed) {
            [self addLog:@"Hold Unit success"];
        }else if (result == BabyScaleResultType_Failure){
            [self addLog:@"Hold Unit failure"];
        }else if (result == BabyScaleResultType_Unsupported){
            [self addLog:@"Hold Unit unsupported"];
        }
    }

}
-(void)babyScaleBackSetUnitResults:(BabyScaleResultType)result{
    if (result == BabyScaleResultType_Succeed) {
        [self addLog:@"Change Unit success"];
    }else if (result == BabyScaleResultType_Failure){
        [self addLog:@"Change Unit failure"];
    }else if (result == BabyScaleResultType_Unsupported){
        [self addLog:@"Change Unit unsupported"];
    }

}

-(void)babyScaleManagerUpdateState:(ELBluetoothState)state{
    switch (state) {
        case ELBluetoothStateUnavailable:
        {
            self.title = @"Please open the bluetooth";
        }
            break;
        case ELBluetoothStateAvailable:
        {
            self.title = @"Bluetooth is open";
        }
            break;
        case ELBluetoothStateScaning:
        {
            self.title = @"Scaning";
        }
            break;
        case ELBluetoothStateConnectFail:
        {
            self.title = @"Connect fail";
        }
            break;
        case ELBluetoothStateDidDisconnect:
        {
            self.title = @"Disconnected";
        }
            break;
        case ELBluetoothStateDidValidationPass:
        {
            self.title = @"Connected";
            [[ELBabyScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeReadDeviceSupportUnit)];
        }
            break;
        case ELBluetoothStateFailedValidation:
        {
            self.title = @"Illegal equipment";
        }
            break;
            case ELBluetoothStateWillConnect:
            self.title = @"Connecting";
            break;
        default:
            break;
    }
}

6.Explanation

The baby scale needs to read the supported height unit and weight unit from the device. When the unit is switched, the supported unit shall prevail

E、Integrated blood pressure monitor

1.Import header files and follow the agreement

#import <AILinkBleSDK/ELBloodBleManager.h>
@interface BloodConnectViewController ()<ELBluetoothManagerDelegate,ELBloodBleManagerDelegate>

2.Set proxy

[ELBloodBleManager shareManager].bloodDelegate = self; 
    [ELBloodBleManager shareManager].delegate  =self;

3.Scan and connect the device

[[ELBloodBleManager shareManager] startScan];
-(void)bloodBleManagerScanDevices:(NSArray<ELPeripheralModel *> *)devices{
    [[ELBloodBleManager shareManager] connectPeripheral:device];

}

4.send data

(1)Get BM version number

[[ELBloodBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetBMVersion)];

(2)Set Bluetooth name

[[ELBloodBleManager shareManager] setBluetoothName:@"AILink"];

(3)Start measurement

[[ELBloodBleManager shareManager] sendInteractiveInstructions:(ELBloodInteractionTypeStartTest)];

(4)Stop measuring

[[ELBloodBleManager shareManager] sendInteractiveInstructions:(ELBloodInteractionTypeStopTest)];

(5)Switch units

[[ELBloodBleManager shareManager] changeUnit:(ELDeviceBloodPressureUnit_mmhg)];

(6)Switch voice

[[ELBloodBleManager shareManager] sendSwitchVoice:(ELBloodBleSwitchVoiceTypeOff)];

5.Receive data

-(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{
    if (type == ELInetSetCmdTypeSetName) {
        if (result == ELSetBluetoothResponseTypeSuccess) {
            [self addLog:@"Set name Success "];
        }else if (result == ELSetBluetoothResponseTypeFailure){
            [self addLog:@"Set name failure "];
        }else if (result == ELSetBluetoothResponseTypeNoSupport){
            [self addLog:@"Set name unsupport "];
        }

    }

}

//MARK:Units supported by equipment
-(void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *)weightArray Height:(NSArray<NSNumber *> *)heightArray Temperature:(NSArray<NSNumber *> *)temperatureArray BloodPressure:(NSArray<NSNumber *> *)bloodPressureArray Pressure:(NSArray<NSNumber *> *)pressureArray{
// The weight and height units here
// When setting up the unit, you need to set up the unit supported by the device
    
}

-(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{
    [self addLog:bmVersion];
}
-(void)bloodBleManagerReceiceTestData:(ELBloodBleDataModel *)model type:(ELBloodBleDataModelType)type{
    [self addLog:[NSString stringWithFormat:@"dia = %@--sys=%@ unit = %ld point = %ld",model.dia,model.sys,AiLinkBloodUnitDic[@(model.unit)],model.point]];
}
-(void)bloodBleManagerReceiveSetSwitchVoiceOperationType:(ELBloodBleSwitchVoiceType)type result:(ELSetBluetoothResponseType)result{
    if (type == ELBloodBleSwitchVoiceTypeOff) {
        [self addLog:[NSString stringWithFormat:@"close voice result = %ld",result]];
    }else{
        [self addLog:[NSString stringWithFormat:@"open voice result = %ld",result]];
    }
}
-(void)bloodBleManagerReceiveSetUnitResult:(ELSetBluetoothResponseType)type{
    [self addLog:[NSString stringWithFormat:@"change unit result = %ld",type]];
}
-(void)bloodBleManagerReceiveFailCode:(ELBloodFailCode)code{
    [self addLog:[NSString stringWithFormat:@"error code = %ld",code]];
}
-(void)bloodBleManagerUpdateBleState:(ELBluetoothState)state{
    switch (state) {
        case ELBluetoothStateUnavailable:
        {
            self.title = @"Please open the bluetooth";
        }
            break;
        case ELBluetoothStateAvailable:
        {
            self.title = @"Bluetooth is open";
        }
            break;
        case ELBluetoothStateScaning:
        {
            self.title = @"Scaning";
        }
            break;
        case ELBluetoothStateConnectFail:
        {
            self.title = @"Connect fail";
        }
            break;
        case ELBluetoothStateDidDisconnect:
        {
            self.title = @"Disconnected";
        }
            break;
        case ELBluetoothStateDidValidationPass:
        {
            self.title = @"Connected";
            [[ELBloodBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeReadDeviceSupportUnit)];
        }
            break;
        case ELBluetoothStateFailedValidation:
        {
            self.title = @"Illegal equipment";
        }
            break;
            case ELBluetoothStateWillConnect:
            self.title = @"Connecting";
            break;
        default:
            break;
    }
}

6.Explanation

The sphygmomanometer needs to read the supported blood pressure unit from the device. When the unit is switched, the supported unit shall prevail

F、Integrated height gauge

1.Import header files and follow the agreement

#import <AILinkBleSDK/ELHeightGaugeBleManager.h>
@interface HeightGuageConnectViewController ()<ELBluetoothManagerDelegate,ELHeightGaugeBleManagerDelegate>

2.Set proxy

[ELHeightGaugeBleManager shareManager].heightGaugeDelegate = self;
    [ELHeightGaugeBleManager shareManager].delegate  =self;

3.Scan and connect the device

[[ELHeightGaugeBleManager shareManager] startScan];
-(void)heightGaugeBleManagerScanDevices:(NSArray<ELPeripheralModel *> *)devices{
    [[ELHeightGaugeBleManager shareManager] connectPeripheral:device];

}

4.Send data

(1)Get BM version number

[[ELHeightGaugeBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetBMVersion)];

(2)Set Bluetooth name

[[ELHeightGaugeBleManager shareManager] setBluetoothName:@"AILink"];

(3)Switch units

[[ELHeightGaugeBleManager shareManager] changeUnit:(ELDeviceHeightUnit_CM)];

5.Receive data

-(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{
    if (type == ELInetSetCmdTypeSetName) {
        if (result == ELSetBluetoothResponseTypeSuccess) {
            [self addLog:@"Set name Success "];
        }else if (result == ELSetBluetoothResponseTypeFailure){
            [self addLog:@"Set name failure "];
        }else if (result == ELSetBluetoothResponseTypeNoSupport){
            [self addLog:@"Set name unsupport "];
        }

    }

}
//MARK:Units supported by the device
-(void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *)weightArray Height:(NSArray<NSNumber *> *)heightArray Temperature:(NSArray<NSNumber *> *)temperatureArray BloodPressure:(NSArray<NSNumber *> *)bloodPressureArray Pressure:(NSArray<NSNumber *> *)pressureArray{
// The weight and height units here
// When setting up the unit, you need to set up the unit supported by the device
    
}

-(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{
    [self addLog:bmVersion];
}
/**
 call back ELHeightGaugeBleDataModel
 */
-(void)heightGaugeBleManagerReceiceTestData:(ELHeightGaugeBleDataModel *_Nonnull)model{
    [self addLog:[NSString stringWithFormat:@"height = %ld  unit = %@ point = %ld",model.height,AiLinkBleHeightUnitDic[@(model.heightUnit)],model.heightPoint]];
}

/**
 call back the result of set unit
 */
-(void)heightGaugeBleManagerReceiveSetUnitResult:(ELSetBluetoothResponseType)type{
    [self addLog:[NSString stringWithFormat:@"change unit result = %lu",(unsigned long)type]];
}

/**
 call back fail code
 */
-(void)heightGaugeBleManagerReceiveFailCode:(ELHeightGaugeFailCode)code{
    [self addLog:[NSString stringWithFormat:@"error code = %lu",(unsigned long)code]];
}
-(void)heightGaugeBleManagerUpdateBleState:(ELBluetoothState)state{
    switch (state) {
        case ELBluetoothStateUnavailable:
        {
            self.title = @"Please open the bluetooth";
        }
            break;
        case ELBluetoothStateAvailable:
        {
            self.title = @"Bluetooth is open";
        }
            break;
        case ELBluetoothStateScaning:
        {
            self.title = @"Scaning";
        }
            break;
        case ELBluetoothStateConnectFail:
        {
            self.title = @"Connect fail";
        }
            break;
        case ELBluetoothStateDidDisconnect:
        {
            self.title = @"Disconnected";
        }
            break;
        case ELBluetoothStateDidValidationPass:
        {
            self.title = @"Connected";
            [[ELHeightGaugeBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeReadDeviceSupportUnit)];
        }
            break;
        case ELBluetoothStateFailedValidation:
        {
            self.title = @"Illegal equipment";
        }
            break;
            case ELBluetoothStateWillConnect:
            self.title = @"Connecting";
            break;
        default:
            break;
    }
}

6.Explanation

The height meter needs to read the supported height units from the device, and the supported units shall prevail when the unit is switched

G、Integrated remote control

1.Import header files and follow the agreement

#import <AILinkBleSDK/ELRemoteControlBleManager.h>
@interface RemoteControlConnectViewController ()<ELBluetoothManagerDelegate,ELRemoteControlBleDelegate>

2.Set proxy

[ELRemoteControlBleManager shareManager].remoteControlDelegate = self;
    [ELRemoteControlBleManager shareManager].delegate  =self;

3.Scan and connect the device

[[ELRemoteControlBleManager shareManager] startScan];
-(void)remoteControlManagerScanDevices:(NSArray<ELRemoteControlDeviceModel *> *)deviceList{
    [[ELRemoteControlBleManager shareManager] connectPeripheral:device];

}

4.Send data

(1)Get BM version

[[ELRemoteControlBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetBMVersion)];

(2)Set bluetooth name

[[ELRemoteControlBleManager shareManager] setBluetoothName:@"AILink"];

(3)Send instructions

[[ELRemoteControlBleManager shareManager] sendRemoreControlData:(RemoteControlType_8_4)];

5.Receive data

-(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{
    if (type == ELInetSetCmdTypeSetName) {
        if (result == ELSetBluetoothResponseTypeSuccess) {
            [self addLog:@"Set name Success "];
        }else if (result == ELSetBluetoothResponseTypeFailure){
            [self addLog:@"Set name failure "];
        }else if (result == ELSetBluetoothResponseTypeNoSupport){
            [self addLog:@"Set name unsupport "];
        }

    }

}
-(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{
    [self addLog:bmVersion];
}
-(void)remoteControlManagerUpdateState:(ELBluetoothState)state{
    switch (state) {
        case ELBluetoothStateUnavailable:
        {
            self.title = @"Please open the bluetooth";
        }
            break;
        case ELBluetoothStateAvailable:
        {
            self.title = @"Bluetooth is open";
        }
            break;
        case ELBluetoothStateScaning:
        {
            self.title = @"Scaning";
        }
            break;
        case ELBluetoothStateConnectFail:
        {
            self.title = @"Connect fail";
        }
            break;
        case ELBluetoothStateDidDisconnect:
        {
            self.title = @"Disconnected";
        }
            break;
        case ELBluetoothStateDidValidationPass:
        {
            self.title = @"Connected";
        }
            break;
        case ELBluetoothStateFailedValidation:
        {
            self.title = @"Illegal equipment";
        }
            break;
            case ELBluetoothStateWillConnect:
            self.title = @"Connecting";
            break;
        default:
            break;
    }
}

6.Explanation

The remote control has no unit, and there is no need to call back data processing when sending commands

H、Integrated front temperature gun

1.Import header files and follow the agreement

#import <AILinkBleSDK/ELForeHeadBleManager.h>
@interface ForeheadConnectViewController ()<ELBluetoothManagerDelegate,ELForeheadBleManagerDelegate>

2.Set proxy

[ELForeHeadBleManager shareManager].foreheadDelegate = self;
    [ELForeHeadBleManager shareManager].delegate  =self;

3.Scan and connect the device

[[ELForeHeadBleManager shareManager] startScan];
-(void)foreheadBleManagerScanDevices:(NSArray<ELPeripheralModel *> *)devices{
    [[ELForeHeadBleManager shareManager] connectPeripheral:device];

}

4.Send data

(1)Get BM version

[[ELForeHeadBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetBMVersion)];

(2)Set blutooth name

[[ELForeHeadBleManager shareManager] setBluetoothName:@"AILink"];

(3)Switch units

[[ELForeHeadBleManager shareManager] changeUnit:(ELDeviceTemperatureUnit_C)];

5.Receive data

-(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{
    if (type == ELInetSetCmdTypeSetName) {
        if (result == ELSetBluetoothResponseTypeSuccess) {
            [self addLog:@"Set name Success "];
        }else if (result == ELSetBluetoothResponseTypeFailure){
            [self addLog:@"Set name failure "];
        }else if (result == ELSetBluetoothResponseTypeNoSupport){
            [self addLog:@"Set name unsupport "];
        }

    }

}
//MARK:Units supported by the device
-(void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *)weightArray Height:(NSArray<NSNumber *> *)heightArray Temperature:(NSArray<NSNumber *> *)temperatureArray BloodPressure:(NSArray<NSNumber *> *)bloodPressureArray Pressure:(NSArray<NSNumber *> *)pressureArray{
// The weight and height units here
// When setting up the unit, you need to set up the unit supported by the device
    
}

-(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{
    [self addLog:bmVersion];
}
/**
 Callback temperature

 @param model ELForeheadBleDataModel
 */
-(void)foreheadBleManagerReceiveTemperature:(ELForeheadBleDataModel *_Nonnull)model dataType:(ForeheadBleDataType)dataType{
    [self addLog:[NSString stringWithFormat:@"temperature = %@ unit = %@  point = %ld",model.temperature,AiLinkBleTempUnitDic[@(model.unit)],model.point]];
}

/**
Set unit callback

 @param type 
 */
-(void)foreheadBleManagerReceiveSetUnitResult:(ELSetBluetoothResponseType)type{
    [self addLog:[NSString stringWithFormat:@"Change Unit result = %lu",(unsigned long)type]];
}

/**
 Error code sent on the device

 @param code 错误码
 */
-(void)foreheadBleManagerReceiveFailCode:(ForeheadFailCode)code{
    [self addLog:[NSString stringWithFormat:@"error code = %lu",(unsigned long)code]];
}

-(void)foreheadBleManagerUpdateBleState:(ELBluetoothState)state{
    switch (state) {
        case ELBluetoothStateUnavailable:
        {
            self.title = @"Please open the bluetooth";
        }
            break;
        case ELBluetoothStateAvailable:
        {
            self.title = @"Bluetooth is open";
        }
            break;
        case ELBluetoothStateScaning:
        {
            self.title = @"Scaning";
        }
            break;
        case ELBluetoothStateConnectFail:
        {
            self.title = @"Connect fail";
        }
            break;
        case ELBluetoothStateDidDisconnect:
        {
            self.title = @"Disconnected";
        }
            break;
        case ELBluetoothStateDidValidationPass:
        {
            self.title = @"Connected";
            [[ELForeHeadBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeReadDeviceSupportUnit)];
        }
            break;
        case ELBluetoothStateFailedValidation:
        {
            self.title = @"Illegal equipment";
        }
            break;
            case ELBluetoothStateWillConnect:
            self.title = @"Connecting";
            break;
        default:
            break;
    }
}

6.Explanation

The forehead temperature gun needs to read the supported temperature unit from the device.

I、Integrated thermometer

1.Import header files and follow the agreement

#import <AILinkBleSDK/ELThermometerBleManager.h>
@interface ThermometerConnectViewController ()<ELBluetoothManagerDelegate,ELThermometerBleDelegate>

2.Set proxy

[ELThermometerBleManager shareManager].thermometerDelegate = self;
    [ELThermometerBleManager shareManager].delegate  =self;

3.Scan and connect the device

[[ELThermometerBleManager shareManager] startScan];
-(void)thermometerManagerScanDevices:(NSArray<ELThermometerDeviceModel *> *)thermometerDevices{
    [[ELThermometerBleManager shareManager] connectPeripheral:device];

}

4.Send data

(1)Get BM version

[[ELThermometerBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetBMVersion)];

(2)Set bluetooth name

[[ELThermometerBleManager shareManager] setBluetoothName:@"AILink"];

(3)Switch unist

[[ELThermometerBleManager shareManager] changeThermometerUnit:(ELDeviceTemperatureUnit_F)];

5.Receive data

-(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{
    if (type == ELInetSetCmdTypeSetName) {
        if (result == ELSetBluetoothResponseTypeSuccess) {
            [self addLog:@"Set name Success "];
        }else if (result == ELSetBluetoothResponseTypeFailure){
            [self addLog:@"Set name failure "];
        }else if (result == ELSetBluetoothResponseTypeNoSupport){
            [self addLog:@"Set name unsupport "];
        }

    }

}

//MARK:Units supported by the device
-(void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *)weightArray Height:(NSArray<NSNumber *> *)heightArray Temperature:(NSArray<NSNumber *> *)temperatureArray BloodPressure:(NSArray<NSNumber *> *)bloodPressureArray Pressure:(NSArray<NSNumber *> *)pressureArray{
// The weight and height units here
// When setting up the unit, you need to set up the unit supported by the device
    
}

-(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{
    [self addLog:bmVersion];
}
/**
 Callback temperature(回调温度)

 @param model ELForeheadBleDataModel
 */
-(void)thermometerManagerReceiveModel:(ELThermometerBleModel *)model{
    [self addLog:[NSString stringWithFormat:@"temperature = %ld unit = %@  point = %ld",model.temperature,AiLinkBleTempUnitDic[@(model.unit)],model.tempPoint]];
}
/**
Set unit callback( 设置单位回调)

 @param type 结果
 */
-(void)thermometerManagerSetUnitResults:(ThermometerBleResultType)result{
    [self addLog:[NSString stringWithFormat:@"Change Unit result = %lu",(unsigned long)result]];
}

/**
 Error code sent on the device(设备上发错误码)

 @param code 错误码
 */
-(void)thermometerManagerBackDeviceErrorCode:(ThermometerBleErrorCode)code{
    [self addLog:[NSString stringWithFormat:@"error code = %lu",(unsigned long)code]];
}

-(void)thermometerManagerUpdateState:(ELBluetoothState)state{
    switch (state) {
        case ELBluetoothStateUnavailable:
        {
            self.title = @"Please open the bluetooth";
        }
            break;
        case ELBluetoothStateAvailable:
        {
            self.title = @"Bluetooth is open";
        }
            break;
        case ELBluetoothStateScaning:
        {
            self.title = @"Scaning";
        }
            break;
        case ELBluetoothStateConnectFail:
        {
            self.title = @"Connect fail";
        }
            break;
        case ELBluetoothStateDidDisconnect:
        {
            self.title = @"Disconnected";
        }
            break;
        case ELBluetoothStateDidValidationPass:
        {
            self.title = @"Connected";
            [[ELThermometerBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeReadDeviceSupportUnit)];
        }
            break;
        case ELBluetoothStateFailedValidation:
        {
            self.title = @"Illegal equipment";
        }
            break;
            case ELBluetoothStateWillConnect:
            self.title = @"Connecting";
            break;
        default:
            break;
    }
}

6.Explanation

The thermometer needs to read the supported temperature unit from the device. When the unit is switched, the supported unit shall prevail

J、Integrated tire pressure monitoring

1.Import header files and follow the agreement

#import <AILinkBleSDK/ELWheelMonitorBleManager.h>
@interface WheelMonitorConnectViewController ()<ELBluetoothManagerDelegate,WheelMonitorBleManagerDelegate>

2.Set proxy

[ELWheelMonitorBleManager shareManager].wheelMonitordelegate = self;
    [ELWheelMonitorBleManager shareManager].delegate  =self;

3.Scan and connect the device

[[ELWheelMonitorBleManager shareManager] startScan];
-(void)wheelMonitorBleManagerScanDevices:(NSArray<ELPeripheralModel *> *)devices{
    [[ELWheelMonitorBleManager shareManager] connectPeripheral:device];

}

4.Send data

(1)Get BM version

[[ELWheelMonitorBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetBMVersion)];

(2)Set bluetooth name

[[ELWheelMonitorBleManager shareManager] setBluetoothName:@"AILink"];

(3)Switch units

[[ELWheelMonitorBleManager shareManager] changePressureUnit:(ELDevicePressureUnit_kPa) tempUnit:(ELDeviceTemperatureUnit_C)];

(4)Get tire pressure records

[[ELWheelMonitorBleManager shareManager] getWheelData:(WheelMonitorGetWheelData_LeftBack)];
        [[ELWheelMonitorBleManager shareManager] getWheelData:(WheelMonitorGetWheelData_LeftFront)];
        [[ELWheelMonitorBleManager shareManager] getWheelData:(WheelMonitorGetWheelData_RightBack)];
        [[ELWheelMonitorBleManager shareManager] getWheelData:(WheelMonitorGetWheelData_RightFront)];

(5)Set tire pressure threshold

[[ELWheelMonitorBleManager shareManager] sendSettingWheelPressureLimitWithFrontMax:300 frontMin:200 backMax:300 backMin:200 pressureUnit:(ELDevicePressureUnit_kPa) valuePoint:0];

(6)Set tire temperature threshold

[[ELWheelMonitorBleManager shareManager] sendSettingWheelTempLimitWithTempMax:100 tempMin:50 tempUnit:(ELDeviceTemperatureUnit_C) valuePoint:0 openVoice:YES];

(7)Toggle voice alarm

[[ELWheelMonitorBleManager shareManager] sendSettingWheelOpenVoice:YES];

5.Receive data

-(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{
    if (type == ELInetSetCmdTypeSetName) {
        if (result == ELSetBluetoothResponseTypeSuccess) {
            [self addLog:@"Set name Success "];
        }else if (result == ELSetBluetoothResponseTypeFailure){
            [self addLog:@"Set name failure "];
        }else if (result == ELSetBluetoothResponseTypeNoSupport){
            [self addLog:@"Set name unsupport "];
        }

    }

}

//MARK:Units supported by the device
-(void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *)weightArray Height:(NSArray<NSNumber *> *)heightArray Temperature:(NSArray<NSNumber *> *)temperatureArray BloodPressure:(NSArray<NSNumber *> *)bloodPressureArray Pressure:(NSArray<NSNumber *> *)pressureArray{
// The weight and height units here
// When setting up the unit, you need to set up the unit supported by the device
    
}

-(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{
    [self addLog:bmVersion];
}
/**
 Set unit callback(设置单位回调)
 
 @param type 结果
 @param settingType 支持类型:
 WheelMonitorBleDataTypeSetUnitResult
 WheelMonitorBleDataTypeSetPressureLimit
 WheelMonitorBleDataTypeSetTempLimit
 WheelMonitorBleDataTypeSetVoice
 */
-(void)wheelMonitorBleManagerReceiveSetResult:(ELSetBluetoothResponseType)type settingType:(WheelMonitorBleDataType)settingType{
    [self addLog:[NSString stringWithFormat:@"set type = %lu set result = %lu",settingType,type]];
}

/**
 Callback tire pressure data(回调胎压数据)

 @param model 胎压数据模型
 */
-(void)wheelMonitorBleManagerWheelMonitorData:(ELWheelMonitorBleModel *_Nonnull)model{
    [self addLog:[NSString stringWithFormat:@"wheel number = %ld voltage = %@ pressure = %@%@ temperature=%@%@",model.wheelType,model.v,model.p,AiLinkBlePressureUnitDic[@(model.pressureUnit)],model.t,AiLinkBlePressureUnitDic[@(model.tempUnit)]]];
}


/**
 Get front and rear wheel parameter setting type(获取前后轮参数设置类型)

 @param type 类型
 */
-(void)wheelMonitorBleManagerReceiveSettingType:(WheelMonitorSettingType)type{
    [self addLog:[NSString stringWithFormat:@"setting type = %lu",type]];
}
-(void)wheelMonitorBleManagerUpdateBleState:(ELBluetoothState)state{
    switch (state) {
        case ELBluetoothStateUnavailable:
        {
            self.title = @"Please open the bluetooth";
        }
            break;
        case ELBluetoothStateAvailable:
        {
            self.title = @"Bluetooth is open";
        }
            break;
        case ELBluetoothStateScaning:
        {
            self.title = @"Scaning";
        }
            break;
        case ELBluetoothStateConnectFail:
        {
            self.title = @"Connect fail";
        }
            break;
        case ELBluetoothStateDidDisconnect:
        {
            self.title = @"Disconnected";
        }
            break;
        case ELBluetoothStateDidValidationPass:
        {
            self.title = @"Connected";
              //Whether the threshold values of front and rear tire pressure are set together or separately
            [[ELWheelMonitorBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:ELInetGetCmdTypeGetBasicInfoData];

            //Units supported by the device
            [[ELWheelMonitorBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeReadDeviceSupportUnit)];
        }
            break;
        case ELBluetoothStateFailedValidation:
        {
            self.title = @"Illegal equipment";
        }
            break;
            case ELBluetoothStateWillConnect:
            self.title = @"Connecting";
            break;
        default:
            break;
    }
}

6.Explanation

The tire pressure monitoring needs to read the supported pressure unit and temperature unit from the device. When the unit is switched, the supported unit shall prevail

After the connection is successful, call the following method to obtain the threshold value of the front and rear tire pressures

            [[ELWheelMonitorBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:ELInetGetCmdTypeGetBasicInfoData];

K、Integrated body fat scale

1.Import header files and follow the agreement

#import <AILinkBleSDK/ELBodyFatScaleBleManager.h>
@interface BodyFatScaleConnectViewController ()<ELBluetoothManagerDelegate,ELBodyFatScaleBleDelegate,ElBleWifiDelegate>

2.Set proxy

[ELBodyFatScaleBleManager shareManager].bodyFatScaleDelegate = self;
    [ELBodyFatScaleBleManager shareManager].delegate  =self;
//If it is a wifi + ble scale, you need to set the wifi proxy
    [ELBodyFatScaleBleManager shareManager].bleWifiDelegate = self;

3.Scan and connect the device

[[ELBodyFatScaleBleManager shareManager] startScan];
-(void)bodyFatScaleManagerScanDevices:(NSArray<ELBodyFatScaleDeviceModel *> *)scaleDevices{
    [[ELBodyFatScaleBleManager shareManager] connectPeripheral:device];

}

4.Send data

1) Get the BM version number (2) Set the Bluetooth name (3) Switch units

5.Receive data, process data, interact

-(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{
    if (type == ELInetSetCmdTypeSetName) {
        if (result == ELSetBluetoothResponseTypeSuccess) {
            [self addLog:@"Set name Success "];
        }else if (result == ELSetBluetoothResponseTypeFailure){
            [self addLog:@"Set name failure "];
        }else if (result == ELSetBluetoothResponseTypeNoSupport){
            [self addLog:@"Set name unsupport "];
        }

    }

}

//MARK:Units supported by the device
-(void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *)weightArray Height:(NSArray<NSNumber *> *)heightArray Temperature:(NSArray<NSNumber *> *)temperatureArray BloodPressure:(NSArray<NSNumber *> *)bloodPressureArray Pressure:(NSArray<NSNumber *> *)pressureArray{
// The weight and height units here
// When setting up the unit, you need to set up the unit supported by the device
/// As long as the weight data is here
    self.units = weightArray;

}

-(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{
    [self addLog:bmVersion];
}
-(void)bluetoothManagerReceiveMCUConnectedState:(struct ELMCUStateStruct)stateStrct{
    
    BleWiFiConnectState wifiState = stateStrct.wifiState;
    

    if (self.p.deviceType == ELSupportDeviceTypeBLE_WIFIScale) {
// Bluetooth WiFi body fat scale
// // Request session code
        [[ELBodyFatScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:ELInetGetCmdTypeBleWifiGetSNNumber];
// MARK: 1. The WiFi configuration prompts the user to configure the network
▲ // TODO: Note: The wifi configuration process must maintain the connection between Bluetooth and the device
        if (wifiState == BleWiFiConnectStateNoWiFi) {
// 1. If there is no distribution network, the user is prompted to configure the network
// // MARK: 2. WiFi configuration first get wifi list
            //
            [[ELBodyFatScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:ELInetGetCmdTypeBleWifiGetNearbyWifi];
            //
//            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Change Unit" message:@"" preferredStyle:(UIAlertControllerStyleAlert)];
//            UIAlertAction *action = [UIAlertAction actionWithTitle:@"去配网" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
//                if ([ELBodyFatScaleBleManager shareManager].state == ELBluetoothStateDidValidationPass) {
//                    WiFiSetupViewController *vc = [[WiFiSetupViewController alloc] init];
//                    [self.navigationController pushViewController:vc animated:YES];
//                }else{
//                    [self addLog:@"Disconnected"];
//                }
//
//            }];
//            UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
//
//            }];
//            [alert addAction:action];
//            [alert addAction:action2];
//            [self presentViewController:alert animated:YES completion:nil];
        }
    }
/// MARK: 9. wifi configuration result
Nes // Other commands and data reception related to wifi, please check the ELBluetoothManager.h file
    if (stateStrct.wifiState == BleWiFiConnectStateSuccess) {
//success
// MARK: 10. Get the SN number of the wifi device, that is, the device id
        [[ELBodyFatScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeBleWifiGetSNNumber)];
    }else{
        //fail
    }

}

/**
 Callback to set unit result(回调设置单位结果)
 
 @param result 结果
 */
- (void)bodyFatScaleManagerCallBackSetUnitResult:(ELSetBluetoothResponseType)result{
    switch (result) {
        case ELSetBluetoothResponseTypeSuccess:
        {
            [self addLog:@"Change Unit Success"];
        }
            break;
        case ELSetBluetoothResponseTypeFailure:
        {
            [self addLog:@"Change Unit Failure"];
        }
            break;
        case ELSetBluetoothResponseTypeNoSupport:
        {
            [self addLog:@"Unsupport Change Unit"];
        }
            break;
        default:
            break;
    }
}
//MARK:Callback Wifi list
-(void)bleWifiReceiveWifiDetailModel:(ELBleWifiDetailModel *)model{
// MARK: 3. WiFi configuration gets Wifi list
// // Display it with a tableview
    [self addLog:[NSString stringWithFormat:@"wifi类型---%lu 名称---%@",(unsigned long)model.wifiState,model.wifiName]];
    
}
-(void)bleWifiReceiveScanedWifiCount:(int)count {
// MARK: Scanning Wifi is over
// MARK: 4. WiFi configuration to get a list of nearby wifi, click to select a wifi to configure
MARK // MARK: 5. Enter wifi password
// // Write a "textfield" to enter the password
// MARK: 6. First send the command to configure the wifi mac address
//    [[ELBodyFatScaleBleManager shareManager] bleWifiSetConnectWifiMac:[NSData data]];
}
-(void)bleWifiReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{
    
    [self addLog:[NSString stringWithFormat:@"bleWifiReceiceResponseType==%lu----%lu",type,result]];
    if (result == ELSetBluetoothResponseTypeSuccess) {
        //Set WiFi results
        if (type == ELInetSetCmdTypeBleWifiSetWifiMac) {
            //MARK:7. Send the instruction to configure wifi password again
            [[ELBodyFatScaleBleManager shareManager] bleWifiSetWifiPwd:@"WiFi pwd"];
        }else if (type == ELInetSetCmdTypeBleWifiSetWifiPwd){
            //MARK:8. Then initiate a connection to Wifi
            [[ELBodyFatScaleBleManager shareManager] bleWifiSetupWifiConnect:YES];
        }else if (type == ELInetSetCmdTypeBleWifiSetConnectWifi){
            //Get connection status
        }
    }
    else{
        //TODO:Handle the failures during Wifi configuration
    }
    
}
/**
 MCU requests user information( MCU 请求用户信息)
 
 @param status 请求状态
 */
- (void)bodyFatScaleManagerMCURequestAppUserInfoType:(BodyFatScaleMCURequestUserInfoStatus)status{
    if (status == BodyFatScaleMCURequestUserInfoStatus_Get) {
        //Send the current user to the scale
        [[ELBodyFatScaleBleManager shareManager] sendCurrentUserToBle:[self getOneUser]];
    }else if (status == BodyFatScaleMCURequestUserInfoStatus_Success){
        [self addLog:@"MCU requests user information success"];
    }else if (BodyFatScaleMCURequestUserInfoStatus_Fail){
        [self addLog:@"MCU requests user information failure"];
    }

}


/**
 Return weight and body fat model(返回重量及体脂model)
 */
-(void)bodyFatScaleManagerCallBackWeight:(ELBodyFatScaleBleWeightModel *)weightModel state:(BodyFatScaleMeasureStatus)status{
    switch (status) {
        case BodyFatScaleMeasureStatus_Unstable:
        {
            [self addLog:[NSString stringWithFormat:@"Unstable data weight = %ld unit = %@ point = %ld adc = %ld",weightModel.weight,AiLinkBleWeightUnitDic[@(weightModel.weightUnit)],weightModel.weightPoint,weightModel.adc]];
        }
            break;
        case BodyFatScaleMeasureStatus_Stable:
        {
            [self addLog:[NSString stringWithFormat:@"Stable data weight = %ld unit = %@ point = %ld adc = %ld",weightModel.weight,AiLinkBleWeightUnitDic[@(weightModel.weightUnit)],weightModel.weightPoint,weightModel.adc]];
        }
            break;
        case BodyFatScaleMeasureStatus_Failed:
        {
            [self addLog:@"Test failure"];
        }
            break;
        case BodyFatScaleMeasureStatus_Complete:
        {
            [self addLog:[NSString stringWithFormat:@"Tested weight = %ld unit = %@ point = %ld adc = %ld",weightModel.weight,AiLinkBleWeightUnitDic[@(weightModel.weightUnit)],weightModel.weightPoint,weightModel.adc]];
            
            //Update user information to scale
            [[ELBodyFatScaleBleManager shareManager] sendCurrentUserToBle:[self getOneUser]];
            //Send user list
            [[ELBodyFatScaleBleManager shareManager] sendOfflineUserListToBle:[self get8Users]];
        }
            break;
        default:
            break;
    }
}


/**
 Return temperature (unit: ° C)(返回温度(单位:°C))
 
 @param temp 温度(单位:°C)
 */
-(void)bodyFatScaleManagerCallBackTemp:(NSString *)temp{
    [self addLog:[NSString stringWithFormat:@"temperature is %@",temp]];
}

/**
 Back to impedance measurement(返回阻抗测量)
 
 @param status 阻抗测量状态
 @param adc 阻抗
 */
-(void)bodyFatScaleManagerCallBackAdcMeasureStatus:(BodyFatScaleAdcMeasureStatus)status adcValue:(NSInteger)adc{
    switch (status) {
        case BodyFatScaleAdcMeasureStatus_Testing:
        {
            [self addLog:@"adc testing"];
        }
            break;
        case BodyFatScaleAdcMeasureStatus_Success:
        {
            [self addLog:[NSString stringWithFormat:@"adc is %ld",adc]];
        }
            break;
        case BodyFatScaleAdcMeasureStatus_Fail:
        {
            [self addLog:@"adc test failure"];
        }
            break;
        case BodyFatScaleAdcMeasureStatus_SuccessCustom:
        {
            [self addLog:[NSString stringWithFormat:@"adc is %ld and user app algum",adc]];
        }
            break;
        default:
            break;
    }
}

/**
 Callback heart rate measurement(回调心率测量)
 
 @param status 心率测量状态
 @param heartRate 心率
 */
-(void)bodyFatScaleManagerCallBackHeartRateMeasureStatus:(BodyFatScaleHeartRateMeasureStatus)status heartRateValue:(NSInteger)heartRate{
    switch (status) {
        case BodyFatScaleHeartRateMeasureStatus_Testing:
        {
            [self addLog:@"Heart Rate Testing"];
        }
            break;
        case BodyFatScaleHeartRateMeasureStatus_Success:
        {
            [self addLog:[NSString stringWithFormat:@"Heart Rate is %ld",heartRate]];
        }
            break;
        case BodyFatScaleHeartRateMeasureStatus_Fail:
        {
            [self addLog:@"Heart Rate Test failure"];
        }
            break;
        default:
            break;
    }
}

/**
 Return error code(返回错误码)
 
 @param code 错误码
 1:overweight
 */
-(void)bodyFatScaleManagerCallBackErrorCode:(NSInteger)code{
    [self addLog:[NSString stringWithFormat:@"error code = %ld",code]];
}
//MARK:Callback A6 command data

/**
 Send success or failure callback for offline user list(发送离线用户列表的成功或失败回调)
 
 @param status 状态
 */
-(void)bodyFatScaleManagerCallBackUpdateRecordStatus:(BodyFatScaleUpdateRecordStatus)status{
    switch (status) {
        case BodyFatScaleUpdateRecordStatus_AllSuccess:
        {
            [self addLog:@"Update All Users Success"];
        }
            break;
        case BodyFatScaleUpdateRecordStatus_OneSuccess:
        {
            [self addLog:@"Update A User Success"];
        }
            break;
        case BodyFatScaleUpdateRecordStatus_OneFail:
        {
            [self addLog:@"Update A User Failure"];
        }
            break;
        case BodyFatScaleUpdateRecordStatus_AllFail:
        {
            [self addLog:@"Update All Users Failure"];
        }
            break;
        default:
            break;
    }
}

/**
 Request callback for offline history(请求离线历史记录的回调)
 
 @param status 状态
 */
-(void)bodyFatScaleManagerCallBackSendHistoryDataStatus:(BodyFatScaleSendHistoryDataStatus)status{
    if (status == BodyFatScaleSendHistoryDataStatus_No) {
        [self addLog:@"No offline datas"];
    }else if (status == BodyFatScaleSendHistoryDataStatus_Begin){
        [self addLog:@"Begin receive offline datas"];
    }else if (status == BodyFatScaleSendHistoryDataStatus_End){
        [self addLog:@"End receive offline datas"];
    }
    
}

/**
 APP algorithm-offline history data(APP 算法-离线历史记录数据)
 
 @param user 用户信息
 */
-(void)bodyFatScaleManagerCallBackBleUserHistoryDataCustomADCModel:(ELBodyFatScaleBleUserModel *)user bodyDataModel:(ELBodyFatScaleBleWeightModel *)bodyModel{
    //The body index and other data here are calculated by the app's custom algorithm, please distinguish bodyModel.algNum to call the algorithm
    [self addLog:[NSString stringWithFormat:@"App algorithm-offline history data:userId = %ld weight = %ld unit =%@ point = %ld",user.usrID,bodyModel.weight,AiLinkBleWeightUnitDic[@(bodyModel.weightUnit)],bodyModel.weightPoint]];
}

/**
 MCU algorithm-offline history data(MCU 算法-离线历史记录数据)
 
 @param user 用户信息
 @param bodyModel 体脂数据
 */
-(void)bodyFatScaleManagerCallBackBleUserHistoryDataModel:(ELBodyFatScaleBleUserModel *)user bodyDataModel:(ELBodyFatScaleBleWeightModel *)bodyModel{
    //The physical index data here is calculated by the scale
    [self addLog:[NSString stringWithFormat:@"MCU algorithm-offline history data:userId = %ld weight = %ld unit =%@ point = %ld",user.usrID,bodyModel.weight,AiLinkBleWeightUnitDic[@(bodyModel.weightUnit)],bodyModel.weightPoint]];
}

-(void)bleWifiReceiveWifiSNCode:(int)code{
    //MARK:11. Get offline data from the server according to the device id of the wifi device (find your own background to interface)

-(void)bodyFatScaleManagerUpdateState:(ELBluetoothState)state{
    switch (state) {
        case ELBluetoothStateUnavailable:
        {
            self.title = @"Please open the bluetooth";
        }
            break;
        case ELBluetoothStateAvailable:
        {
            self.title = @"Bluetooth is open";
        }
            break;
        case ELBluetoothStateScaning:
        {
            self.title = @"Scaning";
        }
            break;
        case ELBluetoothStateConnectFail:
        {
            self.title = @"Connect fail";
        }
            break;
        case ELBluetoothStateDidDisconnect:
        {
            self.title = @"Disconnected";
        }
            break;
        case ELBluetoothStateDidValidationPass:
        {
            self.title = @"Connected";
            //Units supported by the device
            [[ELBodyFatScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeReadDeviceSupportUnit)];
            //Send the unit you set to the scale
            ELDeviceWeightUnit unit = ELDeviceWeightUnit_KG;
            [[ELBodyFatScaleBleManager shareManager] changeBodyFatScaleUnit:unit];
            //Request history
            [[ELBodyFatScaleBleManager shareManager] sendCmd_RequestHistory];
            
            //Send user list
            [[ELBodyFatScaleBleManager shareManager] sendOfflineUserListToBle:[self get8Users]];
            
            if (self.p.deviceType == ELSupportDeviceTypeBLE_WIFIScale) {
                //Get Bluetooth connection status
                [[ELBodyFatScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetConnectState)];
            }
        }
            break;
        case ELBluetoothStateFailedValidation:
        {
            self.title = @"Illegal equipment";
        }
            break;
        case ELBluetoothStateWillConnect:
            self.title = @"Connecting";
            break;
        default:
            break;
    }
}
-(NSArray<ELBodyFatScaleBleUserModel *> *)get8Users{
    NSMutableArray *users = [[NSMutableArray alloc] init];
    for (int i=0; i<8; i++) {
        ELBodyFatScaleBleUserModel *user = [[ELBodyFatScaleBleUserModel alloc] init];
        user.createTime = [[NSDate date] timeIntervalSince1970];
        user.usrID = i;
        user.role = i%4;
        user.sex = i%2;
        user.age = 26+i;
        user.height = 170+i;
        user.weight = 600+i;
        user.adc = 560+i;
        [users addObject:user];
    }

    return users.copy;
}

-(ELBodyFatScaleBleUserModel *)getOneUser{
    ELBodyFatScaleBleUserModel *user = [[ELBodyFatScaleBleUserModel alloc] init];
    user.createTime = [[NSDate date] timeIntervalSince1970];
    user.usrID = 0;
    user.role = BodyFatScaleRole_Ordinary;
    user.sex = ELBluetoothUserSex_Woman;
    user.age = 26;
    user.height = 170;
    user.weight = 600;
    user.adc = 560;
    return user;
}

Broadcast Body Fat Scale

1. File description

  • ELBroadcastScaleBleHeader some enumerations used;
  • ELBroadcastScaleBleManager continues from the class of ELBluetoothManager, used to scan nearby devices and receive data;
  • ELBroadcastScaleDataModel The data structure model of the broadcast scale.

2. Use example Demo

Open AILinkBleSDKDemo_iOS, run it on the phone, select 集成广播秤, refer to the use of BroadcastScaleViewController.m.

Eight electrode body fat scale

1. File description

  • ELEightScaleSDKHeaderSome enumerations and data structures used;
  • ELEightScaleBleManager continues from the class of ELBluetoothManager, used to scan nearby devices, connect devices, receive data and send data to devices;
  • ELEightScaleBleDataModel The data structure model of the weighing result.

2. Use example Demo

Open AILinkBleSDKDemo_iOS, run it on the phone, select 八电极体脂秤, refer to the use of EightScaleScanViewController.m and EightScaleConnectionViewController.m.

Bluetooth WiFi toothbrush

1. File description

  • ELToothburshHeader some enumerations and data structures used;
  • ELToothbrushBleManager continues from the class of ELBluetoothManager, used to scan nearby devices, connect devices, receive data and send data to devices.

2. Use example Demo

Open AILinkBleSDKDemo_iOS, run it on the phone, select 蓝牙WiFi牙刷, refer to the use of ToothbrushScanViewController.m and ToothbrushConnectionViewController.m.

6.Explanation

The body fat scale needs to read the supported weight unit from the device. When the unit is switched, the supported unit shall prevail

For details and wifi configuration logic, please refer to the protocol and demo

Contact us

Thank you for using the product net SDK for product development. If you have any questions during use, please feel free to contact us Helping enterprises to achieve rapid and intelligent products is our driving force. Web: www.inet-tek.com Email : iot.support@inet-tek.com