#include <rfcomm.h>
Public Member Functions | |
RfcommService * | GetService (void) const |
Query the service associated with the session. | |
rfcomm_secmode_t | GetSecMode (void) const |
Query the security mode of the connection to the device. | |
bool | IsAutoReconnect (void) const |
Query whether the autoreconnect mechanism is enabled for this device. | |
void | SetAutoReconnect (bool enable) |
Enable or disable the autoreconnect mechanism for this device. | |
bool | IsConnectionRemoteInitiated (void) const |
Query whether an in-progress or complete connection to the device was initiated by the device. | |
bool | IsPriorDisconnectVoluntary (void) const |
Query whether the last disconnection was voluntary or involuntary. | |
BtDevice * | GetDevice (void) const |
Query the BtDevice associated with the session. | |
void | Disconnect (bool voluntary=true) |
Request disconnection of the session. | |
BtHub * | GetHub (void) const |
DispatchInterface * | GetDi (void) const |
void * | GetPrivate (void) const |
Query the private pointer associated with the object. | |
void | SetPrivate (void *priv) |
Assign the private pointer associated with the object. | |
void | Get (void) |
Increment the reference count. | |
void | Put (void) |
Decrement the reference count. | |
Public Attributes | |
Callback< void, BtManaged * > | cb_NotifyDestroy |
Object destruction notification callback. |
RfcommSession is a proto-session that contains utility code useful for creating a service handler for an RFCOMM profile. It works in conjunction with RfcommService.
RfcommService* GetService | ( | void | ) | const [inline] |
Query the service associated with the session.
Reimplemented from BtSession.
Reimplemented in HfpSession.
rfcomm_secmode_t GetSecMode | ( | void | ) | const [inline] |
Query the security mode of the connection to the device.
For information on the security mode, see rfcomm_secmode_t.
If the device is connected, this accessor will return the security mode associated with the socket.
Security modes are configured at the service level, as they must be set at the socket level prior to connection in order to take effect. For inbound connections, the service object is the keeper of the one listening socket that accepts inbound connections and assigns their security modes.
While it may be possible to try to manage security modes at the level of each session, at least for outbound connections, no compelling reasons have been identified at the time of this writing and management only at the level of the service is supported.
bool IsAutoReconnect | ( | void | ) | const [inline] |
Query whether the autoreconnect mechanism is enabled for this device.
true | Autoreconnect is enabled | |
false | Autoreconnect is disabled. |
void SetAutoReconnect | ( | bool | enable | ) |
Enable or disable the autoreconnect mechanism for this device.
If enabled, whenever the device is disconnected, a reconnection attempt will be made periodically through a timer. Auto-reconnection is useful for devices such as phones that regularly move in and out of range.
This function can affect the life cycle management of the object it is called on.
enable | Set to true to enable, false to disable. |
bool IsConnectionRemoteInitiated | ( | void | ) | const [inline] |
Query whether an in-progress or complete connection to the device was initiated by the device.
This is useful for connection auditing logic, e.g. to refuse connections from unknown devices.
true | The device initiated the connection | |
false | The local UI or autoreconnect mechanism initiated the connection |
bool IsPriorDisconnectVoluntary | ( | void | ) | const [inline] |
Query whether the last disconnection was voluntary or involuntary.
When a connection is explicitly broken, e.g. selecting a disconnect function on the device or calling Disconnect(), it is considered voluntary. When a connection fails for implicit reasons such as a device moving out of radio range or an HCI being disconnected, it is considered involuntary. This function reports whether the last transition from the Connecting or Connected state to the Disconnected state was voluntary.
true | The last transition to the Disconnected state was voluntary. | |
false | The last transition to the Disconnected state was involuntary. |
BtDevice* GetDevice | ( | void | ) | const [inline, inherited] |
void Disconnect | ( | bool | voluntary = true |
) | [inline, inherited] |
Request disconnection of the session.
This abstract interface allows one to request any connection-oriented session object derived from BtSession to disconnect itself.
voluntary | Whether the disconnection should be presented as voluntary and explicit, i.e. selecting disconnect on a list, or involuntary, i.e. exiting Bluetooth radio range. |
DispatchInterface* GetDi | ( | void | ) | const [inline, inherited] |
Query the dispatcher interface of the presiding BtHub
void* GetPrivate | ( | void | ) | const [inline, inherited] |
Query the private pointer associated with the object.
All BtManaged derived objects have a single pointer field reserved for the use of clients. It is always initialized to zero when the object is constructed, and clients may assign it as they wish.
void SetPrivate | ( | void * | priv | ) | [inline, inherited] |
Assign the private pointer associated with the object.
All BtManaged derived objects have a single pointer field reserved for the use of clients. It is always initialized to zero when the object is constructed, and clients may assign it as they wish.
priv | New value to assign to the private pointer |
void Get | ( | void | ) | [inline, inherited] |
Increment the reference count.
As per managed objects, BtManaged derived objects are not deleted so long as they have a positive reference count.
void Put | ( | void | ) | [inherited] |
Decrement the reference count.
As per managed objects, when the object's reference count reaches zero, the object will be destroyed in the context of a timer event.
Callback<void, BtManaged*> cb_NotifyDestroy [inherited] |
Object destruction notification callback.
This callback is invoked proir to deletion of the managed object, so that clients may release associated resources. This callback occurs in the context of a timer event, and complies with the rule of not invoking client callbacks in a nested fashion.
The decision to destroy the object is final. The client may not attempt to preserve the object by acquiring additional references from this callback.