Skip to main content

BleConnect

The BleConnect module provides comprehensive Bluetooth Low Energy (BLE) device management capabilities, including device discovery, connection, authentication, and binding. It handles the complete connection lifecycle from initial scanning through authentication to full readiness, with granular state tracking and error handling at each stage.

Prerequisites​

  • iOS 12.0 or later
  • Bluetooth Low Energy (BLE) capable device
  • NSBluetoothPeripheralUsageDescription permission in Info.plist
  • NSBluetoothCentralUsageDescription permission in Info.plist
  • User must grant Bluetooth permissions at runtime

Data Models​

TSPeripheral​

Complete peripheral device information container.

PropertyTypeDescription
systemInfoTSPeripheralSystem *System-level information including Bluetooth connection details, MAC address, and device identification
screenInfoTSPeripheralScreen *Screen properties including size, shape, border radius, and preview dimensions
projectInfoTSPeripheralProject *Project-level information including firmware version, serial number, and device identifiers
capabilityTSPeripheralCapability *Device capability information including supported features and functionalities
limitationTSPeripheralLimitations *Device feature limitations including maximum counts for alarms, reminders, and contacts

TSPeripheralSystem​

System-level information for peripheral devices.

PropertyTypeDescription
peripheralCBPeripheral *Core Bluetooth peripheral object for device communication
centralCBCentralManager *Bluetooth central manager controlling connections and scanning
uuidNSString *UUID string from CBPeripheral.identifier (read-only)
macNSString *Device MAC address in colon-separated format (e.g., "DE:82:47:15:28:B0")
bleNameNSString *Device Bluetooth name broadcasted for user identification
RSSINSNumber *Bluetooth signal strength indicator (RSSI value)
advertisementDataNSDictionary *Raw advertisement data dictionary containing service UUIDs and manufacturer data

TSPeripheralProject​

Project-related information for peripheral devices.

PropertyTypeDescription
projectIdNSString *Unique identifier for the project type
companyIdNSString *Company identifier from BLE manufacturer data (typically 4-character hex string)
brandNSString *Device brand name (maximum 16 characters)
modelNSString *Device model identifier (maximum 16 characters)
firmVersionNSString *Current firmware version (semantic versioning format)
virtualVersionNSString *Special version number for internal version control
serialNumberNSString *Unique device serial number
mainProjNumNSString *Main project number used in FitCloudKit
subProjNumNSString *Sub project number for variant identification

TSPeripheralScreen​

Screen information for peripheral devices.

PropertyTypeDescription
shapeTSPeriphShapeDevice physical shape (circle, square, vertical rectangle, horizontal rectangle)
screenSizeCGSizeScreen size in pixels
screenBorderRadiusCGFloatScreen border radius in pixels
dialPreviewSizeCGSizeWatch face preview image size in pixels
dialPreviewBorderRadiusCGFloatWatch face preview image corner radius in pixels
videoPreviewSizeCGSizeVideo preview stream size in pixels
videoPreviewBorderRadiusCGFloatVideo preview stream corner radius in pixels

TSPeripheralCapability​

Device capability container organizing feature support into distinct modules.

PropertyTypeDescription
featureAbilityTSFeatureAbility *Coarse-grained feature module support flags (YES/NO)
messageAbilityTSMessageAbility *Fine-grained message type support details (which types supported)
dailyActivityAbilityTSDailyActivityAbility *Fine-grained daily activity type support (which types supported)
aiAbilityTSPeripheralAIAbility *Direction-aware AI scenes declared by device firmware
sleepAlgorithmNSIntegerDevice sleep algorithm type (0=LongestNight, 1=LongestOnly)

TSFeatureAbility​

Feature module capability flags indicating which major features are supported.

