• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 WinnerMicro Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <stdio.h>
17 #include <stdint.h>
18 #include "host/ble_hs.h"
19 
20 #include "ble_util.h"
21 
22 #ifndef CASE_RETURN_STR
23 #define CASE_RETURN_STR(const) case const: return #const;
24 #endif
25 
tls_bt_gap_evt_2_str(uint32_t event)26 const char *tls_bt_gap_evt_2_str(uint32_t event)
27 {
28     switch (event) {
29         CASE_RETURN_STR(BLE_GAP_EVENT_CONNECT)
30         CASE_RETURN_STR(BLE_GAP_EVENT_DISCONNECT)
31         CASE_RETURN_STR(BLE_GAP_EVENT_CONN_UPDATE)
32         CASE_RETURN_STR(BLE_GAP_EVENT_CONN_UPDATE_REQ)
33         CASE_RETURN_STR(BLE_GAP_EVENT_L2CAP_UPDATE_REQ)
34         CASE_RETURN_STR(BLE_GAP_EVENT_TERM_FAILURE)
35         CASE_RETURN_STR(BLE_GAP_EVENT_DISC)
36         CASE_RETURN_STR(BLE_GAP_EVENT_DISC_COMPLETE)
37         CASE_RETURN_STR(BLE_GAP_EVENT_ADV_COMPLETE)
38         CASE_RETURN_STR(BLE_GAP_EVENT_ENC_CHANGE)
39         CASE_RETURN_STR(BLE_GAP_EVENT_PASSKEY_ACTION)
40         CASE_RETURN_STR(BLE_GAP_EVENT_NOTIFY_RX)
41         CASE_RETURN_STR(BLE_GAP_EVENT_NOTIFY_TX)
42         CASE_RETURN_STR(BLE_GAP_EVENT_SUBSCRIBE)
43         CASE_RETURN_STR(BLE_GAP_EVENT_MTU)
44         CASE_RETURN_STR(BLE_GAP_EVENT_IDENTITY_RESOLVED)
45         CASE_RETURN_STR(BLE_GAP_EVENT_REPEAT_PAIRING)
46         CASE_RETURN_STR(BLE_GAP_EVENT_PHY_UPDATE_COMPLETE)
47         CASE_RETURN_STR(BLE_GAP_EVENT_EXT_DISC)
48         CASE_RETURN_STR(BLE_GAP_EVENT_PERIODIC_SYNC)
49         CASE_RETURN_STR(BLE_GAP_EVENT_PERIODIC_REPORT)
50         CASE_RETURN_STR(BLE_GAP_EVENT_PERIODIC_SYNC_LOST)
51         CASE_RETURN_STR(BLE_GAP_EVENT_SCAN_REQ_RCVD)
52         CASE_RETURN_STR(BLE_GAP_EVENT_PERIODIC_TRANSFER)
53 
54         default:
55             return "unkown bt host evt";
56     }
57 }
tls_bt_dump_hexstring(const char * info,uint8_t * p,int length)58 void tls_bt_dump_hexstring(const char *info, uint8_t *p, int length)
59 {
60     int i = 0, j = 0;
61     printf("%s\r\n", info);
62     for (i = 0; i < length; i++) {
63         j++;
64         printf("%02x ", p[i]);
65         if ((j % 16) == 0) { // 16:byte alignment
66             printf("\r\n");
67         }
68     }
69     printf("\r\n");
70 }