EEP fORK
Dependencies: BLE_API mbed nRF51822
Fork of MCS_LRF by
bleHelper.h@9:afd6bd6e88bd, 2015-12-17 (annotated)
- Committer:
- Farshad
- Date:
- Thu Dec 17 01:12:17 2015 +0000
- Revision:
- 9:afd6bd6e88bd
- Parent:
- 7:8a23a257b66a
Added more comments.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Farshad | 7:8a23a257b66a | 1 | |
Farshad | 7:8a23a257b66a | 2 | #ifndef __BLE_HELPER_H__ |
Farshad | 7:8a23a257b66a | 3 | #define __BLE_HELPER_H__ |
Farshad | 7:8a23a257b66a | 4 | |
Farshad | 7:8a23a257b66a | 5 | #include "mbed.h" |
Farshad | 7:8a23a257b66a | 6 | #include "Serial.h" |
Farshad | 7:8a23a257b66a | 7 | #include "BLE.h" |
Farshad | 7:8a23a257b66a | 8 | #include "DeviceInformationService.h" |
Farshad | 7:8a23a257b66a | 9 | #include "UARTService.h" |
Farshad | 7:8a23a257b66a | 10 | |
Farshad | 7:8a23a257b66a | 11 | |
Farshad | 9:afd6bd6e88bd | 12 | /* helper class to break larger than 20 byte limit of a BLE payload to smaller multiple |
Farshad | 9:afd6bd6e88bd | 13 | packets and send over the BLE connection */ |
Farshad | 7:8a23a257b66a | 14 | class BLEHelper |
Farshad | 7:8a23a257b66a | 15 | { |
Farshad | 7:8a23a257b66a | 16 | public: |
Farshad | 7:8a23a257b66a | 17 | // constructor |
Farshad | 7:8a23a257b66a | 18 | BLEHelper(BLEDevice* ble, UARTService* UuartServicePtr); |
Farshad | 7:8a23a257b66a | 19 | void sendPacketOverBLE(uint16_t cmd, uint8_t data[], uint16_t len); |
Farshad | 7:8a23a257b66a | 20 | |
Farshad | 7:8a23a257b66a | 21 | private: |
Farshad | 7:8a23a257b66a | 22 | typedef enum { |
Farshad | 7:8a23a257b66a | 23 | PS_FIRST_AND_ONLY = 0b0000000000000000, |
Farshad | 7:8a23a257b66a | 24 | PS_FIRST_AND_NOT_LAST = 0b0010000000000000, |
Farshad | 7:8a23a257b66a | 25 | PS_LAST = 0b0100000000000000, |
Farshad | 7:8a23a257b66a | 26 | PS_MIDDLE = 0b0110000000000000 |
Farshad | 7:8a23a257b66a | 27 | } PacketStatus_e; |
Farshad | 7:8a23a257b66a | 28 | |
Farshad | 7:8a23a257b66a | 29 | BLEDevice* blePtr; |
Farshad | 7:8a23a257b66a | 30 | UARTService* uartServicePtr; |
Farshad | 7:8a23a257b66a | 31 | PacketStatus_e packetStatus; |
Farshad | 7:8a23a257b66a | 32 | |
Farshad | 7:8a23a257b66a | 33 | void sendOverBLE(uint16_t cmd, uint8_t data[], uint16_t len, PacketStatus_e status); |
Farshad | 7:8a23a257b66a | 34 | }; |
Farshad | 7:8a23a257b66a | 35 | |
Farshad | 7:8a23a257b66a | 36 | |
Farshad | 7:8a23a257b66a | 37 | |
Farshad | 7:8a23a257b66a | 38 | #endif // __BLE_HELPER_H__ |