PropertyTypeDescription
originAbilityNSData *Raw ability data from device (maximum 16 bytes)
supportCapabilitiesTSPeripheralSupportAbilityParsed capability flags indicating supported features
isSupportStepCountingBOOLStep counting support
isSupportDistanceCountingBOOLDistance counting support
isSupportCalorieCountingBOOLCalorie counting support
isSupportHeartRateBOOLHeart rate monitoring support
isSupportBloodPressureBOOLBlood pressure monitoring support
isSupportBloodOxygenBOOLBlood oxygen monitoring support
isSupportStressBOOLStress monitoring support
isSupportSleepBOOLSleep monitoring support
isSupportTemperatureBOOLTemperature monitoring support
isSupportECGBOOLECG monitoring support
isSupportFemaleHealthBOOLFemale health features support
isSupportInitiateWorkoutBOOLInitiate workout feature support
isSupportWeightManagementBOOLWeight management support
isSupportRemindersBOOLReminders support
isSupportCallManagementBOOLCall management support
isSupportAppNotificationsBOOLApp notifications support
isSupportMusicBOOLMusic feature support
isSupportWeatherDisplayBOOLWeather display support
isSupportFindMyPhoneBOOLFind my phone feature support
isSupportAlarmClockBOOLAlarm clock support
isSupportWorldClockBOOLWorld clock support
isSupportMapNavigationBOOLMap navigation support
isSupportShakeCameraBOOLShake to take photo support
isSupportCameraPreviewBOOLCamera video preview support
isSupportEWalletBOOLE-wallet support
isSupportBusinessCardBOOLBusiness card support
isSupportPhotoAlbumBOOLPhoto album support
isSupportEBookBOOLE-book support
isSupportVoiceRecordingBOOLVoice recording support
isSupportAppStoreBOOLApp store support
isSupportMotionGamesBOOLMotion sensing games support
isSupportWorkoutPushBOOLWorkout push support
isSupportERNIEBotBOOLERNIE Bot support
isSupportChatGPTBOOLChatGPT support
isSupportLoversFeatureBOOLLovers feature support
isSupportContactsBOOLContacts feature support
isSupportEmergencyContactsBOOLEmergency contacts support
isSupportMuslimPrayerBOOLMuslim prayer reminders support
isSupportQiblaCompassBOOLQibla compass support
isSupportNFCPaymentBOOLNFC payment support
isSupportVoiceAssistantBOOLVoice assistant support
isSupportFacePushBOOLWatch face push support
isSupportCustomFaceBOOLCustom watch face support
isSupportSlideshowFaceBOOLSlideshow watch face support
isSupportDialComponentBOOLDial component support
isSupportTimeSettingsBOOLTime settings support
isSupportLanguageBOOLLanguage settings support
isSupportUserInfoSettingsBOOLUser information settings support
isSupportDailyActivityBOOLDaily activity support
isSupportFirmwareUpgradeBOOLFirmware upgrade support
isSupportUnitSettingsBOOLUnit settings support
isSupportEarbudsAPIsBOOLEarbuds APIs support
isSupportAIChatBOOLAI chat support
isSupportAIChatAudioUsingScoBOOLAI chat audio using SCO support
isSupportScreenLockBOOLScreen lock support
isSupportGameLockBOOLGame lock support
isSupportHRVBOOLHeart-rate variability support
isSupportEqualizerBOOLEqualizer support
isSupportDeviceLogBOOLDevice log support
isSupportOfflineMapBOOLOffline map support
isSupportEpoBOOLGNSS EPO support

TSPeripheralAIAbility and TSPeripheralFeature​

PropertyTypeDescription
deviceInitiatedScenesTSPeripheralAISceneAI audio-stream scenes the device may initiate
appInitiatedScenesTSPeripheralAISceneAI audio-stream scenes the App may initiate
preferredAIVendorTSAIVendorAI vendor suggested by the device; unknown means no suggestion
supportedFeaturesTSFeatureOptionsProvider-neutral top-level feature bitmask

TSMessageAbility​

Message notification ability managing which specific message types are supported.

PropertyTypeDescription
(No public properties)-All data is encapsulated; use query methods to check support

TSDailyActivityAbility​

Daily activity ability managing which activity types are supported and displayed.

PropertyTypeDescription
(No public properties)-All data is encapsulated; use query methods to check support

TSPeripheralConnectParam​

Connection parameters for device connection and binding.

