ADC Home > Reference Library > Reference > Hardware & Drivers > Bluetooth > Bluetooth Framework Reference
|
IOBluetoothL2CAPChannel |
Inherits from: | IOBluetoothObject |
Declared In: |
An instance of IOBluetoothL2CAPChannel represents a single open L2CAP channel.
A client won't create IOBluetoothL2CAPChannel objects directly. Instead, the IOBluetoothDevice's L2CAP channel open API is responsible for opening a new L2CAP channel and returning an IOBluetoothL2CAPChannel instance representing that newly opened channel. Additionally, the IOBluetooth notification system will send notifications when new L2CAP channels are open (if requested).
After a new L2CAP channel is opened, the L2CAP configuration process will not be completed until an incoming data listener is registered with the IOBluetoothL2CAPChannel object. The reason for this is to due to the limited buffering done of incoming L2CAP data. This way, we avoid the situation where incoming data is received before the client is ready for it. Once a client is done with an IOBluetoothL2CAPChannel that it opened, it should call -closeChannel. Additionally, if the client does not intend to use the connection to the remote device any further, it should call -closeConnection on the IOBluetoothDevice object.
Initiates the close process on an open L2CAP channel.
Returns the IOBluetoothDevice to which the target L2CAP channel is open.
Returns the current incoming MTU for the L2CAP channel.
Returns an IOBluetoothL2CAPChannelRef representation of the target IOBluetoothL2CAPChannel object.
Returns the local L2CAP channel ID for the target L2CAP channel.
Returns the IOBluetoothObjectID of the given IOBluetoothL2CAPChannel.
Returns the current outgoing MTU for the L2CAP channel.
Returns the PSM for the target L2CAP channel.
Returns the remote L2CAP channel ID for the target L2CAP channel.
Returns TRUE if the channel is an incoming channel.
Allows a client to register for a channel close notification.
Allows a client to register for L2CAP channel open notifications for any L2CAP channel.
Allows a client to register for L2CAP channel open notifications for certain types of L2CAP channels.
***WARNING*** This method is being deprecated in favor of -setDelegate: Allows a client to register a callback that gets called when new incoming data arrives.
Initiates the process to reconfigure the L2CAP channel with a new outgoing MTU.
Allows an object to register itself as client of the L2CAP channel.
Allows an object to register itself as client of the L2CAP channel.
Method call to convert an IOBluetoothL2CAPChannelRef into an IOBluetoothL2CAPChannel *.
Returns the IObluetoothL2CAPChannel with the given IOBluetoothObjectID.
Writes the given data over the target L2CAP channel to the remote device.
Writes the given data over the target L2CAP channel asynchronously to the remote device.
Writes the given data synchronously over the target L2CAP channel to the remote device.
closeChannel |
Initiates the close process on an open L2CAP channel.
- (IOReturn)closeChannel;
Returns kIOReturnSuccess on success.
This method may only be called by the client that opened the channel in the first place. In the future asynchronous and synchronous versions will be provided that let the client know when the close process has been finished.
getDevice |
Returns the IOBluetoothDevice to which the target L2CAP channel is open.
- (IOBluetoothDevice *)getDevice;
Returns the IOBluetoothDevice to which the target L2CAP channel is open.
getIncomingMTU |
Returns the current incoming MTU for the L2CAP channel.
- (BluetoothL2CAPMTU)getIncomingMTU;
Returns the current incoming MTU for the L2CAP channel.
The incoming MTU represents the maximum L2CAP packet size for packets being sent by the remote device.
getL2CAPChannelRef |
Returns an IOBluetoothL2CAPChannelRef representation of the target IOBluetoothL2CAPChannel object.
- (IOBluetoothL2CAPChannelRef)getL2CAPChannelRef;
Returns an IOBluetoothL2CAPChannelRef representation of the target IOBluetoothL2CAPChannel object.
getLocalChannelID |
Returns the local L2CAP channel ID for the target L2CAP channel.
- (BluetoothL2CAPChannelID)getLocalChannelID;
Returns the local L2CAP channel ID for the target L2CAP channel.
getObjectID |
Returns the IOBluetoothObjectID of the given IOBluetoothL2CAPChannel.
- (IOBluetoothObjectID)getObjectID;
Returns the IOBluetoothObjectID of the given IOBluetoothL2CAPChannel.
The IOBluetoothObjectID can be used as a global reference for a given IOBluetoothL2CAPChannel. It allows two separate applications to refer to the same IOBluetoothL2CAPChannel.
getOutgoingMTU |
Returns the current outgoing MTU for the L2CAP channel.
- (BluetoothL2CAPMTU)getOutgoingMTU;
Returns the current outgoing MTU for the L2CAP channel.
The outgoing MTU represents the maximum L2CAP packet size for packets being sent to the remote device.
getPSM |
Returns the PSM for the target L2CAP channel.
- (BluetoothL2CAPPSM)getPSM;
Returns the PSM for the target L2CAP channel.
getRemoteChannelID |
Returns the remote L2CAP channel ID for the target L2CAP channel.
- (BluetoothL2CAPChannelID)getRemoteChannelID;
Returns the remote L2CAP channel ID for the target L2CAP channel.
isIncoming |
Returns TRUE if the channel is an incoming channel.
- (BOOL)isIncoming;
Returns TRUE if the channel is an incoming channel.
An incoming channel is one that was initiated by a remote device.
registerForChannelCloseNotification:selector: |
Allows a client to register for a channel close notification.
- (IOBluetoothUserNotification *) registerForChannelCloseNotification:(id)observer selector:(SEL)inSelector;
observer
Target observer object
inSelector
Selector to be sent to the observer when the L2CAP channel is closed.
Returns an IOBluetoothUserNotification representing the outstanding L2CAP channel close notification. To unregister the notification, call -unregister of the returned IOBluetoothUserNotification object. If an error is encountered creating the notification, nil is returned.
The given selector will be called on the target observer when the L2CAP channel is closed. The selector should contain two arguments. The first is the user notification object. The second is the IOBluetoothL2CAPChannel that was closed.
registerForChannelOpenNotifications:selector: |
Allows a client to register for L2CAP channel open notifications for any L2CAP channel.
+ (IOBluetoothUserNotification *) registerForChannelOpenNotifications:(id)object selector:(SEL)selector;
object
Target object
selector
Selector to be called on the target object when a new L2CAP channel is opened.
Returns an IOBluetoothUserNotification representing the outstanding L2CAP channel notification. To unregister the notification, call -unregister on the resulting IOBluetoothUserNotification object. If an error is encountered creating the notification, nil is returned. The returned IOBluetoothUserNotification will be valid for as long as the notification is registered. It is not necessary to retain the result. Once -unregister is called on it, it will no longer be valid.
The given selector will be called on the target object whenever any L2CAP channel is opened. The selector should accept two arguments. The first is the user notification object. The second is the IOBluetoothL2CAPChannel that was opened.
registerForChannelOpenNotifications:selector:withPSM:direction: |
Allows a client to register for L2CAP channel open notifications for certain types of L2CAP channels.
+ (IOBluetoothUserNotification *) registerForChannelOpenNotifications:(id)object selector:(SEL)selector withPSM:(BluetoothL2CAPPSM)psm direction:(IOBluetoothUserNotificationChannelDirection)inDirection;
object
Target object
selector
Selector to be called on the target object when a new L2CAP channel is opened.
psm
PSM to match a new L2CAP channel. If the PSM doesn't matter, 0 may be passed in.
inDirection
The desired direction of the L2CAP channel - kIOBluetoothUserNotificationChannelDirectionAny if the direction doesn't matter.
Returns an IOBluetoothUserNotification representing the outstanding L2CAP channel notification. To unregister the notification, call -unregister on the resulting IOBluetoothUserNotification object. If an error is encountered creating the notification, nil is returned. The returned IOBluetoothUserNotification will be valid for as long as the notification is registered. It is not necessary to retain the result. Once -unregister is called on it, it will no longer be valid.
The given selector will be called on the target object whenever an L2CAP channel with the given attributes is opened. The selector should accept two arguments. The first is the user notification object. The second is the IOBluetoothL2CAPChannel that was opened.
registerIncomingDataListener:refCon: |
***WARNING*** This method is being deprecated in favor of -setDelegate: Allows a client to register a callback that gets called when new incoming data arrives.
- (IOReturn)registerIncomingDataListener:(IOBluetoothL2CAPChannelIncomingDataListener)listener refCon:(void *)refCon DEPRECATED_IN_BLUETOOTH_VERSION_2_0_AND_LATER;
listener
Callback function that gets called when new incoming data is received.
refCon
Client-supplied reference that gets passed to the listener function.
Returns kIOReturnSuccess if the listener is successfully registered.
A newly opened L2CAP channel will not complete its configuration process until the client that opened it registers an incoming data listener. This prevents that case where incoming data is received before the client is ready. The incoming data listener callback is currently a C function. In the future, API will be available that allows an objective-c listener to be set.
requestRemoteMTU: |
Initiates the process to reconfigure the L2CAP channel with a new outgoing MTU.
- (IOReturn)requestRemoteMTU:(BluetoothL2CAPMTU)remoteMTU;
remoteMTU
The desired outgoing MTU.
Returns kIOReturnSuccess if the channel re-configure process was successfully initiated.
Currently, this API does not give an indication that the re-config process has completed. In the future additional API will be available to provide that information both synchronously and asynchronously.
setDelegate: |
Allows an object to register itself as client of the L2CAP channel.
- (IOReturn)setDelegate:(id)channelDelegate;
channelDelegate
the object that will play the role of channel delegate [NOTE the l2cap channel will retain the delegate].
Returns kIOReturnSuccess if the delegate is successfully registered.
A channel delegate is the object the L2CAP channel uses as target for data and events. The developer will implement only the the methods he/she is interested in. A list of the possible methods is at the end of this file in the definition of the informal protocol IOBluetoothL2CAPChannelDelegate. A newly opened L2CAP channel will not complete its configuration process until the client that opened it registers a connectionHandler. This prevents that case where incoming data is received before the client is ready.
NOTE: This method is only available in Mac OS X 10.2.5 (Bluetooth v1.2) or later.
setDelegate:withConfiguration: |
Allows an object to register itself as client of the L2CAP channel.
- (IOReturn)setDelegate:(id)channelDelegate withConfiguration:(NSDictionary*)channelConfiguration;
channelDelegate
the object that will play the role of channel delegate.
channelConfiguration
the dictionary that describes the initial configuration for the channel.
Returns kIOReturnSuccess if the delegate is successfully registered.
A channel delegate is the object the L2CAP channel uses as target for data and events. The developer will implement only the the methods he/she is interested in. A list of the possible methods is at the end of this file in the definition of the informal protocol IOBluetoothL2CAPChannelDelegate. A newly opened L2CAP channel will not complete its configuration process until the client that opened it registers a connectionHandler. This prevents that case where incoming data is received before the client is ready.
NOTE: This method is only available in Mac OS X 10.5 (Bluetooth v2.0) or later.
withL2CAPChannelRef: |
Method call to convert an IOBluetoothL2CAPChannelRef into an IOBluetoothL2CAPChannel *.
+ (IOBluetoothL2CAPChannel *)withL2CAPChannelRef:(IOBluetoothL2CAPChannelRef)l2capChannelRef;
l2capChannelRef
IOBluetoothL2CAPChannelRef for which an IOBluetoothL2CAPChannel * is desired.
Returns the IOBluetoothL2CAPChannel * for the given IOBluetoothL2CAPChannelRef.
withObjectID: |
Returns the IObluetoothL2CAPChannel with the given IOBluetoothObjectID.
+ (IOBluetoothL2CAPChannel *)withObjectID:(IOBluetoothObjectID)objectID;
objectID
IOBluetoothObjectID of the desired IOBluetoothL2CAPChannel.
Returns the IOBluetoothL2CAPChannel that matches the given IOBluetoothObjectID if one exists. If no matching L2CAP channel exists, nil is returned.
The IOBluetoothObjectID can be used as a global reference for a given IOBluetoothL2CAPChannel. It allows two separate applications to refer to the same IOBluetoothL2CAPChannel object.
write:length: |
Writes the given data over the target L2CAP channel to the remote device.
- (IOReturn)write:(void *)data length:(UInt16)length DEPRECATED_IN_BLUETOOTH_VERSION_2_0_AND_LATER;
data
Pointer to the buffer containing the data to send.
length
The length of the given data buffer.
Returns kIOReturnSuccess if the data was written successfully.
***WARNING*** This method is being deprecated in favor of -writeSync:... and -writeAsync:... The length of the data may not exceed the L2CAP channel's ougoing MTU. The fact that this method has returned doesn't mean that the data has been delivered successfully. It just means that it has been scheduled to be delivered. In the future, additional API will be available to provide a notification that the write has been completed (both synchronously and asynchronously). This method may block if previous writes have not been delivered.
writeAsync:length:refcon: |
Writes the given data over the target L2CAP channel asynchronously to the remote device.
- (IOReturn)writeAsync:(void *)data length:(UInt16)length refcon:(void*)refcon;
data
Pointer to the buffer containing the data to send.
length
The length of the given data buffer.
refcon
User supplied value that gets passed to the write callback.
Returns kIOReturnSuccess if the data was buffered successfully.
The length of the data may not exceed the L2CAP channel's ougoing MTU. When the data has been successfully passed to the hardware to be transmitted, the delegate method -l2capChannelWriteComplete:refcon:status: will be called with the refcon passed into this method.
NOTE: This method is only available in Mac OS X 10.2.5 (Bluetooth v1.2) or later.
writeSync:length: |
Writes the given data synchronously over the target L2CAP channel to the remote device.
- (IOReturn)writeSync:(void *)data length:(UInt16)length;
data
Pointer to the buffer containing the data to send.
length
The length of the given data buffer.
Returns kIOReturnSuccess if the data was written successfully.
The length of the data may not exceed the L2CAP channel's ougoing MTU. This method will block until the data has been successfully sent to the hardware for transmission (or an error occurs).
NOTE: This method is only available in Mac OS X 10.2.5 (Bluetooth v1.2) or later.
|
Last Updated: 2008-08-07