SidewalkConnection

Represents a BLE connection with a Sidewalk device.

This class is created when the Sidewalk Mobile SDK is able to create a secure connection with a Sidewalk device.

The connection might be terminated by Sidewalk device if no traffic for an amount of time to prevent BLE resources occupation. The time is configurable by Sidewalk device.

Before releasing SidewalkConnection object, you should make sure the ongoing operation like startCoverageTest is properly cancelled by calling cancel() on the corresponding SidewalkCancellable object and waiting for the corresponding completion closure to be invoked. Otherwise, cancel() operation may be interrupted since the connection with Sidewalk device is disconnected.

Note

This object automatically disconnects when deinitialized.

Public Methods

  • Availability of the Sidewalk connection.

    Return true if the connection is available to write/subscribe messages, false otherwise.

  • Subscribe to SidewalkMessages received from the Sidewalk connection and get notification from the completion callback on connection termination.

    Monitors the Sidewalk device over BLE, calls onMessageReceived for SidewalkMessages destined to the mobile service, and calls completion when the connection terminates to inform error on failure case.

    Note

    This object automatically calls cancel() when deinitialized.
  • Writes a SidewalkMessage to a Sidewalk device.

    Writes a SidewalkMessage over the secure BLE connection.

    Note

    This object automatically calls cancel() when deinitialized.
  • Start coverage test on the device in the connection.

    When coverage test is started, Sidewalk device will start ping-pong tests, and send corresponding logs to mobile. During the progress, Sidewalk Mobile SDK will provide update via onProgressUpdated closure with event. When coverage test is ended, Sidewalk Mobile SDK will collect report from Sidewalk device, and send the result via completion closure.

    To stop the coverage test properly after this method is called, you should call cancel() on the returned SidewalkCancellable, and hold the SidewalkConnection object until the completion closure passed in this method is invoked.

    Note

    This object automatically calls cancel() when deinitialized.

  • Disconnects from the SidewalkDevice.

    This is also called automatically by the SDK when the SidewalkConnection class is de-initialized.