MicroBit as BLE gamepad
Dependencies: BLE_API mbed-dev-bin nRF51822
Fork of microbit-dal by
inc/types/PacketBuffer.h@75:df904445f561, 2017-01-30 (annotated)
- Committer:
- rengro01
- Date:
- Mon Jan 30 08:29:06 2017 +0000
- Revision:
- 75:df904445f561
- Parent:
- 1:8aa5cdb4ab67
MicroBit as BLE gamepad
Who changed what in which revision?
User | Revision | Line number | New 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_PACKET_BUFFER_H |
Jonathan Austin |
1:8aa5cdb4ab67 | 27 | #define MICROBIT_PACKET_BUFFER_H |
Jonathan Austin |
1:8aa5cdb4ab67 | 28 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 29 | #include "mbed.h" |
Jonathan Austin |
1:8aa5cdb4ab67 | 30 | #include "MicroBitConfig.h" |
Jonathan Austin |
1:8aa5cdb4ab67 | 31 | #include "RefCounted.h" |
Jonathan Austin |
1:8aa5cdb4ab67 | 32 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 33 | struct PacketData : RefCounted |
Jonathan Austin |
1:8aa5cdb4ab67 | 34 | { |
Jonathan Austin |
1:8aa5cdb4ab67 | 35 | uint16_t rssi; // The radio signal strength this packet was received. |
Jonathan Austin |
1:8aa5cdb4ab67 | 36 | uint8_t length; // The length of the payload in bytes |
Jonathan Austin |
1:8aa5cdb4ab67 | 37 | uint8_t payload[0]; // User / higher layer protocol data |
Jonathan Austin |
1:8aa5cdb4ab67 | 38 | }; |
Jonathan Austin |
1:8aa5cdb4ab67 | 39 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 40 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 41 | * Class definition for a PacketBuffer. |
Jonathan Austin |
1:8aa5cdb4ab67 | 42 | * A PacketBuffer holds a series of bytes that can be sent or received from the MicroBitRadio channel. |
Jonathan Austin |
1:8aa5cdb4ab67 | 43 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 44 | * @note This is a mutable, managed type. |
Jonathan Austin |
1:8aa5cdb4ab67 | 45 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 46 | class PacketBuffer |
Jonathan Austin |
1:8aa5cdb4ab67 | 47 | { |
Jonathan Austin |
1:8aa5cdb4ab67 | 48 | PacketData *ptr; // Pointer to payload data |
Jonathan Austin |
1:8aa5cdb4ab67 | 49 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 50 | public: |
Jonathan Austin |
1:8aa5cdb4ab67 | 51 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 52 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 53 | * Provide a pointer to a memory location containing the packet data. |
Jonathan Austin |
1:8aa5cdb4ab67 | 54 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 55 | * @return The contents of this packet, as an array of bytes. |
Jonathan Austin |
1:8aa5cdb4ab67 | 56 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 57 | uint8_t *getBytes(); |
Jonathan Austin |
1:8aa5cdb4ab67 | 58 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 59 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 60 | * Default Constructor. |
Jonathan Austin |
1:8aa5cdb4ab67 | 61 | * Creates an empty Packet Buffer. |
Jonathan Austin |
1:8aa5cdb4ab67 | 62 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 63 | * @code |
Jonathan Austin |
1:8aa5cdb4ab67 | 64 | * PacketBuffer p(); |
Jonathan Austin |
1:8aa5cdb4ab67 | 65 | * @endcode |
Jonathan Austin |
1:8aa5cdb4ab67 | 66 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 67 | PacketBuffer(); |
Jonathan Austin |
1:8aa5cdb4ab67 | 68 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 69 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 70 | * Constructor. |
Jonathan Austin |
1:8aa5cdb4ab67 | 71 | * Creates a new PacketBuffer of the given size. |
Jonathan Austin |
1:8aa5cdb4ab67 | 72 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 73 | * @param length The length of the buffer to create. |
Jonathan Austin |
1:8aa5cdb4ab67 | 74 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 75 | * @code |
Jonathan Austin |
1:8aa5cdb4ab67 | 76 | * PacketBuffer p(16); // Creates a PacketBuffer 16 bytes long. |
Jonathan Austin |
1:8aa5cdb4ab67 | 77 | * @endcode |
Jonathan Austin |
1:8aa5cdb4ab67 | 78 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 79 | PacketBuffer(int length); |
Jonathan Austin |
1:8aa5cdb4ab67 | 80 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 81 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 82 | * Constructor. |
Jonathan Austin |
1:8aa5cdb4ab67 | 83 | * Creates an empty Packet Buffer of the given size, |
Jonathan Austin |
1:8aa5cdb4ab67 | 84 | * and fills it with the data provided. |
Jonathan Austin |
1:8aa5cdb4ab67 | 85 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 86 | * @param data The data with which to fill the buffer. |
Jonathan Austin |
1:8aa5cdb4ab67 | 87 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 88 | * @param length The length of the buffer to create. |
Jonathan Austin |
1:8aa5cdb4ab67 | 89 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 90 | * @param rssi The radio signal strength at the time this packet was recieved. Defaults to 0. |
Jonathan Austin |
1:8aa5cdb4ab67 | 91 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 92 | * @code |
Jonathan Austin |
1:8aa5cdb4ab67 | 93 | * uint8_t buf = {13,5,2}; |
Jonathan Austin |
1:8aa5cdb4ab67 | 94 | * PacketBuffer p(buf, 3); // Creates a PacketBuffer 3 bytes long. |
Jonathan Austin |
1:8aa5cdb4ab67 | 95 | * @endcode |
Jonathan Austin |
1:8aa5cdb4ab67 | 96 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 97 | PacketBuffer(uint8_t *data, int length, int rssi = 0); |
Jonathan Austin |
1:8aa5cdb4ab67 | 98 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 99 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 100 | * Copy Constructor. |
Jonathan Austin |
1:8aa5cdb4ab67 | 101 | * Add ourselves as a reference to an existing PacketBuffer. |
Jonathan Austin |
1:8aa5cdb4ab67 | 102 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 103 | * @param buffer The PacketBuffer to reference. |
Jonathan Austin |
1:8aa5cdb4ab67 | 104 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 105 | * @code |
Jonathan Austin |
1:8aa5cdb4ab67 | 106 | * PacketBuffer p(); |
Jonathan Austin |
1:8aa5cdb4ab67 | 107 | * PacketBuffer p2(p); // Refers to the same packet as p. |
Jonathan Austin |
1:8aa5cdb4ab67 | 108 | * @endcode |
Jonathan Austin |
1:8aa5cdb4ab67 | 109 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 110 | PacketBuffer(const PacketBuffer &buffer); |
Jonathan Austin |
1:8aa5cdb4ab67 | 111 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 112 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 113 | * Internal constructor-initialiser. |
Jonathan Austin |
1:8aa5cdb4ab67 | 114 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 115 | * @param data The data with which to fill the buffer. |
Jonathan Austin |
1:8aa5cdb4ab67 | 116 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 117 | * @param length The length of the buffer to create. |
Jonathan Austin |
1:8aa5cdb4ab67 | 118 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 119 | * @param rssi The radio signal strength at the time this packet was recieved. |
Jonathan Austin |
1:8aa5cdb4ab67 | 120 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 121 | void init(uint8_t *data, int length, int rssi); |
Jonathan Austin |
1:8aa5cdb4ab67 | 122 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 123 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 124 | * Destructor. |
Jonathan Austin |
1:8aa5cdb4ab67 | 125 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 126 | * Removes buffer resources held by the instance. |
Jonathan Austin |
1:8aa5cdb4ab67 | 127 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 128 | ~PacketBuffer(); |
Jonathan Austin |
1:8aa5cdb4ab67 | 129 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 130 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 131 | * Copy assign operation. |
Jonathan Austin |
1:8aa5cdb4ab67 | 132 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 133 | * Called when one PacketBuffer is assigned the value of another using the '=' operator. |
Jonathan Austin |
1:8aa5cdb4ab67 | 134 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 135 | * Decrements our reference count and free up the buffer as necessary. |
Jonathan Austin |
1:8aa5cdb4ab67 | 136 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 137 | * Then, update our buffer to refer to that of the supplied PacketBuffer, |
Jonathan Austin |
1:8aa5cdb4ab67 | 138 | * and increase its reference count. |
Jonathan Austin |
1:8aa5cdb4ab67 | 139 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 140 | * @param p The PacketBuffer to reference. |
Jonathan Austin |
1:8aa5cdb4ab67 | 141 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 142 | * @code |
Jonathan Austin |
1:8aa5cdb4ab67 | 143 | * uint8_t buf = {13,5,2}; |
Jonathan Austin |
1:8aa5cdb4ab67 | 144 | * PacketBuffer p1(16); |
Jonathan Austin |
1:8aa5cdb4ab67 | 145 | * PacketBuffer p2(buf, 3); |
Jonathan Austin |
1:8aa5cdb4ab67 | 146 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 147 | * p1 = p2; |
Jonathan Austin |
1:8aa5cdb4ab67 | 148 | * @endcode |
Jonathan Austin |
1:8aa5cdb4ab67 | 149 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 150 | PacketBuffer& operator = (const PacketBuffer& p); |
Jonathan Austin |
1:8aa5cdb4ab67 | 151 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 152 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 153 | * Array access operation (read). |
Jonathan Austin |
1:8aa5cdb4ab67 | 154 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 155 | * Called when a PacketBuffer is dereferenced with a [] operation. |
Jonathan Austin |
1:8aa5cdb4ab67 | 156 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 157 | * Transparently map this through to the underlying payload for elegance of programming. |
Jonathan Austin |
1:8aa5cdb4ab67 | 158 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 159 | * @code |
Jonathan Austin |
1:8aa5cdb4ab67 | 160 | * PacketBuffer p1(16); |
Jonathan Austin |
1:8aa5cdb4ab67 | 161 | * uint8_t data = p1[0]; |
Jonathan Austin |
1:8aa5cdb4ab67 | 162 | * @endcode |
Jonathan Austin |
1:8aa5cdb4ab67 | 163 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 164 | uint8_t operator [] (int i) const; |
Jonathan Austin |
1:8aa5cdb4ab67 | 165 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 166 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 167 | * Array access operation (modify). |
Jonathan Austin |
1:8aa5cdb4ab67 | 168 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 169 | * Called when a PacketBuffer is dereferenced with a [] operation. |
Jonathan Austin |
1:8aa5cdb4ab67 | 170 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 171 | * Transparently map this through to the underlying payload for elegance of programming. |
Jonathan Austin |
1:8aa5cdb4ab67 | 172 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 173 | * @code |
Jonathan Austin |
1:8aa5cdb4ab67 | 174 | * PacketBuffer p1(16); |
Jonathan Austin |
1:8aa5cdb4ab67 | 175 | * p1[0] = 42; |
Jonathan Austin |
1:8aa5cdb4ab67 | 176 | * @endcode |
Jonathan Austin |
1:8aa5cdb4ab67 | 177 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 178 | uint8_t& operator [] (int i); |
Jonathan Austin |
1:8aa5cdb4ab67 | 179 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 180 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 181 | * Equality operation. |
Jonathan Austin |
1:8aa5cdb4ab67 | 182 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 183 | * Called when one PacketBuffer is tested to be equal to another using the '==' operator. |
Jonathan Austin |
1:8aa5cdb4ab67 | 184 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 185 | * @param p The PacketBuffer to test ourselves against. |
Jonathan Austin |
1:8aa5cdb4ab67 | 186 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 187 | * @return true if this PacketBuffer is identical to the one supplied, false otherwise. |
Jonathan Austin |
1:8aa5cdb4ab67 | 188 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 189 | * @code |
Jonathan Austin |
1:8aa5cdb4ab67 | 190 | * MicroBitDisplay display; |
Jonathan Austin |
1:8aa5cdb4ab67 | 191 | * uint8_t buf = {13,5,2}; |
Jonathan Austin |
1:8aa5cdb4ab67 | 192 | * PacketBuffer p1(); |
Jonathan Austin |
1:8aa5cdb4ab67 | 193 | * PacketBuffer p2(); |
Jonathan Austin |
1:8aa5cdb4ab67 | 194 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 195 | * if(p1 == p2) // will be true |
Jonathan Austin |
1:8aa5cdb4ab67 | 196 | * display.scroll("same!"); |
Jonathan Austin |
1:8aa5cdb4ab67 | 197 | * @endcode |
Jonathan Austin |
1:8aa5cdb4ab67 | 198 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 199 | bool operator== (const PacketBuffer& p); |
Jonathan Austin |
1:8aa5cdb4ab67 | 200 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 201 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 202 | * Sets the byte at the given index to value provided. |
Jonathan Austin |
1:8aa5cdb4ab67 | 203 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 204 | * @param position The index of the byte to change. |
Jonathan Austin |
1:8aa5cdb4ab67 | 205 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 206 | * @param value The new value of the byte (0-255). |
Jonathan Austin |
1:8aa5cdb4ab67 | 207 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 208 | * @return MICROBIT_OK, or MICROBIT_INVALID_PARAMETER. |
Jonathan Austin |
1:8aa5cdb4ab67 | 209 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 210 | * @code |
Jonathan Austin |
1:8aa5cdb4ab67 | 211 | * PacketBuffer p1(16); |
Jonathan Austin |
1:8aa5cdb4ab67 | 212 | * p1.setByte(0,255); // Sets the first byte in the buffer to the value 255. |
Jonathan Austin |
1:8aa5cdb4ab67 | 213 | * @endcode |
Jonathan Austin |
1:8aa5cdb4ab67 | 214 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 215 | int setByte(int position, uint8_t value); |
Jonathan Austin |
1:8aa5cdb4ab67 | 216 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 217 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 218 | * Determines the value of the given byte in the packet. |
Jonathan Austin |
1:8aa5cdb4ab67 | 219 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 220 | * @param position The index of the byte to read. |
Jonathan Austin |
1:8aa5cdb4ab67 | 221 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 222 | * @return The value of the byte at the given position, or MICROBIT_INVALID_PARAMETER. |
Jonathan Austin |
1:8aa5cdb4ab67 | 223 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 224 | * @code |
Jonathan Austin |
1:8aa5cdb4ab67 | 225 | * PacketBuffer p1(16); |
Jonathan Austin |
1:8aa5cdb4ab67 | 226 | * p1.setByte(0,255); // Sets the first byte in the buffer to the value 255. |
Jonathan Austin |
1:8aa5cdb4ab67 | 227 | * p1.getByte(0); // Returns 255. |
Jonathan Austin |
1:8aa5cdb4ab67 | 228 | * @endcode |
Jonathan Austin |
1:8aa5cdb4ab67 | 229 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 230 | int getByte(int position); |
Jonathan Austin |
1:8aa5cdb4ab67 | 231 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 232 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 233 | * Gets number of bytes in this buffer |
Jonathan Austin |
1:8aa5cdb4ab67 | 234 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 235 | * @return The size of the buffer in bytes. |
Jonathan Austin |
1:8aa5cdb4ab67 | 236 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 237 | * @code |
Jonathan Austin |
1:8aa5cdb4ab67 | 238 | * PacketBuffer p1(16); |
Jonathan Austin |
1:8aa5cdb4ab67 | 239 | * p1.length(); // Returns 16. |
Jonathan Austin |
1:8aa5cdb4ab67 | 240 | * @endcode |
Jonathan Austin |
1:8aa5cdb4ab67 | 241 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 242 | int length(); |
Jonathan Austin |
1:8aa5cdb4ab67 | 243 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 244 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 245 | * Retrieves the received signal strength of this packet. |
Jonathan Austin |
1:8aa5cdb4ab67 | 246 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 247 | * @return The signal strength of the radio when this packet was received, in -dbM. |
Jonathan Austin |
1:8aa5cdb4ab67 | 248 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 249 | * @code |
Jonathan Austin |
1:8aa5cdb4ab67 | 250 | * PacketBuffer p1(16); |
Jonathan Austin |
1:8aa5cdb4ab67 | 251 | * p1.getRSSI(); // Returns the received signal strength. |
Jonathan Austin |
1:8aa5cdb4ab67 | 252 | * @endcode |
Jonathan Austin |
1:8aa5cdb4ab67 | 253 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 254 | int getRSSI(); |
Jonathan Austin |
1:8aa5cdb4ab67 | 255 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 256 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 257 | * Sets the received signal strength of this packet. |
Jonathan Austin |
1:8aa5cdb4ab67 | 258 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 259 | * @code |
Jonathan Austin |
1:8aa5cdb4ab67 | 260 | * PacketBuffer p1(16); |
Jonathan Austin |
1:8aa5cdb4ab67 | 261 | * p1.setRSSI(37); |
Jonathan Austin |
1:8aa5cdb4ab67 | 262 | * @endcode |
Jonathan Austin |
1:8aa5cdb4ab67 | 263 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 264 | void setRSSI(uint8_t rssi); |
Jonathan Austin |
1:8aa5cdb4ab67 | 265 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 266 | static PacketBuffer EmptyPacket; |
Jonathan Austin |
1:8aa5cdb4ab67 | 267 | }; |
Jonathan Austin |
1:8aa5cdb4ab67 | 268 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 269 | #endif |