Added WiFi AP console mode

This commit is contained in:
Mark Qvist
2023-01-07 16:35:07 +01:00
parent da1d9e732b
commit 910d50f11e
9 changed files with 313 additions and 27 deletions

View File

@@ -85,6 +85,8 @@
#define MAX_PKT_LENGTH 255
bool lora_preinit_done = false;
LoRaClass::LoRaClass() :
_spiSettings(8E6, MSBFIRST, SPI_MODE0),
_ss(LORA_DEFAULT_SS_PIN), _reset(LORA_DEFAULT_RESET_PIN), _dio0(LORA_DEFAULT_DIO0_PIN),
@@ -97,13 +99,26 @@ LoRaClass::LoRaClass() :
setTimeout(0);
}
int LoRaClass::begin(long frequency)
{
bool LoRaClass::preInit() {
// setup pins
pinMode(_ss, OUTPUT);
// set SS high
digitalWrite(_ss, HIGH);
SPI.begin();
// check version
uint8_t version = readRegister(REG_VERSION);
if (version != 0x12) {
return false;
}
lora_preinit_done = true;
return true;
}
int LoRaClass::begin(long frequency)
{
if (_reset != -1) {
pinMode(_reset, OUTPUT);
@@ -114,13 +129,10 @@ int LoRaClass::begin(long frequency)
delay(10);
}
// start SPI
SPI.begin();
// check version
uint8_t version = readRegister(REG_VERSION);
if (version != 0x12) {
return 0;
if (!lora_preinit_done) {
if (!preInit()) {
return false;
}
}
// put in sleep mode
@@ -433,6 +445,11 @@ void LoRaClass::setTxPower(int level, int outputPin) {
}
}
uint8_t LoRaClass::getTxPower() {
byte txp = readRegister(REG_PA_CONFIG);
return txp;
}
void LoRaClass::setFrequency(long frequency) {
_frequency = frequency;