Sidewalk
public class Sidewalk
Main entry point to the Amazon Sidewalk Mobile SDK.
Provides access to Amazon Sidewalk device and the Amazon Sidewalk network for registration, secure connection, deregistration, and clear account cache.
-
Closure to be executed when a request has completed.
Declaration
Swift
public typealias Completion<T, E> = (_ result: Result<T, E>) -> Void where E : ErrorParameters
resultResultobject indicating either a success or failure. -
Closure to be executed when a scan discovers a
SidewalkDevice.Declaration
Swift
public typealias ScanResponse = (_ device: SidewalkDevice) -> VoidParameters
deviceA
SidewalkDeviceobject discovered during scanning.
-
A
SidewalkLoggingto capture Amazon Sidewalk Mobile SDK logs.Declaration
Swift
public static var logger: SidewalkLogging? { get set }
-
Creates an instance of
Sidewalk.Declaration
Swift
public convenience init(authProvider: SidewalkAuthProviding, deregisterStrategy: DeregisterStrategy = DefaultDeregisterStrategy())Parameters
authProviderA
SidewalkAuthProvidinginstance that provides the auth token on demand. Amazon Sidewalk Mobile SDK does not keep a strong hold on the instance.deregisterStrategyA
DeregisterStrategyinstance that provides configurable settings for deregistration flow.
-
Starts scanning for Amazon Sidewalk devices via Bluetooth.
Scan for devices advertising AMA characteristics conforming to the Amazon Sidewalk protocol. Only one scan can be in operation at a time. Additional calls will restart scanning and return the same
SidewalkCancellableinstance.Note
This object automatically calls cancel() when deinitialized.Declaration
Swift
public func scan(onDeviceFound: @escaping ScanResponse, completion: Completion<Void, SidewalkError>? = nil) -> SidewalkCancellableParameters
onDeviceFoundA closure that executes when an Amazon Sidewalk device is found.
completionAn optional closure that executes when the scan completes. Currently
scanonly completes when an error occurs, closure returns.failure(SidewalkError)whereSidewalkErrorindicates the the failure cause.Return Value
A
SidewalkCancellableobject that can be used to stop scanning explicitly. -
Authenticate existing devices already in the field onto the Amazon Sidewalk network.
This is part of the Amazon Sidewalk remote certificate provisioning process.
Note
This object automatically calls cancel() when deinitialized.Declaration
Swift
public func remoteCertificateProvisioningAuthenticate(request: CertificateSigningRequest, completion: @escaping Completion<AuthenticatingResponse, SidewalkError>) -> SidewalkCancellableParameters
requestAmazon Sidewalk remote certificate provisioning attested device certificate signing request (srcp_attested_device_csr).
completionA closure that executes when authentication completes. Closure returns
.success(AuthenticatingResponse)if the authentication completes successfully; otherwise.failure(SidewalkError)whereSidewalkErrorindicates the the failure cause.Return Value
A
SidewalkCancellableobject that can be used to stop remote certificate provisioning authentication. -
Clear user related data.
You should call
clearAccountCacheexplicitly when the account credential is no longer available, e.g. user logged out.Declaration
Swift
public func clearAccountCache(completion: @escaping Completion<Void, SidewalkError>)Parameters
completionA closure that executes when deregistration completes. Closure returns
.successif the account cache is cleared successfully; otherwise.failure(SidewalkError)whereSidewalkErrorindicates the the failure cause.
-
Securely connects to a given Amazon Sidewalk device.
Connects to the given Amazon Sidewalk device via BLE, and exchanges encryption keys to create a secure connection.
You can establish a secure connection by the given
SidewalkDevice.truncatedSmsnorSidewalkDevice.fullSmsn(if provided) received fromscan. Amazon Sidewalk Mobile SDK would scan peripherals with the givenSMSNand connect to the device if one found.Note
This object automatically calls cancel() when deinitialized.Declaration
Swift
public func secureConnectDevice(smsn: String, completion: @escaping Completion<SidewalkConnection, SidewalkError>) -> SidewalkCancellableParameters
smsnThe Sidewalk Manufacturing Serial Number(
SMSN) of the device to attempt to connect to. Thesmsncould be either 32-Byte hex string or 5-Byte hex string, for instance, “F123456789”. String with invalid length or character will cause the process to fail directly.completionA closure that executes when the connection is established Closure returns
.success(SidewalkConnection)if the connection is successful; otherwise.failure(SidewalkError)whereSidewalkErrorindicates the the failure cause.Return Value
A
SidewalkCancellableobject that can be used to stop connecting explicitly. -
Registers an Amazon Sidewalk device with the Amazon Sidewalk network. If a
SidewalkConnectionhas been established with the device prior to registration, useregister(connection:completion:)instead.You can register a device by the given
SidewalkDevice.truncatedSmsnreceived fromscan. Amazon Sidewalk Mobile SDK would scan peripherals with the givensmsnand register the device if one found.Process returns directly if the device is already registered to your account; otherwise the Amazon Sidewalk device will disconnect after registration regardless of result. Call
secureConnect()to acquire a newSidewalkConnectionif connection features are still required.Connects to the Amazon Sidewalk device over Bluetooth Low-Energy (BLE). Attempts to register it for use on the Amazon Sidewalk network. Only one registration call can be in operation at a time.
Note
This object automatically calls cancel() when deinitialized.Declaration
Swift
public func registerDevice(smsn: String, completion: Completion<RegistrationDetail, SidewalkError>? = nil) -> SidewalkCancellableParameters
smsnThe Sidewalk Manufacturing Serial Number(
SMSN) of the device to attempt to connect to. Thesmsnis a 5-Byte hex string, for instance, “F123456789”. String with invalid length or character will cause the process to fail directly.completionAn optional closure that executes when registration completes. Closure returns
.success(RegistrationDetail)if the Amazon Sidewalk device is registered successfully; otherwise.failure(SidewalkError)whereSidewalkErrorindicates the the failure cause.Return Value
A
SidewalkCancellableobject that can be used to stop registration. -
Registers an Amazon Sidewalk device with the Amazon Sidewalk network through the BLE secure connection.
Process returns directly if the device is already registered to your account; otherwise the Amazon Sidewalk device will disconnect after registration regardless of result. Call
secureConnect()to acquire a newSidewalkConnectionif connection features are still required.Attempts to register the connected
SidewalkDevicefor use on the Amazon Sidewalk network. Only one registration call can be in operation at a time.Note
This object automatically calls cancel() when deinitialized.Declaration
Swift
public func registerDevice(connection: SidewalkConnection, completion: Completion<RegistrationDetail, SidewalkError>? = nil) -> SidewalkCancellableParameters
connectionA secure BLE connection with an Amazon Sidewalk device.
completionAn optional closure that executes when registration completes. Closure returns
.success(RegistrationDetail)if the Amazon Sidewalk device is registered successfully; otherwise.failure(SidewalkError)whereSidewalkErrorindicates the the failure cause.Return Value
A
SidewalkCancellableobject that can be used to stop registration. -
Deregisters an Amazon Sidewalk device from the Amazon Sidewalk network.
Note
This object automatically calls cancel() when deinitialized.Declaration
Swift
public func deregisterDevice(smsn: String, factoryReset: Bool, completion: @escaping Completion<Void, SidewalkError>) -> SidewalkCancellableParameters
smsnThe Sidewalk Manufacturing Serial Number(
SMSN) of the device to attempt to connect to. Thesmsncould be either 32-Byte hex string or 5-Byte hex string. String with invalid length or character will cause the process to fail directly.factoryResetIf set to true, will attempt to scan for and factory reset the device.
completionA closure that executes when deregistration completes. Closure returns
.successif the Amazon Sidewalk device is de-registered successfully; otherwise.failure(SidewalkError)whereSidewalkErrorindicates the the failure cause.Return Value
A
SidewalkCancellableobject that can be used to stop deregistration.
-
Securely connects to a given Amazon Sidewalk device. NOTE: This method is being deprecated in the near future, please use
secureConnectDevice(smsn:completion:)instead for simpler Amazon Sidewalk device management with consistentsmsnvalue.Connects to the given Amazon Sidewalk device via BLE, and exchanges encryption keys to create a secure connection.
You can establish a secure connection by a given
SidewalkDevicereceived fromscan; or provide aSidewalkDeviceDescriptor, containing devicenameFilterand / orendpointIdFilter. Amazon Sidewalk Mobile SDK would scan peripherals with the given descriptor and connect to the device if one found.Note
This object automatically calls cancel() when deinitialized.Declaration
Swift
@available(*, deprecated, message: "Please use `secureConnectDevice(smsn:completion:﹚` instead for simpler Amazon Sidewalk device management with consistent `smsn` value.") public func secureConnect(device: SidewalkDeviceDescriptor, completion: @escaping Completion<SidewalkConnection, SidewalkError>) -> SidewalkCancellableParameters
deviceThe device to attempt to connect to. Empty device descriptor is not allowed and will cause the process to fail directly.
SidewalkDeviceDescriptorwith nil value or empty string for bothendpointIDFilterandnameFilterwill be considered as emtpy.completionA closure that executes when the connection is established. Closure returns
.success(SidewalkConnection)if the connection is successful; otherwise.failure(SidewalkError)whereSidewalkErrorindicates the the failure cause.Return Value
A
SidewalkCancellableobject that can be used to stop connecting explicitly. -
Registers an Amazon Sidewalk device with the Amazon Sidewalk network. If a
SidewalkConnectionhas been established with the device prior to registration, useregister(connection:completion:)instead. NOTE: This method is being deprecated in the near future, please useregisterDevice(smsn:completion:)instead for simpler Amazon Sidewalk device management with consistentsmsnvalue.You can register a device by a given
SidewalkDevicereceived fromscan; or provide aSidewalkDeviceDescriptor, containing devicenameFilterand / orendpointIdFilter. Amazon Sidewalk Mobile SDK would scan peripherals with the given descriptor and register the device if one found.Deregister with factory reset and re-registration will be performed if the device is already registered to your account. The Amazon Sidewalk device will disconnect after registration regardless of result. Call
secureConnect()to acquire a newSidewalkConnectionif connection features are still required.Connects to the Amazon Sidewalk device over Bluetooth Low-Energy (BLE). Attempts to register it for use on the Amazon Sidewalk network. Only one registration call can be in operation at a time.
Note
This object automatically calls cancel() when deinitialized.Declaration
Swift
@available(*, deprecated, message: "Please use `registerDevice(smsn:completion:﹚` instead for simpler Amazon Sidewalk device management with consistent `smsn` value.") public func register(device: SidewalkDeviceDescriptor, completion: Completion<(WirelessDeviceID, SidewalkID), SidewalkError>? = nil) -> SidewalkCancellableParameters
deviceDevice to attempt registration for. Empty device descriptor is not allowed and will cause the process to fail directly.
SidewalkDeviceDescriptorwith nil value or empty string for bothendpointIDFilterandnameFilterwill be considered as emtpy.completionAn optional closure that executes when registration completes. This closure provides two parameters. Closure returns
.success(WirelessDeviceID, SidewalkID)if the Amazon Sidewalk device is registered successfully, where the first parameter is theWirelessDeviceIDString to be used with the AWS IoT Core service, the second parameter is theSidewalkID; otherwise.failure(SidewalkError)whereSidewalkErrorindicates the the failure cause.Return Value
A
SidewalkCancellableobject that can be used to stop registration. -
Registers an Amazon Sidewalk device with the Amazon Sidewalk network through the BLE secure connection. NOTE: This method is being deprecated in the near future, please use
registerDevice(connection:completion:)instead for simpler Amazon Sidewalk device management with consistentsmsnvalue.Deregister with factory reset and re-registration will be performed if the device is already registered to your account. The Amazon Sidewalk device will disconnect after registration regardless of result. Call
secureConnect()to acquire a newSidewalkConnectionif connection features are still required.Attempts to register the connected
SidewalkDevicefor use on the Amazon Sidewalk network. Only one registration call can be in operation at a time.Note
This object automatically calls cancel() when deinitialized.Declaration
Swift
@available(*, deprecated, message: "Please use `registerDevice(connection:completion:﹚` instead for simpler Amazon Sidewalk device management with consistent `smsn` value.") public func register(connection: SidewalkConnection, completion: Completion<(WirelessDeviceID, SidewalkID), SidewalkError>? = nil) -> SidewalkCancellableParameters
connectionA secure BLE connection with an Amazon Sidewalk device.
completionAn optional closure that executes when registration completes. Closure returns
.success(WirelessDeviceID, SidewalkID)if the Amazon Sidewalk device is registered successfully, where the first parameter is theWirelessDeviceIDString to be used with the AWS IoT Core service, the second parameter is theSidewalkID; otherwise.failure(SidewalkError)whereSidewalkErrorindicates the the failure cause.Return Value
A
SidewalkCancellableobject that can be used to stop registration. -
Deregisters an Amazon Sidewalk device from the Amazon Sidewalk network. NOTE: This method is being deprecated in the near future, please use
deregisterDevice(smsn:factoryReset:completion:)instead for simpler Amazon Sidewalk device management with consistentsmsnvalue.Note
This object automatically calls cancel() when deinitialized.Declaration
Swift
@available(*, deprecated, message: "Please use `deregisterDevice(smsn:factoryReset:completion:﹚` instead for simpler Amazon Sidewalk device management with consistent `smsn` value.") public func deregister(sidewalkID: SidewalkID, factoryReset: Bool, completion: @escaping Completion<Void, SidewalkError>) -> SidewalkCancellableParameters
sidewalkIDA device’s ID to deregister.
factoryResetIf set to true, will attempt to scan for and factory reset the device.
completionA closure that executes when deregistration completes. Closure returns
.successif the Amazon Sidewalk device is de-registered successfully; otherwise.failure(SidewalkError)whereSidewalkErrorindicates the the failure cause.Return Value
A
SidewalkCancellableobject that can be used to stop deregistration.