My fork

Dependencies:   BLE_API mbed-dev-bin nRF51822-bluetooth-mdw

Fork of microbit-dal-bluetooth-mdw by Martin Woolley

Committer:
LancasterUniversity
Date:
Wed Jul 13 12:18:45 2016 +0100
Revision:
65:f7ebabf23e15
Parent:
58:2ac8d45f1b08
Child:
66:2fc7d7c2fffc
Synchronized with git rev 00674e34
Author: Joe Finney
microbit: Tuning and furhter debounce of SHAKE gesture

- Added timeout code to prevent over-generation of SHAKE events.
- Tuning of SHAKE detection parameters to align sensitivity with existing
microbit.co.uk algorithm

Who changed what in which revision?

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