Configurable scan pages and RSSI method

This commit is contained in:
Sassa NF
2024-12-18 12:57:23 +00:00
parent 08c5fbdde5
commit 52359cb7ac
8 changed files with 190 additions and 69 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ struct Config
bool print_profile_time;
String detection_strategy;
int samples;
int scan_ranges_sz;
size_t scan_ranges_sz;
ScanRange *scan_ranges;
int log_data_json_interval;
String listen_on_serial0;
+13
View File
@@ -0,0 +1,13 @@
#ifndef LORASA_EVENT_TYPES_H
#define LORASA_EVENT_TYPES_H
struct Event;
enum EventType
{
ALL_EVENTS = 0, // used only at registration time
DETECTED,
SCAN_TASK_COMPLETE,
_MAX_EVENT_TYPE = SCAN_TASK_COMPLETE // unused as event type
};
struct Listener;
#endif
+1 -10
View File
@@ -1,17 +1,8 @@
#ifndef LORASA_EVENTS_H
#define LORASA_EVENTS_H
struct Event;
enum EventType
{
ALL_EVENTS = 0, // used only at registration time
DETECTED,
SCAN_TASK_COMPLETE,
_MAX_EVENT_TYPE = SCAN_TASK_COMPLETE // unused as event type
};
struct Listener;
#include <cstdint>
#include <event_types.h>
#include <scan.h>
struct Event
+4 -2
View File
@@ -4,9 +4,11 @@
#include "scan.h"
#include <cstdint>
#include <cstring>
#include <events.h>
#include <stdlib.h>
uint16_t Scan::rssiMethod(size_t samples, uint16_t *result, size_t res_size)
uint16_t Scan::rssiMethod(float (*getRSSI)(void *), void *param, size_t samples,
uint16_t *result, size_t res_size)
{
float scale((float)res_size / (HI_RSSI_THRESHOLD - LO_RSSI_THRESHOLD + 0.1));
@@ -18,7 +20,7 @@ uint16_t Scan::rssiMethod(size_t samples, uint16_t *result, size_t res_size)
// N of samples
for (int r = 0; r < samples; r++)
{
float rssi = getRSSI();
float rssi = getRSSI(param);
if (rssi < -65535)
rssi = -65535;
+23 -8
View File
@@ -1,11 +1,11 @@
#ifndef LORASA_SCAN_H
#define LORASA_SCAN_H
#include <config.h>
#include <cstdint>
#include <events.h>
#include <event_types.h>
#include <stdlib.h>
#ifndef LORASA_CORE_H
#define LORASA_CORE_H
#ifdef PRINT_DEBUG
#define LOG(args...) Serial.printf(args...)
#define LOG_IF(cond, args...) \
@@ -34,6 +34,22 @@ constexpr float LO_RSSI_THRESHOLD = HI_RSSI_THRESHOLD - 66;
#define SAMPLES_RSSI 20
#endif
struct ScanPage
{
uint64_t start_mhz;
uint64_t end_mhz;
size_t page_sz;
ScanRange *scan_ranges;
~ScanPage()
{
if (page_sz > 0)
{
delete[] scan_ranges;
}
}
};
struct Scan
{
uint64_t epoch;
@@ -61,11 +77,10 @@ struct Scan
},
comms_initialized(false) {};
virtual float getRSSI() = 0;
// rssiMethod gets the data similar to the scan method,
// but uses getRSSI directly.
uint16_t rssiMethod(size_t samples, uint16_t *result, size_t res_size);
uint16_t rssiMethod(float (*getRSSI)(void *), void *param, size_t samples,
uint16_t *result, size_t res_size);
// detect method analyses result, and produces filtered_result, marking
// those values that represent a detection event.