[LR11x0] Remove WIP GNSS functionality (moved to branch)

This commit is contained in:
jgromes 2024-09-10 18:58:46 +02:00
parent 44d2ba8487
commit 3696672f6f
2 changed files with 0 additions and 199 deletions

View file

@ -1684,172 +1684,6 @@ int16_t LR11x0::updateFirmware(const uint32_t* image, size_t size, bool nonvolat
return(state);
}
int16_t LR11x0::isGnssScanCapable() {
// get the version
LR11x0VersionInfo_t version;
int16_t state = this->getVersionInfo(&version);
RADIOLIB_ASSERT(state);
// check the device firmware version is sufficient
uint16_t versionFull = ((uint16_t)version.fwMajor << 8) | (uint16_t)version.fwMinor;
state = RADIOLIB_ERR_UNSUPPORTED;
if((version.device == RADIOLIB_LR11X0_DEVICE_LR1110) && (versionFull >= 0x0401)) {
state = RADIOLIB_ERR_NONE;
} else if((version.device == RADIOLIB_LR11X0_DEVICE_LR1120) && (versionFull >= 0x0201)) {
state = RADIOLIB_ERR_NONE;
}
RADIOLIB_ASSERT(state);
// in debug mode, dump the almanac
#if RADIOLIB_DEBUG_BASIC
uint32_t addr = 0;
uint16_t sz = 0;
state = this->gnssAlmanacReadAddrSize(&addr, &sz);
RADIOLIB_ASSERT(state);
RADIOLIB_DEBUG_BASIC_PRINTLN("Almanac@%08x, %d bytes", addr, sz);
uint32_t buff[32] = { 0 };
while(sz > 0) {
size_t len = sz > 32 ? 32 : sz/sizeof(uint32_t);
state = this->readRegMem32(addr, buff, len);
RADIOLIB_ASSERT(state);
Module::hexdump(NULL, (uint8_t*)buff, len*sizeof(uint32_t), addr);
addr += len*sizeof(uint32_t);
sz -= len*sizeof(uint32_t);
}
uint8_t almanac[22] = { 0 };
for(uint8_t i = 0; i < 128; i++) {
RADIOLIB_DEBUG_BASIC_PRINTLN("Almanac[%d]:", i);
state = this->gnssAlmanacReadSV(i, almanac);
RADIOLIB_ASSERT(state);
Module::hexdump(NULL, almanac, 22);
}
#endif
return(state);
}
int16_t LR11x0::gnssScan(uint16_t* resSize) {
// go to standby
int16_t state = standby();
RADIOLIB_ASSERT(state);
// set DIO mapping
state = setDioIrqParams(RADIOLIB_LR11X0_IRQ_GNSS_DONE);
RADIOLIB_ASSERT(state);
state = this->gnssSetConstellationToUse(0x03);
RADIOLIB_ASSERT(state);
// set scan mode (single vs multiple)
state = this->gnssSetMode(0x03);
RADIOLIB_ASSERT(state);
// start scan with high effort
RADIOLIB_DEBUG_BASIC_PRINTLN("GNSS scan start");
state = this->gnssPerformScan(0x01, 0x3C, 8);
RADIOLIB_ASSERT(state);
// wait for scan finished or timeout
RadioLibTime_t softTimeout = 300UL * 1000UL;
RadioLibTime_t start = this->mod->hal->millis();
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
if(this->mod->hal->millis() - start > softTimeout) {
RADIOLIB_DEBUG_BASIC_PRINTLN("Timeout waiting for IRQ");
this->standby();
return(RADIOLIB_ERR_RX_TIMEOUT);
}
}
RADIOLIB_DEBUG_BASIC_PRINTLN("GNSS scan done in %lu ms", (long unsigned int)(this->mod->hal->millis() - start));
state = this->clearIrq(RADIOLIB_LR11X0_IRQ_ALL);
RADIOLIB_ASSERT(state);
int8_t status = 0;
uint8_t info = 0;
state = this->gnssReadDemodStatus(&status, &info);
RADIOLIB_ASSERT(state);
RADIOLIB_DEBUG_BASIC_PRINTLN("Demod status %d, info %02x", (int)status, (unsigned int)info);
uint8_t fwVersion = 0;
uint32_t almanacCrc = 0;
uint8_t errCode = 0;
uint8_t almUpdMask = 0;
uint8_t freqSpace = 0;
state = this->gnssGetContextStatus(&fwVersion, &almanacCrc, &errCode, &almUpdMask, &freqSpace);
RADIOLIB_DEBUG_BASIC_PRINTLN("Context status fwVersion %d, almanacCrc %lx, errCode %d, almUpdMask %d, freqSpace %d",
(int)fwVersion, (unsigned long)almanacCrc, (int)errCode, (int)almUpdMask, (int)freqSpace);
RADIOLIB_ASSERT(state);
uint8_t stat[53] = { 0 };
state = this->gnssReadAlmanacStatus(stat);
RADIOLIB_ASSERT(state);
//Module::hexdump(NULL, stat, 53);
return(this->gnssGetResultSize(resSize));
}
int16_t LR11x0::getGnssScanResult(uint16_t size) {
uint32_t timing[31] = { 0 };
uint8_t constDemod = 0;
int16_t state = this->gnssReadCumulTiming(timing, &constDemod);
RADIOLIB_ASSERT(state);
RADIOLIB_DEBUG_BASIC_PRINTLN("Timing:");
for(size_t i = 0; i < 31; i++) {
uint32_t t = (timing[i] * 1000UL) / 32768UL;
(void)t;
RADIOLIB_DEBUG_BASIC_PRINTLN(" %d: %lu ms", (int)i*4, (unsigned long)t);
}
RADIOLIB_DEBUG_BASIC_PRINTLN("constDemod: %d", constDemod);
uint8_t nbSv = 0;
state = this->gnssGetNbSvDetected(&nbSv);
RADIOLIB_ASSERT(state);
RADIOLIB_DEBUG_BASIC_PRINTLN("Detected %d SVs:", nbSv);
uint8_t svId[32] = { 0 };
uint8_t snr[32] = { 0 };
int16_t doppler[32] = { 0 };
state = this->gnssGetSvDetected(svId, snr, doppler, nbSv);
RADIOLIB_ASSERT(state);
for(size_t i = 0; i < nbSv; i++) {
RADIOLIB_DEBUG_BASIC_PRINTLN(" SV %d: C/N0 %i dB, Doppler %i Hz", (int)i, snr[i] + 31, doppler[i]);
}
float lat = 0;
float lon = 0;
state = this->gnssReadAssistancePosition(&lat, &lon);
RADIOLIB_ASSERT(state);
RADIOLIB_DEBUG_BASIC_PRINTLN("lat = %.5f, lon = %.5f", lat, lon);
// read the result
uint8_t res[256] = { 0 };
state = this->gnssReadResults(res, size);
RADIOLIB_ASSERT(state);
RADIOLIB_DEBUG_BASIC_PRINTLN("Result type: %02x", (int)res[0]);
return(state);
}
int16_t LR11x0::getGnssPosition(float* lat, float* lon, bool filtered) {
uint8_t error = 0;
uint8_t nbSvUsed = 0;
uint16_t accuracy = 0;
int16_t state;
if(filtered) {
state = this->gnssReadDopplerSolverRes(&error, &nbSvUsed, NULL, NULL, NULL, NULL, lat, lon, &accuracy, NULL);
} else {
state = this->gnssReadDopplerSolverRes(&error, &nbSvUsed, lat, lon, &accuracy, NULL, NULL, NULL, NULL, NULL);
}
RADIOLIB_ASSERT(state);
RADIOLIB_DEBUG_BASIC_PRINTLN("Solver error %d, nbSvUsed %d, accuracy = %u", (int)error, (int)nbSvUsed, (unsigned int)accuracy);
return(state);
}
int16_t LR11x0::modSetup(float tcxoVoltage, uint8_t modem) {
this->mod->init();
this->mod->hal->pinMode(this->mod->getIrq(), this->mod->hal->GpioModeInput);

View file

@ -1375,39 +1375,6 @@ class LR11x0: public PhysicalLayer {
*/
int16_t updateFirmware(const uint32_t* image, size_t size, bool nonvolatile = true);
/*!
\brief Method to check whether the device is capable of performing a GNSS scan.
CAUTION: Work in progress! Most data is returned via debug prints.
\returns \ref status_codes
*/
int16_t isGnssScanCapable();
/*!
\brief Performs GNSS scan.
CAUTION: Work in progress! Most data is returned via debug prints.
\param resSize Pointer to a variable in which the result size will be saved.
\returns \ref status_codes
*/
int16_t gnssScan(uint16_t* resSize);
/*!
\brief Get GNSS scan result.
CAUTION: Work in progress! Most data is returned via debug prints.
\param size Result size to read.
\returns \ref status_codes
*/
int16_t getGnssScanResult(uint16_t size);
/*!
\brief Get GNSS position.
CAUTION: Work in progress! Most data is returned via debug prints.
\param lat Pointer to a variable where latitude in degrees will be saved.
\param lon Pointer to a variable where longitude in degrees will be saved.
\param filtered Whether to save the filtered, or unfiltered value. Defaults to true (filtered).
\returns \ref status_codes
*/
int16_t getGnssPosition(float* lat, float* lon, bool filtered = true);
#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL
protected:
#endif