class UARTBTService : DeviceBluetoothServiceDelegate, UARTServiceInterface
The UART BT Service uses the DeviceBluetoothService and defined UART Characteristics to provide an UART-Like Interface to communicate with a device. Basically it needs 4 Characteristics:
Basically one additional job the class is providing is to allow longer packages than maxPackageLength by cutting packages and sending them as chunks. There is no retrying done in this class and there is no configuration by this. It will also block sending for a small amount of time when the other device ran out of buffer space, see ModemOut Characteristic. It will disconnect if the uart is blocked longer than UART_BLOCKED_TIMEOUT.
Author
NIMMSTA Team
Copyright
NIMMSTA GmbH & IBPG 2020
License
NIMMSTA GmbH
<init> |
The UART BT Service uses the DeviceBluetoothService and defined UART Characteristics to provide an UART-Like Interface to communicate with a device. Basically it needs 4 Characteristics: UARTBTService(deviceService: DeviceBluetoothService, modemInCharacteristic: BluetoothGattCharacteristic, modemOutCharacteristic: BluetoothGattCharacteristic, readCharacteristic: BluetoothGattCharacteristic, writeCharacteristic: BluetoothGattCharacteristic, debugCharacteristic: BluetoothGattCharacteristic?, terminatorCharacteristic: BluetoothGattCharacteristic?, versionCharacteristic: BluetoothGattCharacteristic?) |
allowChangeTerminator |
val allowChangeTerminator: Boolean |
communicationModuleVersion |
var communicationModuleVersion: Version? |
connected |
val connected: Boolean |
connectionService |
val connectionService: Any? |
delegate |
var delegate: UARTServiceDelegate? |
deviceAddress |
val deviceAddress: DeviceAddress |
maxNumberOfRequestsWithoutAck |
number of requests at same time allowed val maxNumberOfRequestsWithoutAck: Int |
maxPacketSize |
val maxPacketSize: Int |
protocolLog |
val protocolLog: String |
terminator |
var terminator: Byte |
changeTerminator |
Changes the terminator used by the service. It will write it to the TerminatorCharacteristic if available. fun changeTerminator(newTerminator: Byte): Task<Unit> |
closeConnection |
closes the connection and clears all buffers fun closeConnection(: Reason?): Task<Unit> |
communicationModuleVersion |
fun communicationModuleVersion(): Task<String?> |
didConnect |
fun didConnect(): Unit |
didDisconnect |
fun didDisconnect(: Reason): Unit |
enableNotifications |
enables notifications for the characteristics on the HS 50. fun enableNotifications(): Task<Unit> |
onCharacteristicChanged |
fun onCharacteristicChanged(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic): Unit |
onConnectionStateChange |
fun onConnectionStateChange(gatt: BluetoothGatt, status: Int, newState: Int): Unit |
onError |
fun onError(throwable: Throwable): Unit |
send |
send a message. This service has two queues. One Priority queue and one normal. Messages are sent FIFO and priority message queue is emptied before normal queue. fun send(: EncodedMessage, : Boolean, : CancellationToken?): Task<Unit> |
MAX_LOGS_TO_STORE |
const val MAX_LOGS_TO_STORE: Int |
READ_ATTEMPTS |
const val READ_ATTEMPTS: Int |
UART_BLOCKED_TIMEOUT |
val UART_BLOCKED_TIMEOUT: TimeSpan |
findUARTServiceInDevice |
tries to find the UART Service with a given device bluetooth service and service definition. It will retry up to 3 times if it failed. fun findUARTServiceInDevice(: DeviceBluetoothService, : UARTBTServiceDefinition, : CancellationToken? = null): Task<UARTBTService> |