Stand Hoechfeld Update
This commit is contained in:
parent
12f048cc39
commit
794b4066ed
|
|
@ -35,7 +35,9 @@ using namespace McciCatena;
|
||||||
|
|
|
|
||||||
| MANIFEST CONSTANTS & TYPEDEFS
|
| MANIFEST CONSTANTS & TYPEDEFS
|
||||||
|
|
|
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
|
|
||||||
|
constexpr uint8_t kUplinkPort = 2;
|
||||||
|
|
||||||
/* how long do we wait between transmissions? (in seconds) */
|
/* how long do we wait between transmissions? (in seconds) */
|
||||||
enum {
|
enum {
|
||||||
|
|
@ -84,7 +86,7 @@ unsigned gTxCycleCount;
|
||||||
// forwards
|
// forwards
|
||||||
static void settleDoneCb(osjob_t* pSendJob);
|
static void settleDoneCb(osjob_t* pSendJob);
|
||||||
static void warmupDoneCb(osjob_t* pSendJob);
|
static void warmupDoneCb(osjob_t* pSendJob);
|
||||||
static void txFailedDoneCb(osjob_t* pSendJob);
|
static void txNotProvisionedCb(osjob_t *pSendJob);
|
||||||
static void sleepDoneCb(osjob_t* pSendJob);
|
static void sleepDoneCb(osjob_t* pSendJob);
|
||||||
static Arduino_LoRaWAN::SendBufferCbFn sendBufferDoneCb;
|
static Arduino_LoRaWAN::SendBufferCbFn sendBufferDoneCb;
|
||||||
static Arduino_LoRaWAN::ReceivePortBufferCbFn receiveMessage;
|
static Arduino_LoRaWAN::ReceivePortBufferCbFn receiveMessage;
|
||||||
|
|
@ -251,11 +253,6 @@ void setup(void)
|
||||||
setup_bme280();
|
setup_bme280();
|
||||||
//setup_scales();
|
//setup_scales();
|
||||||
|
|
||||||
/* for 4451, we need wider tolerances, it seems */
|
|
||||||
#if defined(ARDUINO_ARCH_STM32)
|
|
||||||
LMIC_setClockError(MAX_CLOCK_ERROR * 10 / 100);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
setup_flash();
|
setup_flash();
|
||||||
setup_uplink();
|
setup_uplink();
|
||||||
}
|
}
|
||||||
|
|
@ -366,9 +363,6 @@ void setup_platform(void)
|
||||||
flags = 0;
|
flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Swisscom temporary fix...
|
|
||||||
//LMIC_setDrTxpow(DR_SF10,14);
|
|
||||||
//LMIC_setAdrMode(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup_bme280(void)
|
void setup_bme280(void)
|
||||||
|
|
@ -431,9 +425,18 @@ void setup_flash(void)
|
||||||
|
|
||||||
void setup_uplink(void)
|
void setup_uplink(void)
|
||||||
{
|
{
|
||||||
// Do an unjoin, so every reboot will trigger a join
|
#if defined(_mcci_arduino_version) && _mcci_arduino_version >= _mcci_arduino_version_calc(2,4,0,90) && \
|
||||||
LMIC_unjoin();
|
defined(CATENA_ARDUINO_PLATFORM_VERSION_CALC) && CATENA_ARDUINO_PLATFORM_VERSION >= CATENA_ARDUINO_PLATFORM_VERSION_CALC(0,17,0,10)
|
||||||
|
LMIC_setClockError(5*65536/100);
|
||||||
|
#else
|
||||||
|
LMIC_setClockError(10*65536/100);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Do an unjoin, so every reboot will trigger a join
|
||||||
|
gCatena.SafePrintf("Do an unjoin...\n");
|
||||||
|
LMIC_unjoin();
|
||||||
|
LMIC_setLinkCheckMode(1);
|
||||||
|
|
||||||
/* trigger a join by sending the first packet */
|
/* trigger a join by sending the first packet */
|
||||||
if (!(gCatena.GetOperatingFlags() & static_cast<uint32_t>(gCatena.OPERATING_FLAGS::fManufacturingTest))) {
|
if (!(gCatena.GetOperatingFlags() & static_cast<uint32_t>(gCatena.OPERATING_FLAGS::fManufacturingTest))) {
|
||||||
if (!gLoRaWAN.IsProvisioned())
|
if (!gLoRaWAN.IsProvisioned())
|
||||||
|
|
@ -768,12 +771,12 @@ void startSendingUplink(bool firstTime)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
gCatena.SafePrintf("SendBuffer firstTime\n");
|
gCatena.SafePrintf("SendBuffer firstTime\n");
|
||||||
#endif
|
#endif
|
||||||
gLoRaWAN.SendBuffer((uint8_t*)&lora_data_first, sizeof(LORA_data_first), sendBufferDoneCb, NULL, fConfirmed);
|
gLoRaWAN.SendBuffer((uint8_t*)&lora_data_first, sizeof(LORA_data_first), sendBufferDoneCb, NULL, fConfirmed, kUplinkPort);
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
gCatena.SafePrintf("SendBuffer not firstTime\n");
|
gCatena.SafePrintf("SendBuffer not firstTime\n");
|
||||||
#endif
|
#endif
|
||||||
gLoRaWAN.SendBuffer((uint8_t*)&lora_data, sizeof(LORA_data), sendBufferDoneCb, NULL, fConfirmed);
|
gLoRaWAN.SendBuffer((uint8_t*)&lora_data, sizeof(LORA_data), sendBufferDoneCb, NULL, fConfirmed, kUplinkPort);
|
||||||
}
|
}
|
||||||
ClearLoraData();
|
ClearLoraData();
|
||||||
}
|
}
|
||||||
|
|
@ -785,27 +788,37 @@ static void sendBufferDoneCb(
|
||||||
osjobcb_t pFn;
|
osjobcb_t pFn;
|
||||||
|
|
||||||
gLed.Set(LedPattern::Settling);
|
gLed.Set(LedPattern::Settling);
|
||||||
if (!fStatus) {
|
|
||||||
gCatena.SafePrintf("send buffer failed\n");
|
pFn = settleDoneCb;
|
||||||
pFn = txFailedDoneCb;
|
if (! fStatus)
|
||||||
}
|
{
|
||||||
else {
|
if (!gLoRaWAN.IsProvisioned())
|
||||||
pFn = settleDoneCb;
|
{
|
||||||
|
// we'll talk about it at the callback.
|
||||||
|
pFn = txNotProvisionedCb;
|
||||||
|
|
||||||
|
// but prevent join attempts now.
|
||||||
|
gLoRaWAN.Shutdown();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
gCatena.SafePrintf("send buffer failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
os_setTimedCallback(
|
os_setTimedCallback(
|
||||||
&sensorJob,
|
&sensorJob,
|
||||||
os_getTime() + sec2osticks(CATCFG_T_SETTLE),
|
os_getTime() + sec2osticks(CATCFG_T_SETTLE),
|
||||||
pFn);
|
pFn
|
||||||
}
|
);
|
||||||
|
|
||||||
static void txFailedDoneCb(
|
|
||||||
osjob_t* pSendJob)
|
|
||||||
{
|
|
||||||
gCatena.SafePrintf("not provisioned, idling\n");
|
|
||||||
gLoRaWAN.Shutdown();
|
|
||||||
gLed.Set(LedPattern::NotProvisioned);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void txNotProvisionedCb(
|
||||||
|
osjob_t *pSendJob
|
||||||
|
)
|
||||||
|
{
|
||||||
|
gCatena.SafePrintf("LoRaWAN not provisioned yet. Use the commands to set it up.\n");
|
||||||
|
gLoRaWAN.Shutdown();
|
||||||
|
gLed.Set(LedPattern::NotProvisioned);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void settleDoneCb(
|
static void settleDoneCb(
|
||||||
|
|
@ -814,13 +827,13 @@ static void settleDoneCb(
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
gCatena.SafePrintf("settleDoneCb\n");
|
gCatena.SafePrintf("settleDoneCb\n");
|
||||||
#endif
|
#endif
|
||||||
// Terry vv
|
// Terry vv
|
||||||
gCatena.SafePrintf("LMIC.rxDelay: %i\n",LMIC.rxDelay);
|
gCatena.SafePrintf("LMIC.rxDelay: %i\n", LMIC.rxDelay);
|
||||||
gCatena.SafePrintf("LMIC.dn2Dr: %i\n",LMIC.dn2Dr);
|
gCatena.SafePrintf("LMIC.dn2Dr: %i\n", LMIC.dn2Dr);
|
||||||
gCatena.SafePrintf("LMIC.dn2Freq: %i\n",LMIC.dn2Freq);
|
gCatena.SafePrintf("LMIC.dn2Freq: %i\n", LMIC.dn2Freq);
|
||||||
gCatena.SafePrintf("LMIC.rx1DrOffset: %i\n",LMIC.rx1DrOffset);
|
gCatena.SafePrintf("LMIC.rx1DrOffset: %i\n", LMIC.rx1DrOffset);
|
||||||
|
|
||||||
// Terry ^^
|
// Terry ^^
|
||||||
|
|
||||||
|
|
||||||
sleepDoneCb(pSendJob);
|
sleepDoneCb(pSendJob);
|
||||||
|
|
@ -849,25 +862,25 @@ static void receiveMessage(void *pContext, uint8_t port, const uint8_t *pMessage
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
gCatena.SafePrintf("receiveMessage was called!!!\n");
|
gCatena.SafePrintf("receiveMessage was called!!!\n");
|
||||||
#endif
|
#endif
|
||||||
// Terry vv
|
// Terry vv
|
||||||
if (port == 0)
|
if (port == 0)
|
||||||
{
|
{
|
||||||
gCatena.SafePrintf("MAC message:");
|
gCatena.SafePrintf("MAC message:");
|
||||||
for (unsigned i = 0; i < LMIC.dataBeg; ++i)
|
for (unsigned i = 0; i < LMIC.dataBeg; ++i)
|
||||||
{
|
{
|
||||||
gCatena.SafePrintf(" %02x", LMIC.frame[i]);
|
gCatena.SafePrintf(" %02x", LMIC.frame[i]);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gCatena.SafePrintf("receiveMessage was called!!!!n");
|
gCatena.SafePrintf("receiveMessage was called!!!!n");
|
||||||
gCatena.SafePrintf("Port: %s\n",port);
|
gCatena.SafePrintf("Port: %s\n", port);
|
||||||
gCatena.SafePrintf("LMIC.rxDelay: %i\n",LMIC.rxDelay);
|
gCatena.SafePrintf("LMIC.rxDelay: %i\n", LMIC.rxDelay);
|
||||||
gCatena.SafePrintf("LMIC.dn2Dr: %i\n",LMIC.dn2Dr);
|
gCatena.SafePrintf("LMIC.dn2Dr: %i\n", LMIC.dn2Dr);
|
||||||
gCatena.SafePrintf("LMIC.dn2Freq: %i\n",LMIC.dn2Freq);
|
gCatena.SafePrintf("LMIC.dn2Freq: %i\n", LMIC.dn2Freq);
|
||||||
gCatena.SafePrintf("LMIC.rx1DrOffset: %i\n",LMIC.rx1DrOffset);
|
gCatena.SafePrintf("LMIC.rx1DrOffset: %i\n", LMIC.rx1DrOffset);
|
||||||
|
|
||||||
// Terry ^^
|
// Terry ^^
|
||||||
|
|
||||||
if (! (port == 1 && 2 <= nMessage && nMessage <= 3))
|
if (! (port == 1 && 2 <= nMessage && nMessage <= 3))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue