NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
ble_uuid.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef H_BLE_UUID_
21#define H_BLE_UUID_
22
30#include <inttypes.h>
31#include <stddef.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37struct os_mbuf;
38
40enum {
43
46
49};
50
52typedef struct {
54 uint8_t type;
56
58typedef struct {
59 ble_uuid_t u;
60 uint16_t value;
62
64typedef struct {
65 ble_uuid_t u;
66 uint32_t value;
68
70typedef struct {
71 ble_uuid_t u;
72 uint8_t value[16];
74
76typedef union {
77 ble_uuid_t u;
78 ble_uuid16_t u16;
79 ble_uuid32_t u32;
80 ble_uuid128_t u128;
82
83#define BLE_UUID16_INIT(uuid16) \
84 { \
85 .u = { \
86 .type = BLE_UUID_TYPE_16, \
87 }, \
88 .value = (uuid16), \
89 }
90
91#define BLE_UUID32_INIT(uuid32) \
92 { \
93 .u = { \
94 .type = BLE_UUID_TYPE_32, \
95 }, \
96 .value = (uuid32), \
97 }
98
99#define BLE_UUID128_INIT(uuid128 ...) \
100 { \
101 .u = { \
102 .type = BLE_UUID_TYPE_128, \
103 }, \
104 .value = { uuid128 }, \
105 }
106
107#define BLE_UUID16_DECLARE(uuid16) \
108 ((ble_uuid_t *) (&(ble_uuid16_t) BLE_UUID16_INIT(uuid16)))
109
110#define BLE_UUID32_DECLARE(uuid32) \
111 ((ble_uuid_t *) (&(ble_uuid32_t) BLE_UUID32_INIT(uuid32)))
112
113#define BLE_UUID128_DECLARE(uuid128...) \
114 ((ble_uuid_t *) (&(ble_uuid128_t) BLE_UUID128_INIT(uuid128)))
115
116#define BLE_UUID16(u) \
117 ((ble_uuid16_t *) (u))
118
119#define BLE_UUID32(u) \
120 ((ble_uuid32_t *) (u))
121
122#define BLE_UUID128(u) \
123 ((ble_uuid128_t *) (u))
124
128#define BLE_UUID_STR_LEN (37)
129
139int ble_uuid_init_from_buf(ble_uuid_any_t *uuid, const void *buf, size_t len);
140
148int ble_uuid_cmp(const ble_uuid_t *uuid1, const ble_uuid_t *uuid2);
149
155void ble_uuid_copy(ble_uuid_any_t *dst, const ble_uuid_t *src);
156
169char *ble_uuid_to_str(const ble_uuid_t *uuid, char *dst);
170
178uint16_t ble_uuid_u16(const ble_uuid_t *uuid);
179
180#ifdef __cplusplus
181}
182#endif
183
188#endif /* _BLE_HOST_UUID_H */
char * ble_uuid_to_str(const ble_uuid_t *uuid, char *dst)
Converts the specified UUID to its string representation.
Definition ble_uuid.c:110
int ble_uuid_cmp(const ble_uuid_t *uuid1, const ble_uuid_t *uuid2)
Compares two Bluetooth UUIDs.
Definition ble_uuid.c:65
int ble_uuid_init_from_buf(ble_uuid_any_t *uuid, const void *buf, size_t len)
Constructs a UUID object from a byte array.
Definition ble_uuid.c:44
uint16_t ble_uuid_u16(const ble_uuid_t *uuid)
Converts the specified 16-bit UUID to a uint16_t.
Definition ble_uuid.c:140
void ble_uuid_copy(ble_uuid_any_t *dst, const ble_uuid_t *src)
Copy Bluetooth UUID.
Definition ble_uuid.c:89
@ BLE_UUID_TYPE_128
Definition ble_uuid.h:48
@ BLE_UUID_TYPE_32
Definition ble_uuid.h:45
@ BLE_UUID_TYPE_16
Definition ble_uuid.h:42
Definition ble_uuid.h:70
Definition ble_uuid.h:58
Definition ble_uuid.h:64
Definition ble_uuid.h:52
uint8_t type
Definition ble_uuid.h:54
Definition os_mbuf.h:86
Definition ble_uuid.h:76