public final class RangingSession
- Object
- RangingSession
One ranging conversation with one peer or accessory, obtained from
Ranging.prepareSession.
A prepared session has a getLocalToken() to publish and is not yet
using the radio. It starts measuring when start or startAccessory
is called and keeps going until stop(), until the platform
invalidates it, or until the app exits.
Sessions are not reusable: once stopped or invalidated, prepare another.
Methods
public RangingToken getLocalToken() | The token to publish so the peer can range against this device. |
public RangingRole getRole() | Which end of the session this device is. |
public boolean isRunning() | true while the radio is measuring. |
public AsyncResource<RangingSession> start(RangingToken peerToken) | Starts ranging against a peer whose token arrived out of band. |
public AsyncResource<byte[]> startAccessory(byte[] accessoryConfigurationData) | Starts ranging against a third-party UWB accessory. |
public void stop() | Stops measuring and releases the radio. |
public void addRangingListener(RangingListener l) | Registers a listener. |
public void removeRangingListener(RangingListener l) | Removes a listener added by addRangingListener. |
Inherited methods
Method details
getLocalToken
public RangingToken getLocalToken()Returns
getRole
public RangingRole getRole()Returns
isRunning
public boolean isRunning()start
public AsyncResource<RangingSession> start(RangingToken peerToken)Parameters
peerTokenRangingToken- the peer’s token, decoded from the bytes they published
Returns
NearbyExceptionstartAccessory
public AsyncResource<byte[]> startAccessory(byte[] accessoryConfigurationData)Starts ranging against a third-party UWB accessory.
The accessory publishes a blob of configuration data over its own channel – in practice a GATT characteristic. Hand those bytes here, and send whatever this resolves with back to the accessory: Apple’s Nearby Interaction Accessory Protocol needs that second half of the handshake before the accessory begins ranging.
Android has no equivalent protocol. There, an accessory simply names
the channel and session to join, so build a token with
RangingToken.forUwbAddress and call start instead; this method
fails with NearbyError.NOT_SUPPORTED.
Parameters
accessoryConfigurationDatabyte[]- what the accessory published
Returns
stop
public void stop()addRangingListener
public void addRangingListener(RangingListener l)Parameters
lRangingListener- the listener to add
removeRangingListener
public void removeRangingListener(RangingListener l)addRangingListener.Parameters
lRangingListener- the listener to remove