Skip to main content

Remote Control (TSRemoteControl)

The TSRemoteControl module provides remote control capabilities for the device, including restart, shutdown, and factory reset. It is useful for device management, troubleshooting, and device recycling scenarios.

Prerequisites

  1. TopStepComKit SDK has been successfully initialized
  2. A Bluetooth connection with the peripheral device has been established
  3. The peripheral device supports remote control

Callback Types

CallbackDescription
TSCompletionBlockGeneric completion callback. A nil error indicates success; otherwise it contains error details

Interface Methods

1. Device Control

Restart Device

Sends a restart command to the device; the device will reboot immediately.

- (void)restartDevice:(TSCompletionBlock)completion;

Parameters

NameTypeDescription
completionTSCompletionBlockCalled when the command is sent. A nil error means the command was sent successfully

Example

id<TSRemoteControlInterface> remoteControl = [TopStepComKit sharedInstance].remoteControl;

[remoteControl restartDevice:^(NSError *_Nullable error) {
if (!error) {
TSLog(@"Restart command sent; the device is rebooting");
// Bluetooth will disconnect after restart. Consider listening for connection state changes.
} else {
TSLog(@"Failed to send restart command: %@", error.localizedDescription);
}
}];

Shutdown

Sends a shutdown command to the device; the device will power off immediately.

- (void)shutdownDevice:(TSCompletionBlock)completion;

Parameters

NameTypeDescription
completionTSCompletionBlockCalled when the command is sent. A nil error means the command was sent successfully

Example

id<TSRemoteControlInterface> remoteControl = [TopStepComKit sharedInstance].remoteControl;

[remoteControl shutdownDevice:^(NSError *_Nullable error) {
if (!error) {
TSLog(@"Shutdown command sent; the device is powering off");
} else {
TSLog(@"Failed to send shutdown command: %@", error.localizedDescription);
}
}];

Factory Reset

Sends a factory-reset command; all user data and configuration on the device will be cleared. This operation is irreversible.

- (void)factoryResetDevice:(TSCompletionBlock)completion;

Parameters

NameTypeDescription
completionTSCompletionBlockCalled when the command is sent. A nil error means the command was sent successfully

Example

id<TSRemoteControlInterface> remoteControl = [TopStepComKit sharedInstance].remoteControl;

// Show a confirmation dialog before calling this.
[remoteControl factoryResetDevice:^(NSError *_Nullable error) {
if (!error) {
TSLog(@"Factory reset command sent; device data is being erased");
// The device will reboot after factory reset and the Bluetooth connection will drop.
} else {
TSLog(@"Factory reset failed: %@", error.localizedDescription);
}
}];

Notes

  1. Send vs. execution: The TSCompletionBlock callback indicates only that the command was sent successfully; it does not guarantee the device has finished the corresponding operation.
  2. Connection state changes: The Bluetooth connection drops after restart and shutdown. Consider listening for connection state changes via TSBleConnectInterface.
  3. Factory reset is irreversible: It wipes all user data and configuration from the device. Always show a confirmation dialog before invoking it.
  4. Use with care in production: All three operations are high-risk. Invoke only with explicit user authorization and keep audit logs where appropriate.