code sanitization

This commit is contained in:
Klaus K Wilting 2018-12-02 14:29:32 +01:00
parent decb8b7181
commit 47579414ac
4 changed files with 5 additions and 94 deletions

View File

@ -1,77 +0,0 @@
// Copyright 2018-2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __COEXIST_INTERNAL_H__
#define __COEXIST_INTERNAL_H__
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
COEX_PREFER_WIFI = 0,
COEX_PREFER_BT,
COEX_PREFER_BALANCE,
COEX_PREFER_NUM,
} coex_prefer_t;
/**
* @brief Init software coexist
* extern function for internal use.
*
* @return Init ok or failed.
*/
esp_err_t coex_init(void);
/**
* @brief De-init software coexist
* extern function for internal use.
*/
void coex_deinit(void);
/**
* @brief Pause software coexist
* extern function for internal use.
*/
void coex_pause(void);
/**
* @brief Resume software coexist
* extern function for internal use.
*/
void coex_resume(void);
/**
* @brief Get software coexist version string
* extern function for internal use.
* @return : version string
*/
const char *coex_version_get(void);
/**
* @brief Coexist performance preference set from libbt.a
* extern function for internal use.
*
* @param prefer : the prefer enumeration value
* @return : ESP_OK - success, other - failed
*/
esp_err_t coex_preference_set(coex_prefer_t prefer);
#ifdef __cplusplus
}
#endif
#endif /* __COEXIST_INTERNAL_H__ */

View File

@ -16,7 +16,4 @@
#include "spislave.h" #include "spislave.h"
#include "lorawan.h" #include "lorawan.h"
#include <esp_coexist.h>
#include "coexist_internal.h"
#endif #endif

View File

@ -106,7 +106,7 @@ void setup() {
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded"
: "external"); : "external");
ESP_LOGI(TAG, "ESP32 SDK: %s", ESP.getSdkVersion()); ESP_LOGI(TAG, "ESP32 SDK: %s", ESP.getSdkVersion());
ESP_LOGI(TAG, "Wifi/BT software coexist version: %s", esp_coex_version_get()); ESP_LOGI(TAG, "Wifi/BT software coexist version: %s", coex_version_get());
ESP_LOGI(TAG, "Free RAM: %d bytes", ESP.getFreeHeap()); ESP_LOGI(TAG, "Free RAM: %d bytes", ESP.getFreeHeap());
#ifdef HAS_GPS #ifdef HAS_GPS

View File

@ -2,7 +2,6 @@
#include "globals.h" #include "globals.h"
#include "wifiscan.h" #include "wifiscan.h"
#include <esp_coexist.h> #include <esp_coexist.h>
#include "coexist_internal.h"
// Local logging tag // Local logging tag
static const char TAG[] = "wifi"; static const char TAG[] = "wifi";
@ -11,7 +10,7 @@ static wifi_country_t wifi_country = {WIFI_MY_COUNTRY, WIFI_CHANNEL_MIN,
WIFI_CHANNEL_MAX, 100, WIFI_CHANNEL_MAX, 100,
WIFI_COUNTRY_POLICY_MANUAL}; WIFI_COUNTRY_POLICY_MANUAL};
esp_coex_prefer_t coexist_config = ESP_COEX_PREFER_BALANCE; esp_coex_prefer_t esp_coexist_config = ESP_COEX_PREFER_BALANCE;
typedef struct { typedef struct {
unsigned frame_ctrl : 16; unsigned frame_ctrl : 16;
@ -45,12 +44,6 @@ IRAM_ATTR void wifi_sniffer_packet_handler(void *buff,
mac_add((uint8_t *)hdr->addr2, ppkt->rx_ctrl.rssi, MAC_SNIFF_WIFI); mac_add((uint8_t *)hdr->addr2, ppkt->rx_ctrl.rssi, MAC_SNIFF_WIFI);
} }
const char *esp_coex_version_get(void) { return coex_version_get(); }
esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer) {
return coex_preference_set((coex_prefer_t)prefer);
}
void wifi_sniffer_init(void) { void wifi_sniffer_init(void) {
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
cfg.nvs_enable = 0; // we don't need any wifi settings from NVRAM cfg.nvs_enable = 0; // we don't need any wifi settings from NVRAM
@ -59,12 +52,10 @@ void wifi_sniffer_init(void) {
// .filter_mask = WIFI_PROMIS_FILTER_MASK_MGMT}; // only MGMT frames // .filter_mask = WIFI_PROMIS_FILTER_MASK_MGMT}; // only MGMT frames
.filter_mask = WIFI_PROMIS_FILTER_MASK_ALL}; // we use all frames .filter_mask = WIFI_PROMIS_FILTER_MASK_ALL}; // we use all frames
coex_pause(); //coex_pause();
ESP_ERROR_CHECK( ESP_ERROR_CHECK(
esp_coex_preference_set(coexist_config)); // configure Wifi/BT coexist lib esp_coex_preference_set(esp_coexist_config)); // configure Wifi/BT coexist lib
coex_resume(); //coex_resume();
//coex_deinit();
ESP_ERROR_CHECK(esp_wifi_init(&cfg)); // configure Wifi with cfg ESP_ERROR_CHECK(esp_wifi_init(&cfg)); // configure Wifi with cfg
ESP_ERROR_CHECK( ESP_ERROR_CHECK(