Modules.BLE.L2CAPChannel
L2Cap allow us to open a side channel, with it we can directly read and write without any framing limitation, packet size limitations. It’s a direct way to talk between our devices and accessories.
L2Cap Channel on the lowest level is the stream of data between two devices. It’s actually the protocol that has been used underneath for all types of communication between two devices. So L2Cap has been used from the first day of Bluetooth communications. but now with the L2CAP class, we use is directly talk over these channels.
Extends: Titanium.Proxy · Since: 1.1.0, 1.0.0, 1.0.0 · Platforms: android, iphone, ipad
Properties #
Methods #
getReadBufferSize #
Get the size of the read buffer in bytes.
Returns: Number — Size of the read buffer in bytes.
setReadBufferSize #
Sets the size of the read buffer in bytes.
You can set the read buffer size at any time, but it will only take effect during the next read.
By default, the buffer size is 1024 bytes.
| Name | Type | Summary | Optional |
|---|---|---|---|
size | Number | The desired size of the read buffer in bytes. | No |
write #
write data to channel
| Name | Type | Summary | Optional |
|---|---|---|---|
data | Titanium.Buffer | Titanium.Buffer object to write data on channel | No |
Returns: void
Events #
onDataReceived #
Fired whenever new data recived on channel.
| Name | Type | Summary |
|---|---|---|
data | Titanium.Buffer | Titanium.Buffer object which represent the read data |
onStreamEndEncountered #
Fired whenever the end of the stream has been reached.
onStreamError #
Fired whenever there is some error in reading or writing.
| Name | Type | Summary |
|---|---|---|
errorCode | String | The error code |
errorDomain | String | The error domain |
errorDescription | String | The error description |