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 #include <stdint.h>
21 #include <assert.h>
22 #include <string.h>
23 #include "syscfg/syscfg.h"
24 #include "os/os.h"
25 #include "nimble/ble.h"
26 #include "nimble/nimble_opt.h"
27 #include "controller/ble_hw.h"
28
29 /* Total number of white list elements supported by nrf52 */
30 #define BLE_HW_WHITE_LIST_SIZE (0)
31
32 /* We use this to keep track of which entries are set to valid addresses */
33 static uint8_t g_ble_hw_whitelist_mask;
34
35 /* Returns public device address or -1 if not present */
36 int
ble_hw_get_public_addr(ble_addr_t * addr)37 ble_hw_get_public_addr(ble_addr_t *addr)
38 {
39 return -1;
40 }
41
42 /* Returns random static address or -1 if not present */
43 int
ble_hw_get_static_addr(ble_addr_t * addr)44 ble_hw_get_static_addr(ble_addr_t *addr)
45 {
46 return -1;
47 }
48
49 /**
50 * Clear the whitelist
51 *
52 * @return int
53 */
54 void
ble_hw_whitelist_clear(void)55 ble_hw_whitelist_clear(void)
56 {
57 g_ble_hw_whitelist_mask = 0;
58 }
59
60 /**
61 * Add a device to the hw whitelist
62 *
63 * @param addr
64 * @param addr_type
65 *
66 * @return int 0: success, BLE error code otherwise
67 */
68 int
ble_hw_whitelist_add(uint8_t * addr,uint8_t addr_type)69 ble_hw_whitelist_add(uint8_t *addr, uint8_t addr_type)
70 {
71 return BLE_ERR_MEM_CAPACITY;
72 }
73
74 /**
75 * Remove a device from the hw whitelist
76 *
77 * @param addr
78 * @param addr_type
79 *
80 */
81 void
ble_hw_whitelist_rmv(uint8_t * addr,uint8_t addr_type)82 ble_hw_whitelist_rmv(uint8_t *addr, uint8_t addr_type)
83 {
84 return;
85 }
86
87 /**
88 * Returns the size of the whitelist in HW
89 *
90 * @return int Number of devices allowed in whitelist
91 */
92 uint8_t
ble_hw_whitelist_size(void)93 ble_hw_whitelist_size(void)
94 {
95 return BLE_HW_WHITE_LIST_SIZE;
96 }
97
98 /**
99 * Enable the whitelisted devices
100 */
101 void
ble_hw_whitelist_enable(void)102 ble_hw_whitelist_enable(void)
103 {
104 return;
105 }
106
107 /**
108 * Disables the whitelisted devices
109 */
110 void
ble_hw_whitelist_disable(void)111 ble_hw_whitelist_disable(void)
112 {
113 return;
114 }
115
116 /**
117 * Boolean function which returns true ('1') if there is a match on the
118 * whitelist.
119 *
120 * @return int
121 */
122 int
ble_hw_whitelist_match(void)123 ble_hw_whitelist_match(void)
124 {
125 return 0;
126 }
127
128 /* Encrypt data */
129 int
ble_hw_encrypt_block(struct ble_encryption_block * ecb)130 ble_hw_encrypt_block(struct ble_encryption_block *ecb)
131 {
132 return -1;
133 }
134
135 /**
136 * Initialize the random number generator
137 *
138 * @param cb
139 * @param bias
140 *
141 * @return int
142 */
143 int
ble_hw_rng_init(ble_rng_isr_cb_t cb,int bias)144 ble_hw_rng_init(ble_rng_isr_cb_t cb, int bias)
145 {
146 return -1;
147 }
148
149 /**
150 * Start the random number generator
151 *
152 * @return int
153 */
154 int
ble_hw_rng_start(void)155 ble_hw_rng_start(void)
156 {
157 return -1;
158 }
159
160 /**
161 * Stop the random generator
162 *
163 * @return int
164 */
165 int
ble_hw_rng_stop(void)166 ble_hw_rng_stop(void)
167 {
168 return -1;
169 }
170
171 /**
172 * Read the random number generator.
173 *
174 * @return uint8_t
175 */
176 uint8_t
ble_hw_rng_read(void)177 ble_hw_rng_read(void)
178 {
179 return 0;
180 }
181
182 #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
183 /**
184 * Clear the resolving list
185 *
186 * @return int
187 */
188 void
ble_hw_resolv_list_clear(void)189 ble_hw_resolv_list_clear(void)
190 {
191 }
192
193 /**
194 * Add a device to the hw resolving list
195 *
196 * @param irk Pointer to IRK to add
197 *
198 * @return int 0: success, BLE error code otherwise
199 */
200 int
ble_hw_resolv_list_add(uint8_t * irk)201 ble_hw_resolv_list_add(uint8_t *irk)
202 {
203 return BLE_ERR_MEM_CAPACITY;
204 }
205
206 /**
207 * Remove a device from the hw resolving list
208 *
209 * @param index Index of IRK to remove
210 */
211 void
ble_hw_resolv_list_rmv(int index)212 ble_hw_resolv_list_rmv(int index)
213 {
214 }
215
216 /**
217 * Returns the size of the resolving list. NOTE: this returns the maximum
218 * allowable entries in the HW. Configuration options may limit this.
219 *
220 * @return int Number of devices allowed in resolving list
221 */
222 uint8_t
ble_hw_resolv_list_size(void)223 ble_hw_resolv_list_size(void)
224 {
225 return 0;
226 }
227
228 /**
229 * Called to determine if the address received was resolved.
230 *
231 * @return int Negative values indicate unresolved address; positive values
232 * indicate index in resolving list of resolved address.
233 */
234 int
ble_hw_resolv_list_match(void)235 ble_hw_resolv_list_match(void)
236 {
237 return -1;
238 }
239 #endif
240