xref: /nrf52832-nimble/packages/NimBLE-latest/nimble/host/test/src/ble_hs_test_util_hci.h (revision 042d53a763ad75cb1465103098bb88c245d95138)
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_HS_TEST_UTIL_HCI_
21 #define H_BLE_HS_TEST_UTIL_HCI_
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* leave this as macro so it may be used for static const initialization */
28 #define ble_hs_hci_util_opcode_join(ogf, ocf) (((ogf) << 10) | (ocf))
29 
30 #define BLE_HS_TEST_UTIL_PHONY_ACK_MAX  64
31 struct ble_hs_test_util_hci_ack {
32     uint16_t opcode;
33     uint8_t status;
34     uint8_t evt_params[256];
35     uint8_t evt_params_len;
36 };
37 
38 struct ble_hs_test_util_hci_num_completed_pkts_entry {
39     uint16_t handle_id; /* 0 for terminating entry in array. */
40     uint16_t num_pkts;
41 };
42 
43 /* $out queue */
44 void ble_hs_test_util_hci_out_adj(int count);
45 void *ble_hs_test_util_hci_out_first(void);
46 void *ble_hs_test_util_hci_out_last(void);
47 void ble_hs_test_util_hci_out_enqueue(void *cmd);
48 void ble_hs_test_util_hci_out_clear(void);
49 
50 /* $build */
51 void ble_hs_test_util_hci_build_cmd_complete(uint8_t *dst, int len,
52                                              uint8_t param_len,
53                                              uint8_t num_pkts,
54                                              uint16_t opcode);
55 void ble_hs_test_util_hci_build_cmd_status(uint8_t *dst, int len,
56                                            uint8_t status, uint8_t num_pkts,
57                                            uint16_t opcode);
58 
59 /* $ack */
60 void ble_hs_test_util_hci_ack_set_params(uint16_t opcode, uint8_t status,
61                                          void *params, uint8_t params_len);
62 void ble_hs_test_util_hci_ack_set(uint16_t opcode, uint8_t status);
63 void ble_hs_test_util_hci_ack_append_params(uint16_t opcode, uint8_t status,
64                                             void *params, uint8_t params_len);
65 void ble_hs_test_util_hci_ack_append(uint16_t opcode, uint8_t status);
66 void ble_hs_test_util_hci_ack_set_seq(const struct ble_hs_test_util_hci_ack *acks);
67 void ble_hs_test_util_hci_ack_set_startup(void);
68 void ble_hs_test_util_hci_ack_set_disc(uint8_t own_addr_type,
69                                        int fail_idx, uint8_t fail_status);
70 void ble_hs_test_util_hci_ack_set_disconnect(uint8_t hci_status);
71 
72 int ble_hs_test_util_hci_startup_seq_cnt(void);
73 
74 /* $verify tx */
75 void ble_hs_test_util_hci_verify_tx_add_irk(uint8_t addr_type,
76                                             const uint8_t *addr,
77                                             const uint8_t *peer_irk,
78                                             const uint8_t *local_irk);
79 void ble_hs_test_util_hci_verify_tx_set_priv_mode(uint8_t addr_type,
80                                                   const uint8_t *addr,
81                                                   uint8_t priv_mode);
82 void ble_hs_test_util_hci_verify_tx_disconnect(uint16_t handle,
83                                                uint8_t reason);
84 void ble_hs_test_util_hci_verify_tx_create_conn(
85     const struct hci_create_conn *exp);
86 uint8_t *ble_hs_test_util_hci_verify_tx(uint8_t ogf, uint16_t ocf,
87                                         uint8_t *out_param_len);
88 
89 /* $rx */
90 void ble_hs_test_util_hci_rx_num_completed_pkts_event(
91     struct ble_hs_test_util_hci_num_completed_pkts_entry *entries);
92 void ble_hs_test_util_hci_rx_disconn_complete_event(
93     struct hci_disconn_complete *evt);
94 void ble_hs_test_util_hci_rx_conn_cancel_evt(void);
95 
96 /* $misc */
97 int ble_hs_test_util_hci_misc_exp_status(int cmd_idx, int fail_idx,
98                                          uint8_t fail_status);
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif
105