From 62325e9d40f4e20268a311d0ef861832e0038106 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 24 Mar 2018 11:28:33 +0100 Subject: [PATCH] changes in antenna.cpp; license cleanup --- LICENSE | 16 ---------------- src/antenna.cpp | 14 ++++++++------ src/hal/lopy.h | 10 +--------- src/hal/lopy4.h | 10 +--------- src/lorawan.cpp | 2 +- src/main.cpp | 2 +- 6 files changed, 12 insertions(+), 42 deletions(-) diff --git a/LICENSE b/LICENSE index 06a05aed..6145f231 100644 --- a/LICENSE +++ b/LICENSE @@ -19,22 +19,6 @@ NOTICE: Parts of the source files in this repository are made available under different licenses, listed below. Refer to each individual source file for more details. ------------------------------------------------------------------------------------------------- -antenna.cpp - -Parts of antenna.cpp were derived or taken from - -https://github.com/pycom/pycom-micropython-sigfox/blob/master/esp32/util/antenna.c - -under this Licence: - -Copyright (c) 2016, Pycom Limited. - -This software is licensed under the GNU GPL version 3 or any -later version, with permitted additional terms. For more information -see the Pycom Licence v1.0 document supplied with this file, or -available at https://www.pycom.io/opensource/licensing - ------------------------------------------------------------------------------------------------ wifisniffer.cpp diff --git a/src/antenna.cpp b/src/antenna.cpp index 95da8ea9..5485f4fa 100644 --- a/src/antenna.cpp +++ b/src/antenna.cpp @@ -5,7 +5,10 @@ // Local logging tag static const char *TAG = "antenna"; -static antenna_type_t antenna_type_selected = ANTENNA_TYPE_INTERNAL; +typedef enum { + ANTENNA_INT = 0, + ANTENNA_EXT +} antenna_type_t; void antenna_init(void) { gpio_config_t gpioconf = {.pin_bit_mask = 1ull << PIN_ANTENNA_SWITCH, @@ -16,22 +19,21 @@ void antenna_init(void) { gpio_config(&gpioconf); } -void antenna_select (antenna_type_t _antenna) { +void antenna_select (antenna_type_t _ant) { if (PIN_ANTENNA_SWITCH < 32) { - // set the pin value - if (_antenna == ANTENNA_TYPE_EXTERNAL) { + if (_ant == ANTENNA_EXT) { GPIO_REG_WRITE(GPIO_OUT_W1TS_REG, 1 << PIN_ANTENNA_SWITCH); } else { GPIO_REG_WRITE(GPIO_OUT_W1TC_REG, 1 << PIN_ANTENNA_SWITCH); } } else { - if (_antenna == ANTENNA_TYPE_EXTERNAL) { + if (_ant == ANTENNA_EXT) { GPIO_REG_WRITE(GPIO_OUT1_W1TS_REG, 1 << (PIN_ANTENNA_SWITCH & 31)); } else { GPIO_REG_WRITE(GPIO_OUT1_W1TC_REG, 1 << (PIN_ANTENNA_SWITCH & 31)); } } - antenna_type_selected = _antenna; + ESP_LOGI(TAG, "Wifi Antenna switched to %s", _ant ? "external" : "internal"); } #endif // \ No newline at end of file diff --git a/src/hal/lopy.h b/src/hal/lopy.h index 78da1ea2..6995ca9c 100644 --- a/src/hal/lopy.h +++ b/src/hal/lopy.h @@ -15,12 +15,4 @@ // select WIFI antenna (internal = onboard / external = u.fl socket) #define PIN_ANTENNA_SWITCH 16 -#define WIFI_LOPY_ANTENNA ANTENNA_TYPE_INTERNAL - -typedef enum { - ANTENNA_TYPE_INTERNAL = 0, - ANTENNA_TYPE_EXTERNAL -} antenna_type_t; - -extern void antenna_init (void); -extern void antenna_select (antenna_type_t antenna_type); +#define WIFI_ANTENNA ANTENNA_INT // can be switced to ANTENNA_EXT diff --git a/src/hal/lopy4.h b/src/hal/lopy4.h index bc7ad7dc..0829bf1f 100644 --- a/src/hal/lopy4.h +++ b/src/hal/lopy4.h @@ -15,12 +15,4 @@ // select WIFI antenna (internal = onboard / external = u.fl socket) #define PIN_ANTENNA_SWITCH 21 -#define WIFI_LOPY_ANTENNA ANTENNA_TYPE_INTERNAL - -typedef enum { - ANTENNA_TYPE_INTERNAL = 0, - ANTENNA_TYPE_EXTERNAL -} antenna_type_t; - -extern void antenna_init (void); -extern void antenna_select (antenna_type_t antenna_type); +#define WIFI_ANTENNA ANTENNA_INT // can be switced to ANTENNA_EXT diff --git a/src/lorawan.cpp b/src/lorawan.cpp index e9169a06..85164280 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -53,7 +53,7 @@ void printKey(const char * name, const uint8_t * key, uint8_t len, bool lsb) { uint8_t start=lsb?len:0; uint8_t end = lsb?0:len; const uint8_t * p ; - char keystring[len+1] = "?", keybyte[3]; + char keystring[len+1] = "", keybyte[3]; for (uint8_t i=0; i