PropertyTypeDescription
userIdNSString *User ID for device connection (required, must not be empty)
authCodeNSString *Authentication code from QR code scanning during binding
connectTimeoutNSIntegerConnection and authentication timeout; non-positive uses the 30-second default
maxReconnectCountNSIntegerAutomatic retries after an unexpected disconnect; non-positive uses 5
shouldAutoSetTimeBOOLAutomatically set device time after connection; defaults to NO
shouldAutoSetLanguageBOOLAutomatically set device language after connection; defaults to NO
extraParamTSConnectExtraParam *Provider-specific extra parameters

Extra parameter subclasses expose TSFitConnectExtraParam.allowConnectWithBT; TSNpkConnectExtraParam.gender, age, height, and weight; and TSBudsConnectExtraParam.aiLicense and aiVendor.

TSPeripheralScanParam​

Advanced scan parameters for device discovery.

PropertyTypeDescription
userIdNSString *User ID for device connection
serviceUUIDsNSArray<CBUUID *> *Service UUIDs to filter peripherals (nil to discover all)
solicitedServiceUUIDsNSArray<CBUUID *> *Solicited service UUIDs filter (nil to not filter)
bleNameNSString *BLE name filter (nil to discover all)
onlyNamedPeripheralsBOOLOnly return peripherals with a non-empty BLE name (default NO)
macAddressNSString *MAC address filter (nil to discover all)
onlyUnconnectedBOOLOnly return unconnected peripherals (default NO)
allowDuplicatesBOOLAllow duplicate discovery of same peripheral (default NO)
scanTimeoutNSIntegerScan timeout in seconds (0 = no timeout)

TSPeripheralLimitations​

Device feature limitations defining hardware and firmware constraints.

PropertyTypeDescription
maxAlarmCountUInt8Maximum number of alarm clocks (0 = not supported)
maxContactCountUInt8Maximum number of contacts (0 = not supported)
maxEmergencyContactCountUInt8Maximum number of emergency contacts (0 = not supported, 255 = unlimited)
maxPushDialCountUInt8Maximum number of custom watch face slots (0 = not supported)
maxInnerDialCountUInt8Number of pre-installed watch faces
maxWorldClockCountUInt8Maximum number of world clocks (0 = not supported, 255 = unlimited)
maxSedentaryReminderCountUInt8Maximum number of sedentary reminders (0 = not supported, 255 = unlimited)
maxWaterDrinkingReminderCountUInt8Maximum number of water drinking reminders (0 = not supported, 255 = unlimited)
maxMedicationReminderCountUInt8Maximum number of medication reminders (0 = not supported, 255 = unlimited)
maxCustomReminderCountUInt8Maximum number of custom reminders (0 = not supported, 255 = unlimited)
maxAIResponseTextBytesNSUIntegerMaximum UTF-8 byte count for AI response text

TSBluetoothSystem​

Complete Bluetooth system information including both BLE and Classic Bluetooth.

PropertyTypeDescription
bleInfoTSBluetoothInfo *BLE (Bluetooth Low Energy) adapter information
btInfoTSBluetoothInfo *BT (Classic Bluetooth) adapter information

TSBluetoothInfo​

Bluetooth adapter information model.

PropertyTypeDescription
macAddressNSString *Bluetooth MAC address in colon-separated format (may be nil on iOS)
nameNSString *Bluetooth adapter name
statusTSBleStatusBluetooth adapter connection status

Enumerations​

TSPeripheralAIScene​

Values are TSPeripheralAISceneNone, TSPeripheralAISceneChat, TSPeripheralAISceneRecording, TSPeripheralAISceneCallRecording, TSPeripheralAISceneTranslation, TSPeripheralAISceneRideHailing, TSPeripheralAISceneWatchFace, TSPeripheralAISceneQuestionAnswer, TSPeripheralAISceneTranslationSelf, TSPeripheralAISceneTranslationPeer, and the combined TSPeripheralAISceneAll.

TSFeatureOptions​

