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_HW_ 21 #define H_BLE_HW_ 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 #include "syscfg/syscfg.h" 28 29 #if defined(ARCH_sim) 30 #define BLE_USES_HW_WHITELIST (0) 31 #else 32 #define BLE_USES_HW_WHITELIST MYNEWT_VAL(BLE_HW_WHITELIST_ENABLE) 33 #endif 34 35 /* Returns the number of hw whitelist elements */ 36 uint8_t ble_hw_whitelist_size(void); 37 38 /* Clear the whitelist */ 39 void ble_hw_whitelist_clear(void); 40 41 /* Remove a device from the hw whitelist */ 42 void ble_hw_whitelist_rmv(uint8_t *addr, uint8_t addr_type); 43 44 /* Add a device to the hw whitelist */ 45 int ble_hw_whitelist_add(uint8_t *addr, uint8_t addr_type); 46 47 /* Enable hw whitelisting */ 48 void ble_hw_whitelist_enable(void); 49 50 /* Enable hw whitelisting */ 51 void ble_hw_whitelist_disable(void); 52 53 /* Boolean function returning true if address matches a whitelist entry */ 54 int ble_hw_whitelist_match(void); 55 56 /* Encrypt data */ 57 struct ble_encryption_block; 58 int ble_hw_encrypt_block(struct ble_encryption_block *ecb); 59 60 /* Random number generation */ 61 typedef void (*ble_rng_isr_cb_t)(uint8_t rnum); 62 int ble_hw_rng_init(ble_rng_isr_cb_t cb, int bias); 63 64 /** 65 * Start the random number generator 66 * 67 * @return int 68 */ 69 int ble_hw_rng_start(void); 70 71 /** 72 * Stop the random generator 73 * 74 * @return int 75 */ 76 int ble_hw_rng_stop(void); 77 78 /** 79 * Read the random number generator. 80 * 81 * @return uint8_t 82 */ 83 uint8_t ble_hw_rng_read(void); 84 85 /* Clear the resolving list*/ 86 void ble_hw_resolv_list_clear(void); 87 88 /* Add a device to the hw resolving list */ 89 int ble_hw_resolv_list_add(uint8_t *irk); 90 91 /* Remove a device from the hw resolving list */ 92 void ble_hw_resolv_list_rmv(int index); 93 94 /* Returns the size of the whitelist in HW */ 95 uint8_t ble_hw_resolv_list_size(void); 96 97 /* Enable the resolving list */ 98 void ble_hw_resolv_list_enable(void); 99 100 /* Disables resolving list devices */ 101 void ble_hw_resolv_list_disable(void); 102 103 /* Returns index of resolved address; -1 if not resolved */ 104 int ble_hw_resolv_list_match(void); 105 106 /* Returns public device address or -1 if not present */ 107 int ble_hw_get_public_addr(ble_addr_t *addr); 108 109 /* Returns random static address or -1 if not present */ 110 int ble_hw_get_static_addr(ble_addr_t *addr); 111 112 #ifdef __cplusplus 113 } 114 #endif 115 116 #endif /* H_BLE_HW_ */ 117