changes in antenna.cpp; license cleanup
This commit is contained in:
parent
05e9843bd5
commit
62325e9d40
16
LICENSE
16
LICENSE
@ -19,22 +19,6 @@ NOTICE:
|
|||||||
Parts of the source files in this repository are made available under different licenses,
|
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.
|
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
|
wifisniffer.cpp
|
||||||
|
|
||||||
|
@ -5,7 +5,10 @@
|
|||||||
// Local logging tag
|
// Local logging tag
|
||||||
static const char *TAG = "antenna";
|
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) {
|
void antenna_init(void) {
|
||||||
gpio_config_t gpioconf = {.pin_bit_mask = 1ull << PIN_ANTENNA_SWITCH,
|
gpio_config_t gpioconf = {.pin_bit_mask = 1ull << PIN_ANTENNA_SWITCH,
|
||||||
@ -16,22 +19,21 @@ void antenna_init(void) {
|
|||||||
gpio_config(&gpioconf);
|
gpio_config(&gpioconf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void antenna_select (antenna_type_t _antenna) {
|
void antenna_select (antenna_type_t _ant) {
|
||||||
if (PIN_ANTENNA_SWITCH < 32) {
|
if (PIN_ANTENNA_SWITCH < 32) {
|
||||||
// set the pin value
|
if (_ant == ANTENNA_EXT) {
|
||||||
if (_antenna == ANTENNA_TYPE_EXTERNAL) {
|
|
||||||
GPIO_REG_WRITE(GPIO_OUT_W1TS_REG, 1 << PIN_ANTENNA_SWITCH);
|
GPIO_REG_WRITE(GPIO_OUT_W1TS_REG, 1 << PIN_ANTENNA_SWITCH);
|
||||||
} else {
|
} else {
|
||||||
GPIO_REG_WRITE(GPIO_OUT_W1TC_REG, 1 << PIN_ANTENNA_SWITCH);
|
GPIO_REG_WRITE(GPIO_OUT_W1TC_REG, 1 << PIN_ANTENNA_SWITCH);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_antenna == ANTENNA_TYPE_EXTERNAL) {
|
if (_ant == ANTENNA_EXT) {
|
||||||
GPIO_REG_WRITE(GPIO_OUT1_W1TS_REG, 1 << (PIN_ANTENNA_SWITCH & 31));
|
GPIO_REG_WRITE(GPIO_OUT1_W1TS_REG, 1 << (PIN_ANTENNA_SWITCH & 31));
|
||||||
} else {
|
} else {
|
||||||
GPIO_REG_WRITE(GPIO_OUT1_W1TC_REG, 1 << (PIN_ANTENNA_SWITCH & 31));
|
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 //
|
#endif //
|
@ -15,12 +15,4 @@
|
|||||||
|
|
||||||
// select WIFI antenna (internal = onboard / external = u.fl socket)
|
// select WIFI antenna (internal = onboard / external = u.fl socket)
|
||||||
#define PIN_ANTENNA_SWITCH 16
|
#define PIN_ANTENNA_SWITCH 16
|
||||||
#define WIFI_LOPY_ANTENNA ANTENNA_TYPE_INTERNAL
|
#define WIFI_ANTENNA ANTENNA_INT // can be switced to ANTENNA_EXT
|
||||||
|
|
||||||
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);
|
|
||||||
|
@ -15,12 +15,4 @@
|
|||||||
|
|
||||||
// select WIFI antenna (internal = onboard / external = u.fl socket)
|
// select WIFI antenna (internal = onboard / external = u.fl socket)
|
||||||
#define PIN_ANTENNA_SWITCH 21
|
#define PIN_ANTENNA_SWITCH 21
|
||||||
#define WIFI_LOPY_ANTENNA ANTENNA_TYPE_INTERNAL
|
#define WIFI_ANTENNA ANTENNA_INT // can be switced to ANTENNA_EXT
|
||||||
|
|
||||||
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);
|
|
||||||
|
@ -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 start=lsb?len:0;
|
||||||
uint8_t end = lsb?0:len;
|
uint8_t end = lsb?0:len;
|
||||||
const uint8_t * p ;
|
const uint8_t * p ;
|
||||||
char keystring[len+1] = "?", keybyte[3];
|
char keystring[len+1] = "", keybyte[3];
|
||||||
for (uint8_t i=0; i<len ; i++) {
|
for (uint8_t i=0; i<len ; i++) {
|
||||||
p = lsb ? key+len-i-1 : key+i;
|
p = lsb ? key+len-i-1 : key+i;
|
||||||
sprintf(keybyte, "%02X", * p);
|
sprintf(keybyte, "%02X", * p);
|
||||||
|
@ -370,7 +370,7 @@ void setup() {
|
|||||||
// initialize wifi antenna
|
// initialize wifi antenna
|
||||||
#ifdef LOPY
|
#ifdef LOPY
|
||||||
antenna_init();
|
antenna_init();
|
||||||
antenna_select(WIFI_LOPY_ANTENNA);
|
antenna_select(WIFI_ANTENNA);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// initialize display
|
// initialize display
|
||||||
|
Loading…
Reference in New Issue
Block a user