• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CHRE_UTIL_NANOAPP_WIFI_H_
18 #define CHRE_UTIL_NANOAPP_WIFI_H_
19 
20 #include <cstddef>
21 #include <cstdint>
22 
23 #include <chre/wifi.h>
24 
25 namespace chre {
26 
27 //! The length of a string SSID with null-terminator.
28 constexpr size_t kMaxSsidStrLen = CHRE_WIFI_SSID_MAX_LEN + 1;
29 
30 //! The length of a formatted BSSID string in XX:XX:XX:XX:XX:XX\0 format.
31 constexpr size_t kBssidStrLen = 18;
32 
33 /**
34  * Logs the contents of a chreWifiScanResult using the LOGX macro.
35  *
36  * @param result The WiFi scan result to log.
37  * @param logSsidOnly If true, only log the SSID of the WiFi scan result,
38  * otherwise logs other fields as well.
39  */
40 void logChreWifiResult(const chreWifiScanResult &result,
41                        bool logSsidOnly = false);
42 
43 /**
44  * @param buffer a pointer to a buffer to format into.
45  * @param bufferLen a buffer to format into.
46  * @param a pointer to SSID data.
47  * @param ssidLen the length of the SSID data.
48  * @return true if the SSID is printable and was copied into the output buffer.
49  */
50 bool parseSsidToStr(char *buffer, size_t bufferLen, const uint8_t *ssid,
51                     uint8_t ssidLen);
52 
53 /**
54  * Parses a BSSID into a XX:XX:XX:XX:XX:XX formatted string.
55  *
56  * @param bssid the BSSID to format into a string.
57  * @param buffer the buffer to format the string into.
58  * @param bufferLen the length of the buffer to format into.
59  * @return true if the buffer is large enough and the string is formatted.
60  */
61 bool parseBssidToStr(const uint8_t bssid[CHRE_WIFI_BSSID_LEN], char *buffer,
62                      size_t bufferLen);
63 
64 /**
65  * Parses a WiFi band into a string.
66  *
67  * @param band the CHRE WiFi band to parse into a string.
68  * @return a pointer to the string or some indication of invalid.
69  */
70 const char *parseChreWifiBand(uint8_t band);
71 
72 }  // namespace chre
73 
74 #endif  // CHRE_UTIL_NANOAPP_WIFI_H_
75