Top-level feature bits are TSFeatureNone, TSFeatureDailyActivity, TSFeatureHeartRate, TSFeatureHeartRateVariability, TSFeatureBloodPressure, TSFeatureBloodOxygen, TSFeatureStress, TSFeatureSleep, TSFeatureTemperature, TSFeatureElectrocardiogram, TSFeatureFemaleHealth, TSFeatureWorkout, TSFeatureCompanionWorkout, TSFeatureWeightManagement, TSFeatureReminder, TSFeatureCallManagement, TSFeatureMessageNotification, TSFeatureMusic, TSFeatureWeather, TSFeaturePeripheralFind, TSFeatureAlarmClock, TSFeatureWorldClock, TSFeatureNavigation, TSFeatureCamera, TSFeatureECardBag, TSFeaturePayment, TSFeaturePhotoAlbum, TSFeatureEBook, TSFeatureVoiceRecording, TSFeatureAppStore, TSFeatureMotionGame, TSFeatureContact, TSFeatureLovers, TSFeaturePrayer, TSFeatureQiblaCompass, TSFeatureAIChat, TSFeatureVoiceAssistant, TSFeatureDial, TSFeatureTime, TSFeatureLanguage, TSFeatureUserInfo, TSFeatureFirmwareUpgrade, TSFeatureUnit, TSFeatureDeviceSetting, TSFeaturePeripheralLock, TSFeatureBattery, TSFeatureANC, TSFeatureEqualizer, TSFeatureVolume, TSFeatureWearDetection, TSFeatureStorage, TSFeaturePeripheralControl, and TSFeaturePeripheralLog.

New TSPeripheralSupportAbility bits are TSPeripheralSupportNone, TSPeripheralSupportHRV, TSPeripheralSupportMusic, TSPeripheralSupportWorkoutPush, TSPeripheralSupportEqualizer, TSPeripheralSupportDeviceLog, TSPeripheralSupportOfflineMap, and TSPeripheralSupportEpoGnss.

TSBleConnectionState​

Bluetooth connection state during the connection lifecycle.

ValueNameDescription
0eTSBleStateDisconnectedNot connected (initial state or after any failure)
1eTSBleStateConnectingEstablishing BLE physical connection
2eTSBleStateAuthenticatingPerforming bind/login authentication
3eTSBleStatePreparingDataFetching device information after authentication
4eTSBleStateConnectedConnected and ready for data operations

TSScanCompletionReason​

Reasons why BLE scanning completes.

ValueNameDescription
1000eTSScanCompleteReasonTimeoutScan timeout reached
1001eTSScanCompleteReasonBleNotReadyBluetooth not ready
1002eTSScanCompleteReasonPermissionDeniedBluetooth permissions denied
1003eTSScanCompleteReasonUserStoppedUser manually stopped scan
1004eTSScanCompleteReasonSystemErrorSystem error occurred
1005eTSScanCompleteReasonNotSupportBluetooth not supported

TSBleStatus​

Bluetooth adapter connection status.

ValueNameDescription
0TSBleDisconnectedNot connected
1TSBleConnectedConnected (physical connection established)
2TSBleReadyReady (connected and Notify/SPP opened)

TSPeriphShape​

Device physical shape characteristics.

ValueNameDescription
0eTSPeriphShapeUnknowUnknown shape
1eTSPeriphShapeCircleCircular device
2eTSPeriphShapeSquareSquare device
3eTSPeriphShapeVerticalRectangleVertical rectangle device
4eTSPeriphShapeTransverseRectangleHorizontal rectangle device

TSPeripheralSupportAbility​

Bit flags indicating peripheral feature support (uint64_t).

