mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-16 01:52:04 +00:00

all using US frequencies. This build fixes this (and makes the build system cleaner in general). If you are building your own builds in the IDE you'll need to start setting an environment variable called COUNTRY to your two letter country code (or leave unset to get US frequencies). See new comment in platformio.ini.
108 lines
3.2 KiB
C++
108 lines
3.2 KiB
C++
#pragma once
|
|
|
|
#include "CustomRF95.h"
|
|
#include "MemoryPool.h"
|
|
#include "MeshTypes.h"
|
|
#include "Observer.h"
|
|
#include "PointerQueue.h"
|
|
#include "configuration.h"
|
|
#include "mesh.pb.h"
|
|
|
|
// US channel settings
|
|
#define CH0_US 903.08f // MHz
|
|
#define CH_SPACING_US 2.16f // MHz
|
|
#define NUM_CHANNELS_US 13
|
|
|
|
// EU433 channel settings
|
|
#define CH0_EU433 433.175f // MHz
|
|
#define CH_SPACING_EU433 0.2f // MHz
|
|
#define NUM_CHANNELS_EU433 8
|
|
|
|
// EU865 channel settings
|
|
#define CH0_EU865 865.2f // MHz
|
|
#define CH_SPACING_EU865 0.3f // MHz
|
|
#define NUM_CHANNELS_EU865 10
|
|
|
|
// CN channel settings
|
|
#define CH0_CN 470.0f // MHz
|
|
#define CH_SPACING_CN 2.0f // MHz FIXME, this is just a guess for 470-510
|
|
#define NUM_CHANNELS_CN 20
|
|
|
|
// JP channel settings
|
|
#define CH0_JP 920.0f // MHz
|
|
#define CH_SPACING_JP 0.5f // MHz FIXME, this is just a guess for 920-925
|
|
#define NUM_CHANNELS_JP 10
|
|
|
|
// FIXME add defs for other regions and use them here
|
|
#ifdef HW_VERSION_US
|
|
#define CH0 CH0_US
|
|
#define CH_SPACING CH_SPACING_US
|
|
#define NUM_CHANNELS NUM_CHANNELS_US
|
|
#elif defined(HW_VERSION_EU433)
|
|
#define CH0 CH0_EU433
|
|
#define CH_SPACING CH_SPACING_EU433
|
|
#define NUM_CHANNELS NUM_CHANNELS_EU433
|
|
#elif defined(HW_VERSION_EU865)
|
|
#define CH0 CH0_EU865
|
|
#define CH_SPACING CH_SPACING_EU865
|
|
#define NUM_CHANNELS NUM_CHANNELS_EU865
|
|
#elif defined(HW_VERSION_CN)
|
|
#define CH0 CH0_CN
|
|
#define CH_SPACING CH_SPACING_CN
|
|
#define NUM_CHANNELS NUM_CHANNELS_CN
|
|
#elif defined(HW_VERSION_JP)
|
|
#define CH0 CH0_JP
|
|
#define CH_SPACING CH_SPACING_JP
|
|
#define NUM_CHANNELS NUM_CHANNELS_JP
|
|
#else
|
|
// HW version not set - assume US
|
|
#define CH0 CH0_US
|
|
#define CH_SPACING CH_SPACING_US
|
|
#define NUM_CHANNELS NUM_CHANNELS_US
|
|
#endif
|
|
|
|
/**
|
|
* A raw low level interface to our mesh. Only understands nodenums and bytes (not protobufs or node ids)
|
|
*/
|
|
class MeshRadio
|
|
{
|
|
public:
|
|
// Kinda ugly way of selecting different radio implementations, but soon this MeshRadio class will be going away
|
|
// entirely. At that point we can make things pretty.
|
|
#ifdef RF95_IRQ_GPIO
|
|
CustomRF95
|
|
radioIf; // the raw radio interface - for now I'm leaving public - because this class is shrinking to be almost nothing
|
|
#else
|
|
SimRadio radioIf;
|
|
#endif
|
|
|
|
/** pool is the pool we will alloc our rx packets from
|
|
* rxDest is where we will send any rx packets, it becomes receivers responsibility to return packet to the pool
|
|
*/
|
|
MeshRadio();
|
|
|
|
bool init();
|
|
|
|
private:
|
|
CallbackObserver<MeshRadio, void *> configChangedObserver =
|
|
CallbackObserver<MeshRadio, void *>(this, &MeshRadio::reloadConfig);
|
|
|
|
CallbackObserver<MeshRadio, void *> preflightSleepObserver =
|
|
CallbackObserver<MeshRadio, void *>(this, &MeshRadio::preflightSleepCb);
|
|
|
|
CallbackObserver<MeshRadio, void *> notifyDeepSleepObserver =
|
|
CallbackObserver<MeshRadio, void *>(this, &MeshRadio::notifyDeepSleepDb);
|
|
|
|
/// The radioConfig object just changed, call this to force the hw to change to the new settings
|
|
int reloadConfig(void *unused = NULL);
|
|
|
|
/// Return 0 if sleep is okay
|
|
int preflightSleepCb(void *unused = NULL) { return radioIf.canSleep() ? 0 : 1; }
|
|
|
|
int notifyDeepSleepDb(void *unused = NULL)
|
|
{
|
|
radioIf.sleep();
|
|
return 0;
|
|
}
|
|
};
|