HW layer for the Nucleo board, it only work with old BLE_API
Dependents: Hello_BLE F446RE-BLE
Fork of X_NUCLEO_IDB0XA1 by
utils/inc/Payload.h@14:baa7a1464517, 2014-08-06 (annotated)
- Committer:
- hemddabral
- Date:
- Wed Aug 06 11:00:23 2014 +0000
- Revision:
- 14:baa7a1464517
- Parent:
- 12:a5d7db4a1e49
- Child:
- 18:6d5f4c638f6a
added support for advertising device appearance
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hemddabral | 12:a5d7db4a1e49 | 1 | /* mbed Microcontroller Library |
hemddabral | 12:a5d7db4a1e49 | 2 | * Copyright (c) 2006-2013 ARM Limited |
hemddabral | 12:a5d7db4a1e49 | 3 | * |
hemddabral | 12:a5d7db4a1e49 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
hemddabral | 12:a5d7db4a1e49 | 5 | * you may not use this file except in compliance with the License. |
hemddabral | 12:a5d7db4a1e49 | 6 | * You may obtain a copy of the License at |
hemddabral | 12:a5d7db4a1e49 | 7 | * |
hemddabral | 12:a5d7db4a1e49 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
hemddabral | 12:a5d7db4a1e49 | 9 | * |
hemddabral | 12:a5d7db4a1e49 | 10 | * Unless required by applicable law or agreed to in writing, software |
hemddabral | 12:a5d7db4a1e49 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
hemddabral | 12:a5d7db4a1e49 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
hemddabral | 12:a5d7db4a1e49 | 13 | * See the License for the specific language governing permissions and |
hemddabral | 12:a5d7db4a1e49 | 14 | * limitations under the License. |
hemddabral | 12:a5d7db4a1e49 | 15 | */ |
hemddabral | 12:a5d7db4a1e49 | 16 | |
hemddabral | 12:a5d7db4a1e49 | 17 | #include "mbed.h" |
hemddabral | 12:a5d7db4a1e49 | 18 | |
hemddabral | 12:a5d7db4a1e49 | 19 | #ifndef __PAYLOAD_H__ |
hemddabral | 12:a5d7db4a1e49 | 20 | #define __PAYLOAD_H__ |
hemddabral | 12:a5d7db4a1e49 | 21 | |
hemddabral | 12:a5d7db4a1e49 | 22 | class UnitPayload |
hemddabral | 12:a5d7db4a1e49 | 23 | { |
hemddabral | 12:a5d7db4a1e49 | 24 | public: |
hemddabral | 12:a5d7db4a1e49 | 25 | uint8_t length; |
hemddabral | 12:a5d7db4a1e49 | 26 | uint8_t id; |
hemddabral | 12:a5d7db4a1e49 | 27 | uint8_t *data; |
hemddabral | 12:a5d7db4a1e49 | 28 | |
hemddabral | 12:a5d7db4a1e49 | 29 | void set_length(uint8_t l) { |
hemddabral | 12:a5d7db4a1e49 | 30 | length=l; |
hemddabral | 12:a5d7db4a1e49 | 31 | } |
hemddabral | 12:a5d7db4a1e49 | 32 | |
hemddabral | 12:a5d7db4a1e49 | 33 | void set_id(uint8_t i) { |
hemddabral | 12:a5d7db4a1e49 | 34 | id=i; |
hemddabral | 12:a5d7db4a1e49 | 35 | } |
hemddabral | 12:a5d7db4a1e49 | 36 | |
hemddabral | 12:a5d7db4a1e49 | 37 | void set_data(uint8_t* data1) { |
hemddabral | 12:a5d7db4a1e49 | 38 | for(int j=0;j<length;j++) |
hemddabral | 12:a5d7db4a1e49 | 39 | { |
hemddabral | 12:a5d7db4a1e49 | 40 | data[j]=data1[j]; |
hemddabral | 12:a5d7db4a1e49 | 41 | } |
hemddabral | 12:a5d7db4a1e49 | 42 | } |
hemddabral | 12:a5d7db4a1e49 | 43 | |
hemddabral | 12:a5d7db4a1e49 | 44 | uint8_t get_length() { |
hemddabral | 12:a5d7db4a1e49 | 45 | return length; |
hemddabral | 12:a5d7db4a1e49 | 46 | } |
hemddabral | 12:a5d7db4a1e49 | 47 | |
hemddabral | 12:a5d7db4a1e49 | 48 | uint8_t get_id() { |
hemddabral | 12:a5d7db4a1e49 | 49 | return id; |
hemddabral | 12:a5d7db4a1e49 | 50 | } |
hemddabral | 12:a5d7db4a1e49 | 51 | |
hemddabral | 12:a5d7db4a1e49 | 52 | uint8_t* get_data() { |
hemddabral | 12:a5d7db4a1e49 | 53 | return data; |
hemddabral | 12:a5d7db4a1e49 | 54 | } |
hemddabral | 12:a5d7db4a1e49 | 55 | |
hemddabral | 12:a5d7db4a1e49 | 56 | }; |
hemddabral | 12:a5d7db4a1e49 | 57 | |
hemddabral | 12:a5d7db4a1e49 | 58 | class Payload { |
hemddabral | 12:a5d7db4a1e49 | 59 | UnitPayload *payload; |
hemddabral | 12:a5d7db4a1e49 | 60 | int stringLength; |
hemddabral | 12:a5d7db4a1e49 | 61 | int payloadUnitCount; |
hemddabral | 12:a5d7db4a1e49 | 62 | |
hemddabral | 12:a5d7db4a1e49 | 63 | public: |
hemddabral | 12:a5d7db4a1e49 | 64 | Payload(const uint8_t *tokenString, uint8_t string_ength); |
hemddabral | 12:a5d7db4a1e49 | 65 | Payload::Payload(); |
hemddabral | 12:a5d7db4a1e49 | 66 | uint8_t Payload::getPayloadUnitCount(); |
hemddabral | 12:a5d7db4a1e49 | 67 | |
hemddabral | 12:a5d7db4a1e49 | 68 | uint8_t Payload::getIDAtIndex(int index); |
hemddabral | 12:a5d7db4a1e49 | 69 | uint8_t Payload::getLengthAtIndex(int index); |
hemddabral | 12:a5d7db4a1e49 | 70 | uint8_t* Payload::getDataAtIndex(int index); |
hemddabral | 14:baa7a1464517 | 71 | int8_t getInt8AtIndex(int index); |
hemddabral | 14:baa7a1464517 | 72 | uint16_t getUint16AtIndex(int index); |
hemddabral | 12:a5d7db4a1e49 | 73 | }; |
hemddabral | 12:a5d7db4a1e49 | 74 | |
hemddabral | 12:a5d7db4a1e49 | 75 | #endif // __PAYLOAD_H__ |