Bit RangeCategoryFlags
0-15Health FeaturesTSPeripheralSupportStepCounting, TSPeripheralSupportDistanceCounting, TSPeripheralSupportCalorieCounting, TSPeripheralSupportHeartRate, TSPeripheralSupportBloodPressure, TSPeripheralSupportBloodOxygen, TSPeripheralSupportStress, TSPeripheralSupportSleep, TSPeripheralSupportTemperature, TSPeripheralSupportECG, TSPeripheralSupportFemaleHealth, TSPeripheralSupportInitiateWorkout, TSPeripheralSupportDailyActivity, TSPeripheralSupportWeightManagement
16-33Smart FeaturesTSPeripheralSupportReminders, TSPeripheralSupportCallManagement, TSPeripheralSupportAppNotifications, TSPeripheralSupportMusicControl, TSPeripheralSupportWeatherDisplay, TSPeripheralSupportFindMyPhone, TSPeripheralSupportAlarmClock, TSPeripheralSupportWorldClock, TSPeripheralSupportMapNavigation, TSPeripheralSupportShakeCamera, TSPeripheralSupportCameraPreview, TSPeripheralSupportEWallet, TSPeripheralSupportBusinessCard, TSPeripheralSupportPhotoAlbum, TSPeripheralSupportEBook, TSPeripheralSupportVoiceRecording, TSPeripheralSupportAppStore, TSPeripheralSupportMotionGames
34-36AI FeaturesTSPeripheralSupportSportUpload, TSPeripheralSupportERNIEBot, TSPeripheralSupportChatGPT
37-39Social FeaturesTSPeripheralSupportLoversFeature, TSPeripheralSupportContacts, TSPeripheralSupportEmergencyContacts
40-41Religious FeaturesTSPeripheralSupportMuslimPrayer, TSPeripheralSupportQiblaCompass
42-46Hardware FeaturesTSPeripheralSupportNFCPayment, TSPeripheralSupportVoiceAssistant, TSPeripheralSupportFacePush, TSPeripheralSupportCustomFace, TSPeripheralSupportSlideshowFace
47-51System SettingsTSPeripheralSupportTimeSettings, TSPeripheralSupportLanguageSettings, TSPeripheralSupportUserInfoSettings, TSPeripheralSupportFirmwareUpgrade, TSPeripheralSupportUnitSettings
52-63ReservedTSPeripheralSupportEarbudsAPIs, TSPeripheralSupportDialComponent, TSPeripheralSupportAIChat, TSPeripheralSupportAIChatAudioUsingSco, TSPeripheralSupportScreenLock, TSPeripheralSupportGameLock

Callback Types​

TSScanDiscoveryBlock​

Device discovery callback during scanning.

typedef void(^TSScanDiscoveryBlock)(TSPeripheral *_Nonnull peripheral);
ParameterTypeDescription
peripheralTSPeripheral *Discovered peripheral with device name, ID, and other information

TSScanCompletionBlock​

Scan completion callback.

typedef void(^TSScanCompletionBlock)(TSScanCompletionReason reason, NSError * _Nullable error);
ParameterTypeDescription
reasonTSScanCompletionReasonReason for scan completion (timeout, user stopped, error, etc.)
errorNSError *Optional error details if scan failed

TSBleConnectionStateBlock​

Bluetooth connection state change callback.

typedef void (^TSBleConnectionStateBlock)(TSBleConnectionState connectionState, NSError *error);
ParameterTypeDescription
connectionStateTSBleConnectionStateCurrent connection state during the connection lifecycle
errorNSError *Optional error for a failed query or state transition

API Reference​

Get current Bluetooth connection state​

- (void)getConnectState:(nullable TSBleConnectionStateBlock)completion;
ParameterTypeDescription
completionTSBleConnectionStateBlockCallback returning current connection state and an optional error

Code Example:

id<TSBleConnectInterface> bleConnect = /* obtained from SDK */;

[bleConnect getConnectState:^(TSBleConnectionState connectionState, NSError *error) {
if (error) {
TSLog(@"Failed to query state: %@", error.localizedDescription);
return;
}
switch (connectionState) {
case eTSBleStateDisconnected:
TSLog(@"Device is not connected");
break;
case eTSBleStateConnecting:
TSLog(@"Device is connecting");
break;
case eTSBleStateAuthenticating:
TSLog(@"Device is authenticating");
break;
case eTSBleStatePreparingData:
TSLog(@"Device is preparing data");
break;
case eTSBleStateConnected:
TSLog(@"Device is connected and ready");
break;
}
}];

