Official Sheffield ARMBand micro:bit program

Committer:
MrBedfordVan
Date:
Mon Oct 17 12:41:20 2016 +0000
Revision:
0:b9164b348919
Official Sheffield ARMBand Micro:bit program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MrBedfordVan 0:b9164b348919 1 /*
MrBedfordVan 0:b9164b348919 2 The MIT License (MIT)
MrBedfordVan 0:b9164b348919 3
MrBedfordVan 0:b9164b348919 4 Copyright (c) 2016 British Broadcasting Corporation.
MrBedfordVan 0:b9164b348919 5 This software is provided by Lancaster University by arrangement with the BBC.
MrBedfordVan 0:b9164b348919 6
MrBedfordVan 0:b9164b348919 7 Permission is hereby granted, free of charge, to any person obtaining a
MrBedfordVan 0:b9164b348919 8 copy of this software and associated documentation files (the "Software"),
MrBedfordVan 0:b9164b348919 9 to deal in the Software without restriction, including without limitation
MrBedfordVan 0:b9164b348919 10 the rights to use, copy, modify, merge, publish, distribute, sublicense,
MrBedfordVan 0:b9164b348919 11 and/or sell copies of the Software, and to permit persons to whom the
MrBedfordVan 0:b9164b348919 12 Software is furnished to do so, subject to the following conditions:
MrBedfordVan 0:b9164b348919 13
MrBedfordVan 0:b9164b348919 14 The above copyright notice and this permission notice shall be included in
MrBedfordVan 0:b9164b348919 15 all copies or substantial portions of the Software.
MrBedfordVan 0:b9164b348919 16
MrBedfordVan 0:b9164b348919 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
MrBedfordVan 0:b9164b348919 18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
MrBedfordVan 0:b9164b348919 19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
MrBedfordVan 0:b9164b348919 20 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
MrBedfordVan 0:b9164b348919 21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
MrBedfordVan 0:b9164b348919 22 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
MrBedfordVan 0:b9164b348919 23 DEALINGS IN THE SOFTWARE.
MrBedfordVan 0:b9164b348919 24 */
MrBedfordVan 0:b9164b348919 25
MrBedfordVan 0:b9164b348919 26 #ifndef MICROBIT_UART_SERVICE_H
MrBedfordVan 0:b9164b348919 27 #define MICROBIT_UART_SERVICE_H
MrBedfordVan 0:b9164b348919 28
MrBedfordVan 0:b9164b348919 29 #include "mbed.h"
MrBedfordVan 0:b9164b348919 30 #include "ble/UUID.h"
MrBedfordVan 0:b9164b348919 31 #include "ble/BLE.h"
MrBedfordVan 0:b9164b348919 32 #include "MicroBitConfig.h"
MrBedfordVan 0:b9164b348919 33 #include "MicroBitSerial.h"
MrBedfordVan 0:b9164b348919 34
MrBedfordVan 0:b9164b348919 35 #define MICROBIT_UART_S_DEFAULT_BUF_SIZE 20
MrBedfordVan 0:b9164b348919 36
MrBedfordVan 0:b9164b348919 37 #define MICROBIT_UART_S_EVT_DELIM_MATCH 1
MrBedfordVan 0:b9164b348919 38 #define MICROBIT_UART_S_EVT_HEAD_MATCH 2
MrBedfordVan 0:b9164b348919 39 #define MICROBIT_UART_S_EVT_RX_FULL 3
MrBedfordVan 0:b9164b348919 40
MrBedfordVan 0:b9164b348919 41 /**
MrBedfordVan 0:b9164b348919 42 * Class definition for the custom MicroBit UART Service.
MrBedfordVan 0:b9164b348919 43 * Provides a BLE service that acts as a UART port, enabling the reception and transmission
MrBedfordVan 0:b9164b348919 44 * of an arbitrary number of bytes.
MrBedfordVan 0:b9164b348919 45 */
MrBedfordVan 0:b9164b348919 46 class MicroBitUARTService
MrBedfordVan 0:b9164b348919 47 {
MrBedfordVan 0:b9164b348919 48 uint8_t* rxBuffer;
MrBedfordVan 0:b9164b348919 49
MrBedfordVan 0:b9164b348919 50 uint8_t* txBuffer;
MrBedfordVan 0:b9164b348919 51
MrBedfordVan 0:b9164b348919 52 uint8_t rxBufferHead;
MrBedfordVan 0:b9164b348919 53 uint8_t rxBufferTail;
MrBedfordVan 0:b9164b348919 54 uint8_t rxBufferSize;
MrBedfordVan 0:b9164b348919 55
MrBedfordVan 0:b9164b348919 56 uint8_t txBufferSize;
MrBedfordVan 0:b9164b348919 57
MrBedfordVan 0:b9164b348919 58 uint32_t rxCharacteristicHandle;
MrBedfordVan 0:b9164b348919 59
MrBedfordVan 0:b9164b348919 60 // Bluetooth stack we're running on.
MrBedfordVan 0:b9164b348919 61 BLEDevice &ble;
MrBedfordVan 0:b9164b348919 62
MrBedfordVan 0:b9164b348919 63 //delimeters used for matching on receive.
MrBedfordVan 0:b9164b348919 64 ManagedString delimeters;
MrBedfordVan 0:b9164b348919 65
MrBedfordVan 0:b9164b348919 66 //a variable used when a user calls the eventAfter() method.
MrBedfordVan 0:b9164b348919 67 int rxBuffHeadMatch;
MrBedfordVan 0:b9164b348919 68
MrBedfordVan 0:b9164b348919 69 /**
MrBedfordVan 0:b9164b348919 70 * A callback function for whenever a Bluetooth device writes to our TX characteristic.
MrBedfordVan 0:b9164b348919 71 */
MrBedfordVan 0:b9164b348919 72 void onDataWritten(const GattWriteCallbackParams *params);
MrBedfordVan 0:b9164b348919 73
MrBedfordVan 0:b9164b348919 74 /**
MrBedfordVan 0:b9164b348919 75 * An internal method that copies values from a circular buffer to a linear buffer.
MrBedfordVan 0:b9164b348919 76 *
MrBedfordVan 0:b9164b348919 77 * @param circularBuff a pointer to the source circular buffer
MrBedfordVan 0:b9164b348919 78 * @param circularBuffSize the size of the circular buffer
MrBedfordVan 0:b9164b348919 79 * @param linearBuff a pointer to the destination linear buffer
MrBedfordVan 0:b9164b348919 80 * @param tailPosition the tail position in the circular buffer you want to copy from
MrBedfordVan 0:b9164b348919 81 * @param headPosition the head position in the circular buffer you want to copy to
MrBedfordVan 0:b9164b348919 82 *
MrBedfordVan 0:b9164b348919 83 * @note this method assumes that the linear buffer has the appropriate amount of
MrBedfordVan 0:b9164b348919 84 * memory to contain the copy operation
MrBedfordVan 0:b9164b348919 85 */
MrBedfordVan 0:b9164b348919 86 void circularCopy(uint8_t *circularBuff, uint8_t circularBuffSize, uint8_t *linearBuff, uint16_t tailPosition, uint16_t headPosition);
MrBedfordVan 0:b9164b348919 87
MrBedfordVan 0:b9164b348919 88 public:
MrBedfordVan 0:b9164b348919 89
MrBedfordVan 0:b9164b348919 90 /**
MrBedfordVan 0:b9164b348919 91 * Constructor for the UARTService.
MrBedfordVan 0:b9164b348919 92 * @param _ble an instance of BLEDevice
MrBedfordVan 0:b9164b348919 93 * @param rxBufferSize the size of the rxBuffer
MrBedfordVan 0:b9164b348919 94 * @param txBufferSize the size of the txBuffer
MrBedfordVan 0:b9164b348919 95 *
MrBedfordVan 0:b9164b348919 96 * @note The default size is MICROBIT_UART_S_DEFAULT_BUF_SIZE (20 bytes).
MrBedfordVan 0:b9164b348919 97 */
MrBedfordVan 0:b9164b348919 98 MicroBitUARTService(BLEDevice &_ble, uint8_t rxBufferSize = MICROBIT_UART_S_DEFAULT_BUF_SIZE, uint8_t txBufferSize = MICROBIT_UART_S_DEFAULT_BUF_SIZE);
MrBedfordVan 0:b9164b348919 99
MrBedfordVan 0:b9164b348919 100 /**
MrBedfordVan 0:b9164b348919 101 * Retreives a single character from our RxBuffer.
MrBedfordVan 0:b9164b348919 102 *
MrBedfordVan 0:b9164b348919 103 * @param mode the selected mode, one of: ASYNC, SYNC_SPINWAIT, SYNC_SLEEP. Each mode
MrBedfordVan 0:b9164b348919 104 * gives a different behaviour:
MrBedfordVan 0:b9164b348919 105 *
MrBedfordVan 0:b9164b348919 106 * ASYNC - Will attempt to read a single character, and return immediately
MrBedfordVan 0:b9164b348919 107 *
MrBedfordVan 0:b9164b348919 108 * SYNC_SPINWAIT - will return MICROBIT_INVALID_PARAMETER
MrBedfordVan 0:b9164b348919 109 *
MrBedfordVan 0:b9164b348919 110 * SYNC_SLEEP - Will configure the event and block the current fiber until the
MrBedfordVan 0:b9164b348919 111 * event is received.
MrBedfordVan 0:b9164b348919 112 *
MrBedfordVan 0:b9164b348919 113 * @return MICROBIT_INVALID_PARAMETER if the mode given is SYNC_SPINWAIT, a character or MICROBIT_NO_DATA
MrBedfordVan 0:b9164b348919 114 */
MrBedfordVan 0:b9164b348919 115 int getc(MicroBitSerialMode mode = SYNC_SLEEP);
MrBedfordVan 0:b9164b348919 116
MrBedfordVan 0:b9164b348919 117 /**
MrBedfordVan 0:b9164b348919 118 * Places a single character into our transmission buffer,
MrBedfordVan 0:b9164b348919 119 *
MrBedfordVan 0:b9164b348919 120 * @param c the character to transmit
MrBedfordVan 0:b9164b348919 121 *
MrBedfordVan 0:b9164b348919 122 * @param mode the selected mode, one of: ASYNC, SYNC_SPINWAIT, SYNC_SLEEP. Each mode
MrBedfordVan 0:b9164b348919 123 * gives a different behaviour:
MrBedfordVan 0:b9164b348919 124 *
MrBedfordVan 0:b9164b348919 125 * ASYNC - Will copy as many characters as it can into the buffer for transmission,
MrBedfordVan 0:b9164b348919 126 * and return control to the user.
MrBedfordVan 0:b9164b348919 127 *
MrBedfordVan 0:b9164b348919 128 * SYNC_SPINWAIT - will return MICROBIT_INVALID_PARAMETER
MrBedfordVan 0:b9164b348919 129 *
MrBedfordVan 0:b9164b348919 130 * SYNC_SLEEP - Will perform a cooperative blocking wait until all
MrBedfordVan 0:b9164b348919 131 * given characters have been received by the connected
MrBedfordVan 0:b9164b348919 132 * device.
MrBedfordVan 0:b9164b348919 133 *
MrBedfordVan 0:b9164b348919 134 * @return the number of characters written, or MICROBIT_NOT_SUPPORTED if there is
MrBedfordVan 0:b9164b348919 135 * no connected device, or the connected device has not enabled indications.
MrBedfordVan 0:b9164b348919 136 */
MrBedfordVan 0:b9164b348919 137 int putc(char c, MicroBitSerialMode mode = SYNC_SLEEP);
MrBedfordVan 0:b9164b348919 138
MrBedfordVan 0:b9164b348919 139 /**
MrBedfordVan 0:b9164b348919 140 * Copies characters into the buffer used for Transmitting to the central device.
MrBedfordVan 0:b9164b348919 141 *
MrBedfordVan 0:b9164b348919 142 * @param buf a buffer containing length number of bytes.
MrBedfordVan 0:b9164b348919 143 * @param length the size of the buffer.
MrBedfordVan 0:b9164b348919 144 * @param mode the selected mode, one of: ASYNC, SYNC_SPINWAIT, SYNC_SLEEP. Each mode
MrBedfordVan 0:b9164b348919 145 * gives a different behaviour:
MrBedfordVan 0:b9164b348919 146 *
MrBedfordVan 0:b9164b348919 147 * ASYNC - Will copy as many characters as it can into the buffer for transmission,
MrBedfordVan 0:b9164b348919 148 * and return control to the user.
MrBedfordVan 0:b9164b348919 149 *
MrBedfordVan 0:b9164b348919 150 * SYNC_SPINWAIT - will return MICROBIT_INVALID_PARAMETER
MrBedfordVan 0:b9164b348919 151 *
MrBedfordVan 0:b9164b348919 152 * SYNC_SLEEP - Will perform a cooperative blocking wait until all
MrBedfordVan 0:b9164b348919 153 * given characters have been received by the connected
MrBedfordVan 0:b9164b348919 154 * device.
MrBedfordVan 0:b9164b348919 155 *
MrBedfordVan 0:b9164b348919 156 * @return the number of characters written, or MICROBIT_NOT_SUPPORTED if there is
MrBedfordVan 0:b9164b348919 157 * no connected device, or the connected device has not enabled indications.
MrBedfordVan 0:b9164b348919 158 */
MrBedfordVan 0:b9164b348919 159 int send(const uint8_t *buf, int length, MicroBitSerialMode mode = SYNC_SLEEP);
MrBedfordVan 0:b9164b348919 160
MrBedfordVan 0:b9164b348919 161 /**
MrBedfordVan 0:b9164b348919 162 * Copies characters into the buffer used for Transmitting to the central device.
MrBedfordVan 0:b9164b348919 163 *
MrBedfordVan 0:b9164b348919 164 * @param s the string to transmit
MrBedfordVan 0:b9164b348919 165 * @param mode the selected mode, one of: ASYNC, SYNC_SPINWAIT, SYNC_SLEEP. Each mode
MrBedfordVan 0:b9164b348919 166 * gives a different behaviour:
MrBedfordVan 0:b9164b348919 167 *
MrBedfordVan 0:b9164b348919 168 * ASYNC - Will copy as many characters as it can into the buffer for transmission,
MrBedfordVan 0:b9164b348919 169 * and return control to the user.
MrBedfordVan 0:b9164b348919 170 *
MrBedfordVan 0:b9164b348919 171 * SYNC_SPINWAIT - will return MICROBIT_INVALID_PARAMETER
MrBedfordVan 0:b9164b348919 172 *
MrBedfordVan 0:b9164b348919 173 * SYNC_SLEEP - Will perform a cooperative blocking wait until all
MrBedfordVan 0:b9164b348919 174 * given characters have been received by the connected
MrBedfordVan 0:b9164b348919 175 * device.
MrBedfordVan 0:b9164b348919 176 *
MrBedfordVan 0:b9164b348919 177 * @return the number of characters written, or MICROBIT_NOT_SUPPORTED if there is
MrBedfordVan 0:b9164b348919 178 * no connected device, or the connected device has not enabled indications.
MrBedfordVan 0:b9164b348919 179 */
MrBedfordVan 0:b9164b348919 180 int send(ManagedString s, MicroBitSerialMode mode = SYNC_SLEEP);
MrBedfordVan 0:b9164b348919 181
MrBedfordVan 0:b9164b348919 182 /**
MrBedfordVan 0:b9164b348919 183 * Reads a number of characters from the rxBuffer and fills user given buffer.
MrBedfordVan 0:b9164b348919 184 *
MrBedfordVan 0:b9164b348919 185 * @param buf a pointer to a buffer of len bytes.
MrBedfordVan 0:b9164b348919 186 * @param len the size of the user allocated buffer
MrBedfordVan 0:b9164b348919 187 * @param mode the selected mode, one of: ASYNC, SYNC_SPINWAIT, SYNC_SLEEP. Each mode
MrBedfordVan 0:b9164b348919 188 * gives a different behaviour:
MrBedfordVan 0:b9164b348919 189 *
MrBedfordVan 0:b9164b348919 190 * ASYNC - Will attempt to read all available characters, and return immediately
MrBedfordVan 0:b9164b348919 191 * until the buffer limit is reached
MrBedfordVan 0:b9164b348919 192 *
MrBedfordVan 0:b9164b348919 193 * SYNC_SPINWAIT - will return MICROBIT_INVALID_PARAMETER
MrBedfordVan 0:b9164b348919 194 *
MrBedfordVan 0:b9164b348919 195 * SYNC_SLEEP - Will first of all determine whether the given number of characters
MrBedfordVan 0:b9164b348919 196 * are available in our buffer, if not, it will set an event and sleep
MrBedfordVan 0:b9164b348919 197 * until the number of characters are avaialable.
MrBedfordVan 0:b9164b348919 198 *
MrBedfordVan 0:b9164b348919 199 * @return the number of characters digested
MrBedfordVan 0:b9164b348919 200 */
MrBedfordVan 0:b9164b348919 201 int read(uint8_t *buf, int len, MicroBitSerialMode mode = SYNC_SLEEP);
MrBedfordVan 0:b9164b348919 202
MrBedfordVan 0:b9164b348919 203 /**
MrBedfordVan 0:b9164b348919 204 * Reads a number of characters from the rxBuffer and returns them as a ManagedString
MrBedfordVan 0:b9164b348919 205 *
MrBedfordVan 0:b9164b348919 206 * @param len the number of characters to read.
MrBedfordVan 0:b9164b348919 207 * @param mode the selected mode, one of: ASYNC, SYNC_SPINWAIT, SYNC_SLEEP. Each mode
MrBedfordVan 0:b9164b348919 208 * gives a different behaviour:
MrBedfordVan 0:b9164b348919 209 *
MrBedfordVan 0:b9164b348919 210 * ASYNC - Will attempt to read all available characters, and return immediately
MrBedfordVan 0:b9164b348919 211 * until the buffer limit is reached
MrBedfordVan 0:b9164b348919 212 *
MrBedfordVan 0:b9164b348919 213 * SYNC_SPINWAIT - will return MICROBIT_INVALID_PARAMETER
MrBedfordVan 0:b9164b348919 214 *
MrBedfordVan 0:b9164b348919 215 * SYNC_SLEEP - Will first of all determine whether the given number of characters
MrBedfordVan 0:b9164b348919 216 * are available in our buffer, if not, it will set an event and sleep
MrBedfordVan 0:b9164b348919 217 * until the number of characters are avaialable.
MrBedfordVan 0:b9164b348919 218 *
MrBedfordVan 0:b9164b348919 219 * @return an empty ManagedString on error, or a ManagedString containing characters
MrBedfordVan 0:b9164b348919 220 */
MrBedfordVan 0:b9164b348919 221 ManagedString read(int len, MicroBitSerialMode mode = SYNC_SLEEP);
MrBedfordVan 0:b9164b348919 222
MrBedfordVan 0:b9164b348919 223 /**
MrBedfordVan 0:b9164b348919 224 * Reads characters until a character matches one of the given delimeters
MrBedfordVan 0:b9164b348919 225 *
MrBedfordVan 0:b9164b348919 226 * @param delimeters the number of characters to match against
MrBedfordVan 0:b9164b348919 227 * @param mode the selected mode, one of: ASYNC, SYNC_SPINWAIT, SYNC_SLEEP. Each mode
MrBedfordVan 0:b9164b348919 228 * gives a different behaviour:
MrBedfordVan 0:b9164b348919 229 *
MrBedfordVan 0:b9164b348919 230 * ASYNC - Will attempt read the immediate buffer, and look for a match.
MrBedfordVan 0:b9164b348919 231 * If there isn't, an empty ManagedString will be returned.
MrBedfordVan 0:b9164b348919 232 *
MrBedfordVan 0:b9164b348919 233 * SYNC_SPINWAIT - will return MICROBIT_INVALID_PARAMETER
MrBedfordVan 0:b9164b348919 234 *
MrBedfordVan 0:b9164b348919 235 * SYNC_SLEEP - Will first of all consider the characters in the immediate buffer,
MrBedfordVan 0:b9164b348919 236 * if a match is not found, it will block on an event, fired when a
MrBedfordVan 0:b9164b348919 237 * character is matched.
MrBedfordVan 0:b9164b348919 238 *
MrBedfordVan 0:b9164b348919 239 * @return an empty ManagedString on error, or a ManagedString containing characters
MrBedfordVan 0:b9164b348919 240 */
MrBedfordVan 0:b9164b348919 241 ManagedString readUntil(ManagedString delimeters, MicroBitSerialMode mode = SYNC_SLEEP);
MrBedfordVan 0:b9164b348919 242
MrBedfordVan 0:b9164b348919 243 /**
MrBedfordVan 0:b9164b348919 244 * Configures an event to be fired on a match with one of the delimeters.
MrBedfordVan 0:b9164b348919 245 *
MrBedfordVan 0:b9164b348919 246 * @param delimeters the characters to match received characters against e.g. ManagedString("\r\n")
MrBedfordVan 0:b9164b348919 247 * @param mode the selected mode, one of: ASYNC, SYNC_SPINWAIT, SYNC_SLEEP. Each mode
MrBedfordVan 0:b9164b348919 248 * gives a different behaviour:
MrBedfordVan 0:b9164b348919 249 *
MrBedfordVan 0:b9164b348919 250 * ASYNC - Will configure the event and return immediately.
MrBedfordVan 0:b9164b348919 251 *
MrBedfordVan 0:b9164b348919 252 * SYNC_SPINWAIT - will return MICROBIT_INVALID_PARAMETER
MrBedfordVan 0:b9164b348919 253 *
MrBedfordVan 0:b9164b348919 254 * SYNC_SLEEP - Will configure the event and block the current fiber until the
MrBedfordVan 0:b9164b348919 255 * event is received.
MrBedfordVan 0:b9164b348919 256 *
MrBedfordVan 0:b9164b348919 257 * @return MICROBIT_INVALID_PARAMETER if the mode given is SYNC_SPINWAIT, otherwise MICROBIT_OK.
MrBedfordVan 0:b9164b348919 258 *
MrBedfordVan 0:b9164b348919 259 * @note delimeters are matched on a per byte basis.
MrBedfordVan 0:b9164b348919 260 */
MrBedfordVan 0:b9164b348919 261 int eventOn(ManagedString delimeters, MicroBitSerialMode mode = ASYNC);
MrBedfordVan 0:b9164b348919 262
MrBedfordVan 0:b9164b348919 263 /**
MrBedfordVan 0:b9164b348919 264 * Configures an event to be fired after "len" characters.
MrBedfordVan 0:b9164b348919 265 *
MrBedfordVan 0:b9164b348919 266 * @param len the number of characters to wait before triggering the event
MrBedfordVan 0:b9164b348919 267 * @param mode the selected mode, one of: ASYNC, SYNC_SPINWAIT, SYNC_SLEEP. Each mode
MrBedfordVan 0:b9164b348919 268 * gives a different behaviour:
MrBedfordVan 0:b9164b348919 269 *
MrBedfordVan 0:b9164b348919 270 * ASYNC - Will configure the event and return immediately.
MrBedfordVan 0:b9164b348919 271 *
MrBedfordVan 0:b9164b348919 272 * SYNC_SPINWAIT - will return MICROBIT_INVALID_PARAMETER
MrBedfordVan 0:b9164b348919 273 *
MrBedfordVan 0:b9164b348919 274 * SYNC_SLEEP - Will configure the event and block the current fiber until the
MrBedfordVan 0:b9164b348919 275 * event is received.
MrBedfordVan 0:b9164b348919 276 *
MrBedfordVan 0:b9164b348919 277 * @return MICROBIT_INVALID_PARAMETER if the mode given is SYNC_SPINWAIT, otherwise MICROBIT_OK.
MrBedfordVan 0:b9164b348919 278 */
MrBedfordVan 0:b9164b348919 279 int eventAfter(int len, MicroBitSerialMode mode = ASYNC);
MrBedfordVan 0:b9164b348919 280
MrBedfordVan 0:b9164b348919 281 /**
MrBedfordVan 0:b9164b348919 282 * Determines if we have space in our rxBuff.
MrBedfordVan 0:b9164b348919 283 *
MrBedfordVan 0:b9164b348919 284 * @return 1 if we have space, 0 if we do not.
MrBedfordVan 0:b9164b348919 285 */
MrBedfordVan 0:b9164b348919 286 int isReadable();
MrBedfordVan 0:b9164b348919 287
MrBedfordVan 0:b9164b348919 288 /**
MrBedfordVan 0:b9164b348919 289 * @return The currently buffered number of bytes in our rxBuff.
MrBedfordVan 0:b9164b348919 290 */
MrBedfordVan 0:b9164b348919 291 int rxBufferedSize();
MrBedfordVan 0:b9164b348919 292
MrBedfordVan 0:b9164b348919 293 /**
MrBedfordVan 0:b9164b348919 294 * @return The currently buffered number of bytes in our txBuff.
MrBedfordVan 0:b9164b348919 295 */
MrBedfordVan 0:b9164b348919 296 int txBufferedSize();
MrBedfordVan 0:b9164b348919 297 };
MrBedfordVan 0:b9164b348919 298
MrBedfordVan 0:b9164b348919 299 extern const uint8_t UARTServiceBaseUUID[UUID::LENGTH_OF_LONG_UUID];
MrBedfordVan 0:b9164b348919 300 extern const uint16_t UARTServiceShortUUID;
MrBedfordVan 0:b9164b348919 301 extern const uint16_t UARTServiceTXCharacteristicShortUUID;
MrBedfordVan 0:b9164b348919 302 extern const uint16_t UARTServiceRXCharacteristicShortUUID;
MrBedfordVan 0:b9164b348919 303
MrBedfordVan 0:b9164b348919 304 extern const uint8_t UARTServiceUUID[UUID::LENGTH_OF_LONG_UUID];
MrBedfordVan 0:b9164b348919 305 extern const uint8_t UARTServiceUUID_reversed[UUID::LENGTH_OF_LONG_UUID];
MrBedfordVan 0:b9164b348919 306
MrBedfordVan 0:b9164b348919 307 extern const uint8_t UARTServiceTXCharacteristicUUID[UUID::LENGTH_OF_LONG_UUID];
MrBedfordVan 0:b9164b348919 308 extern const uint8_t UARTServiceRXCharacteristicUUID[UUID::LENGTH_OF_LONG_UUID];
MrBedfordVan 0:b9164b348919 309
MrBedfordVan 0:b9164b348919 310 #endif