Add repeater protocol and device firmware features
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define DUTY_LEDGER_BUCKET_US 60000000ULL
|
||||
#define DUTY_LEDGER_WINDOW_US 3600000000ULL
|
||||
#define DUTY_LEDGER_BUCKETS 61
|
||||
|
||||
typedef struct {
|
||||
uint64_t minute_key; // uptime minute + 1; zero means unused
|
||||
uint64_t airtime_us;
|
||||
} duty_ledger_bucket_t;
|
||||
|
||||
typedef struct {
|
||||
duty_ledger_bucket_t buckets[DUTY_LEDGER_BUCKETS];
|
||||
} duty_ledger_t;
|
||||
|
||||
// Minute buckets conservatively include the whole oldest overlapping minute.
|
||||
// The result can over-count by less than one minute, but never drops airtime
|
||||
// that may still be inside the rolling-hour window.
|
||||
uint64_t duty_ledger_used(const duty_ledger_t *ledger, int64_t now_us);
|
||||
void duty_ledger_record(duty_ledger_t *ledger, int64_t now_us,
|
||||
uint32_t airtime_us);
|
||||
Reference in New Issue
Block a user