Observe connection-state changes​

- (void)registerConnectionStateDidChanged:(nullable TSBleConnectionStateBlock)completion;

This connector-level listener reports connection progress and later changes, including device or system disconnections. Pass nil to unregister it.

[bleConnect registerConnectionStateDidChanged:^(TSBleConnectionState connectionState, NSError *error) {
TSLog(@"Connection state: %ld, error: %@", (long)connectionState, error);
}];

Start searching for Bluetooth devices​

- (void)startSearchPeripheral:(NSTimeInterval)timeout
discoverPeripheral:(TSScanDiscoveryBlock)discoverPeripheral
completion:(TSScanCompletionBlock)completion;
ParameterTypeDescription
timeoutNSTimeIntervalScan timeout in seconds (0 = default 30 seconds)
discoverPeripheralTSScanDiscoveryBlockCallback triggered when a new device is discovered
completionTSScanCompletionBlockCallback when scan completes or times out

Code Example:

id<TSBleConnectInterface> bleConnect = /* obtained from SDK */;

[bleConnect startSearchPeripheral:30.0
discoverPeripheral:^(TSPeripheral *peripheral) {
TSLog(@"Found device: %@", peripheral.systemInfo.bleName);
TSLog(@"MAC: %@", peripheral.systemInfo.mac);
TSLog(@"RSSI: %@", peripheral.systemInfo.RSSI);
} completion:^(TSScanCompletionReason reason, NSError *error) {
if (error) {
TSLog(@"Scan failed with error: %@", error.localizedDescription);
} else {
switch (reason) {
case eTSScanCompleteReasonTimeout:
TSLog(@"Scan timeout");
break;
case eTSScanCompleteReasonUserStopped:
TSLog(@"Scan stopped by user");
break;
default:
TSLog(@"Scan completed with reason: %ld", (long)reason);
}
}
}];

Start searching with advanced parameters​

- (void)startSearchPeripheralWithParam:(TSPeripheralScanParam *)param
discoverPeripheral:(TSScanDiscoveryBlock)discoverPeripheral
completion:(TSScanCompletionBlock)completion;
ParameterTypeDescription
paramTSPeripheralScanParam *Scan parameters including filters and timeout
discoverPeripheralTSScanDiscoveryBlockCallback triggered when a new device is discovered
completionTSScanCompletionBlockCallback when scan completes with reason and optional error

Code Example:

id<TSBleConnectInterface> bleConnect = /* obtained from SDK */;

TSPeripheralScanParam *scanParam = [[TSPeripheralScanParam alloc] init];
scanParam.bleName = @"MyDevice";
scanParam.onlyNamedPeripherals = YES;
scanParam.scanTimeout = 30;
scanParam.allowDuplicates = YES;

[bleConnect startSearchPeripheralWithParam:scanParam
discoverPeripheral:^(TSPeripheral *peripheral) {
TSLog(@"Found device: %@", peripheral.systemInfo.bleName);
} completion:^(TSScanCompletionReason reason, NSError *error) {
if (error) {
TSLog(@"Scan error: %@", error.localizedDescription);
} else {
TSLog(@"Scan completed with reason: %ld", (long)reason);
}
}];

Stop searching for Bluetooth devices​

- (void)stopSearchPeripheral;

Code Example:

id<TSBleConnectInterface> bleConnect = /* obtained from SDK */;

[bleConnect stopSearchPeripheral];
TSLog(@"Scan stopped");

Connect to a Bluetooth device​

- (void)connectWithPeripheral:(TSPeripheral *)peripheral
param:(TSPeripheralConnectParam *)param
completion:(TSCompletionBlock)completion;
ParameterTypeDescription
peripheralTSPeripheral *Peripheral device to connect to
paramTSPeripheralConnectParam *Connection parameters with binding info including user ID
completionTSCompletionBlockOne-shot callback for the final result of this connection request

Code Example:

id<TSBleConnectInterface> bleConnect = /* obtained from SDK */;
TSPeripheral *peripheral = /* discovered peripheral */;

