Home | History | Annotate | Download | only in wifi
      1 //
      2 //  Copyright (C) 2016 Google, Inc.
      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 #pragma once
     18 
     19 #include <rapidjson/document.h>
     20 #include <tuple>
     21 
     22 // WifiFacade provides simple wrappers to call Wi-Fi HAL APIs.
     23 //
     24 // Each public function returns a tuple: <result, code>, where:
     25 //     result: result of HAL API or a dummy value (of the correct type)
     26 //             on failure.
     27 //     code: sl4n_error_codes::kPassInt or sl4n_error_codes::kFailInt on
     28 //           success or failure respectively.
     29 //
     30 // The wrapper must check whether or not it is possible to call the API.
     31 // Note the function "SharedValidator()" should be used by wrapper to check
     32 // whether or not the HAL is configured correctly.
     33 class WifiFacade {
     34  public:
     35   WifiFacade();
     36   std::tuple<bool, int> WifiInit();
     37   std::tuple<int, int> WifiGetSupportedFeatureSet();
     38  private:
     39   wifi_hal_fn hal_fn;
     40   wifi_handle wifi_hal_handle;
     41   wifi_interface_handle* wifi_iface_handles;
     42   int num_wifi_iface_handles;
     43   int wlan0_index;
     44   int p2p0_index;
     45 
     46   bool SharedValidator();
     47   bool WifiStartHal();
     48   bool WifiGetInterfaces();
     49 };
     50