Skip to main content

Overview

DreisamLibPro is an SDK designed for device connectivity and data interaction. It provides functionalities such as device connection management, data synchronization, and historical data retrieval, making it ideal for applications that need to communicate with specific hardware devices.

Public Classes and Their Roles

  1. DreisamLib
    • The main header file. Developers can import the entire SDK by using:#import <DreisamLibPro/DreisamLibPro>
  2. DreisamLibManage
    • The central manager class used to initialize the SDK
  3. DreisamBuilderParam
    • A parameter model class used during SDK initialization.
  4. BleManage
    • The Bluetooth control module. Accessed via:[DreisamLibManage shareLib].bleManage
  5. DreisamGlucoseModel
    • A data model representing glucose readings, including glucose value and timestamp
  6. DreisamDeviceModel
    • A model representing a bound device
  7. DreisamEnum
    • An enumeration class that defines status codes returned via callbacks.

Initialization Methods

Initialize the SDK

DreisamBuilderParam *builder = DreisamBuilderParam.new;
builder.hideLog = NO;
builder.appId = @"******";
[[DreisamLibManage shareLib] initSDKBuilderParam:builder];
  • Purpose: Initializes the SDK
  • Parameters
    • hideLog - Whether to suppress SDK logs (default: NO, logs are enabled)
    • appId - The App ID issued from the developer portal

User Login

[DreisamLibManage.shareLib loginUserToken:token callback:^(DreisamEnumState state, DreisamDeviceModel * _Nonnull deviceModel) {}];
  • Purpose: Authenticates the user with a provided token

Logout

[DreisamLibManage.shareLib logout]
  • Purpose: Logs the user out and deinitializes the SDK

Bind a Device

[DreisamLibManage.shareLib.bleManage bindDevice:result resultCallback:^(DreisamBindingProcessState state, DreisamDeviceModel *deviceModel) {
    if (state==DreisamBindingProcessStateBindingFailure) {
        [ListHub showText:@"Binding failure" maskBackgroudEdit:YES];
    }else{
        [ListHub showText:@"Binding successful" maskBackgroudEdit:YES];
        NSLog(@"resultCallback = %@",deviceModel.device_sn);
    }

} processProgress:^(DreisamBindingProcessState state) {
    if (state==DreisamBindingProcessStateScanning) {
        [ListHub showLoadingText:@"Scanning" maskBackgroudEdit:NO showForever:YES];
    }else if (state==DreisamBindingProcessStateConnecting){
        [ListHub showLoadingText:@"Connecting" maskBackgroudEdit:NO showForever:YES];
    }else if (state==DreisamBindingProcessStateInBinding){
        [ListHub showLoadingText:@"InBinding" maskBackgroudEdit:NO showForever:YES];
    }
}];

Device Connection Management

Connect to a Bound Device(You must log in successfully before attempting to connect to a device)

[DreisamLibManage.shareLib loginUserToken:token callback:^(DreisamEnumState state, DreisamDeviceModel * _Nonnull deviceModel) {
    if (state==DreisamEnumStateLoginSucceed) {
        // Proceed to connect device
        [DreisamLibManage.shareLib.bleManage connectDeviceCallback:^(DreisamEnumState state) {

        }];

    }else{
        [ListHub showText:@"login failure" maskBackgroudEdit:YES];
    }
}];

  • Purpose: Establishes a connection with a previously bound device

Get RSSI (Signal Strength)

[[DreisamLibManage shareLib].bleManage getRSSICallback:^(NSNumber *rssi) {

}];

Mark Device as Expired

[DreisamLibManage.shareLib.bleManage finshDevice:^(DreisamEnumState state) {
    if (state==DreisamEnumStateOperationSucceeded) {

    }else{

    }
}];

  • Purpose: Manually mark the device as expired (end of lifecycle)

Status Monitoring & Callbacks

Exception & State Change Callback

[[DreisamLibManage shareLib].bleManage connectBleStateWithExceptionEventCallback:^(DreisamEnumState state) {
    if(state==DreisamEnumStateConnected){
      ////////
    }else if(state==DreisamEnumStateTokenInvalid || state==DreisamEnumStateTokenExpiration){
            [weakSelf logOut];
    }else if(state==DreisamEnumStateUnDeviceExpire){
        
    }
}];
  • 枚举说明:
    • DreisamEnumStateAuthenticationFailure //Device authentication failed
    • DreisamEnumStateDisconnect //Bluetooth connection lost
    • DreisamEnumStateConnected //Device successfully connected
    • DreisamEnumStateIndicateLoading //Operation in progress (show loading indicator)
    • DreisamEnumBleStatePoweredOn //Phone Bluetooth is on
    • DreisamEnumBleStatePoweredOff //Phone Bluetooth is off
    • DreisamEnumStateUnDeviceAvailable //No bound/available device
    • DreisamEnumStateUnDeviceExpire //Device has expired
    • DreisamEnumStateLoginSucceed //User login succeeded
    • DreisamEnumStateLoginFailure //User login failed
    • DreisamEnumStateLoginNotLoggedOn //User not logged in
    • DreisamEnumStateTokenExpiration //Authentication token expired
    • DreisamEnumStateTokenInvalid //Invalid token
    • DreisamEnumStateOperationSucceeded //Generic operation succeeded
    • DreisamEnumStateOperationFailed //Generic operation failed

Data Synchronization Callbacks

[[DreisamLibManage shareLib].bleManage dataSyncStartCallback:^(int totalCount){
    
}];
  • totalCount: number of records to be synced

Sync Progress

[[DreisamLibManage shareLib].bleManage dataSyncProgressCallback:^(**int** progress) {
		NSLog(@"dataSyncProgressCallback = %d",progress);
}];

Sync Complete

[[DreisamLibManage shareLib].bleManage dataSyncCompleteCallback:^(NSArray<DreisamGlucoseModel *> *glucoseModelAry) {
		weakSelf.headerView.dataSyncLabel.text = @"Data sync:100%";
}];

Real-Time Data Updates

[[DreisamLibManage shareLib].bleManage realTimeDataCallBack:^(DreisamGlucoseModel *glucoseModel) {
		weakSelf.headerView.dataSyncLabel.text = @"Data sync:100%";
}];
  • Note: Real-time data is reported approximately once every 3 minutes