TSPeripheralConnectParam *connectParam = [[TSPeripheralConnectParam alloc] initWithUserId:@"user123"];
connectParam.authCode = @"ABC123";
connectParam.brand = @"Apple";
connectParam.model = @"iPhone 15";
connectParam.systemVersion = @"17.0";

[bleConnect connectWithPeripheral:peripheral
param:connectParam
completion:^(BOOL success, NSError *error) {
if (!success) {
TSLog(@"Connection failed: %@", error.localizedDescription);
return;
}
TSLog(@"Device connected successfully");
}];

Connect by MAC address​

- (void)connectWithMacAddress:(NSString *)macAddress
param:(TSPeripheralConnectParam *)param
completion:(TSCompletionBlock)completion;
ParameterTypeDescription
macAddressNSString *MAC address used by the SDK to scan for the target internally
paramTSPeripheralConnectParam *Connection parameters
completionTSCompletionBlockOne-shot callback for the final connection result

Code Example:

id<TSBleConnectInterface> bleConnect = /* obtained from SDK */;
TSPeripheralConnectParam *connectParam = [[TSPeripheralConnectParam alloc] initWithUserId:@"user123"];

[bleConnect connectWithMacAddress:@"AA:BB:CC:DD:EE:FF"
param:connectParam
completion:^(BOOL success, NSError *error) {
TSLog(@"Connection result: %d, error: %@", success, error);
}];

Disconnect from the currently connected device​

- (void)disconnectCompletion:(TSCompletionBlock)completion;
ParameterTypeDescription
completionTSCompletionBlockCallback that returns disconnection result

Code Example:

id<TSBleConnectInterface> bleConnect = /* obtained from SDK */;

[bleConnect disconnectCompletion:^(BOOL success, NSError *error) {
if (!success) {
TSLog(@"Disconnect failed: %@", error.localizedDescription);
} else {
TSLog(@"Device disconnected successfully");
}
}];

Unbind the currently connected device​

- (void)unbindPeripheralCompletion:(TSCompletionBlock)completion;
ParameterTypeDescription
completionTSCompletionBlockCallback that returns unbinding result

Code Example:

id<TSBleConnectInterface> bleConnect = /* obtained from SDK */;

[bleConnect unbindPeripheralCompletion:^(BOOL success, NSError *error) {
if (!success) {
TSLog(@"Unbind failed: %@", error.localizedDescription);
} else {
TSLog(@"Device unbound successfully");
}
}];

Check if a device is currently connected​

- (BOOL)isConnected;

Code Example:

id<TSBleConnectInterface> bleConnect = /* obtained from SDK */;

if ([bleConnect isConnected]) {
TSLog(@"Device is connected");
} else {
TSLog(@"Device is not connected");
}

Get Bluetooth adapter information​

- (void)getBluetoothInfo:(void(^)(TSBluetoothSystem * _Nullable bluetoothInfo, NSError * _Nullable error))completion;
ParameterTypeDescription
completionvoid(^)(TSBluetoothSystem *, NSError *)Callback returning Bluetooth system information including BLE and BT adapter details

Code Example:

id<TSBleConnectInterface> bleConnect = /* obtained from SDK */;

[bleConnect getBluetoothInfo:^(TSBluetoothSystem *bluetoothInfo, NSError *error) {
if (error) {
TSLog(@"Failed to get Bluetooth info: %@", error.localizedDescription);
return;
}

if (bluetoothInfo.bleInfo) {
TSLog(@"BLE status: %ld", (long)bluetoothInfo.bleInfo.status);
}
if (bluetoothInfo.btInfo) {
TSLog(@"Bluetooth status: %ld", (long)bluetoothInfo.btInfo.status);
}
}];

Important notes​

  1. Stop an active scan before starting another scan.
  2. Use onlyNamedPeripherals and bleName together only when name filtering is required.
  3. Register persistent connection-state observation once and unregister it during teardown.
  4. A one-shot connect completion does not replace registerConnectionStateDidChanged: for later disconnects.
  5. The former reconnectWithPeripheral:... API is no longer public; use either current connection entry point.