• 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  * @param buffer a pointer to a buffer to format into.
35  * @param bufferLen a buffer to format into.
36  * @param a pointer to SSID data.
37  * @param ssidLen the length of the SSID data.
38  * @return true if the SSID is printable and was copied into the output buffer.
39  */
40 bool parseSsidToStr(char *buffer, size_t bufferLen,
41                     const uint8_t *ssid, uint8_t ssidLen);
42 
43 /**
44  * Parses a BSSID into a XX:XX:XX:XX:XX:XX formatted string.
45  *
46  * @param bssid the BSSID to format into a string.
47  * @param buffer the buffer to format the string into.
48  * @param bufferLen the length of the buffer to format into.
49  * @return true if the buffer is large enough and the string is formatted.
50  */
51 bool parseBssidToStr(const uint8_t bssid[CHRE_WIFI_BSSID_LEN],
52                      char *buffer, size_t bufferLen);
53 
54 /**
55  * Parses a WiFi band into a string.
56  *
57  * @param band the CHRE WiFi band to parse into a string.
58  * @return a pointer to the string or some indication of invalid.
59  */
60 const char *parseChreWifiBand(uint8_t band);
61 
62 }  // namespace chre
63 
64 #endif  // CHRE_UTIL_NANOAPP_WIFI_H_
65