do unjoin when started
This commit is contained in:
parent
3d03d0b52d
commit
12f048cc39
|
|
@ -253,7 +253,7 @@ void setup(void)
|
||||||
|
|
||||||
/* for 4451, we need wider tolerances, it seems */
|
/* for 4451, we need wider tolerances, it seems */
|
||||||
#if defined(ARDUINO_ARCH_STM32)
|
#if defined(ARDUINO_ARCH_STM32)
|
||||||
LMIC_setClockError(10 * 65536 / 100);
|
LMIC_setClockError(MAX_CLOCK_ERROR * 10 / 100);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
setup_flash();
|
setup_flash();
|
||||||
|
|
@ -365,9 +365,10 @@ void setup_platform(void)
|
||||||
gCatena.SafePrintf("**** no platform, check provisioning ****\n");
|
gCatena.SafePrintf("**** no platform, check provisioning ****\n");
|
||||||
flags = 0;
|
flags = 0;
|
||||||
}
|
}
|
||||||
// Because of Alarms on Swisscom Network
|
|
||||||
LMIC_setDrTxpow(DR_SF10, 14);
|
// Swisscom temporary fix...
|
||||||
LMIC_setAdrMode(1);
|
//LMIC_setDrTxpow(DR_SF10,14);
|
||||||
|
//LMIC_setAdrMode(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup_bme280(void)
|
void setup_bme280(void)
|
||||||
|
|
@ -399,9 +400,6 @@ bool setup_scales(void)
|
||||||
// - With a gain factor of 32, channel B is selected
|
// - With a gain factor of 32, channel B is selected
|
||||||
// By omitting the gain factor parameter, the library
|
// By omitting the gain factor parameter, the library
|
||||||
// default "128" (Channel A) is used here.
|
// default "128" (Channel A) is used here.
|
||||||
#ifdef DEBUG
|
|
||||||
gCatena.SafePrintf("Setup Scale 1...\n");
|
|
||||||
#endif
|
|
||||||
LoadCell.begin(A1, A0);
|
LoadCell.begin(A1, A0);
|
||||||
|
|
||||||
if (!(LoadCell.wait_ready_timeout(2000))) {
|
if (!(LoadCell.wait_ready_timeout(2000))) {
|
||||||
|
|
@ -433,6 +431,9 @@ void setup_flash(void)
|
||||||
|
|
||||||
void setup_uplink(void)
|
void setup_uplink(void)
|
||||||
{
|
{
|
||||||
|
// Do an unjoin, so every reboot will trigger a join
|
||||||
|
LMIC_unjoin();
|
||||||
|
|
||||||
/* 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())
|
||||||
|
|
@ -615,13 +616,13 @@ void ReadSensors(bool firstTime, bool readOnly)
|
||||||
fUsbPower = (vBus > 3.0) ? true : false;
|
fUsbPower = (vBus > 3.0) ? true : false;
|
||||||
|
|
||||||
// Setup Scales
|
// Setup Scales
|
||||||
setup_scales();
|
//setup_scales();
|
||||||
|
|
||||||
// Read Scales
|
// Read Scales
|
||||||
//if (LoadCell.is_ready()) {
|
//if (LoadCell.is_ready()) {
|
||||||
if (setup_scales()) {
|
if (setup_scales()) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("HX711 LoadCell is ready.");
|
gCatena.SafePrintf("HX711 LoadCell is ready.\n");
|
||||||
#endif
|
#endif
|
||||||
LoadCell.set_gain(128);
|
LoadCell.set_gain(128);
|
||||||
long w1 = LoadCell.read_average(5);
|
long w1 = LoadCell.read_average(5);
|
||||||
|
|
@ -639,7 +640,7 @@ void ReadSensors(bool firstTime, bool readOnly)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Serial.println("HX711 LoadCell not ready.");
|
gCatena.SafePrintf("HX711 LoadCell not ready.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable Power
|
// Disable Power
|
||||||
|
|
@ -724,7 +725,7 @@ void ReadSensors(bool firstTime, bool readOnly)
|
||||||
startSendingUplink(firstTime);
|
startSendingUplink(firstTime);
|
||||||
} else {
|
} else {
|
||||||
gCatena.SafePrintf("now going to sleep for 6 minutes...\n");
|
gCatena.SafePrintf("now going to sleep for 6 minutes...\n");
|
||||||
Serial.flush();
|
//Serial.flush();
|
||||||
gLed.Set(LedPattern::Sleeping);
|
gLed.Set(LedPattern::Sleeping);
|
||||||
os_setTimedCallback(
|
os_setTimedCallback(
|
||||||
&sensorJob,
|
&sensorJob,
|
||||||
|
|
@ -813,6 +814,15 @@ static void settleDoneCb(
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
gCatena.SafePrintf("settleDoneCb\n");
|
gCatena.SafePrintf("settleDoneCb\n");
|
||||||
#endif
|
#endif
|
||||||
|
// Terry vv
|
||||||
|
gCatena.SafePrintf("LMIC.rxDelay: %i\n",LMIC.rxDelay);
|
||||||
|
gCatena.SafePrintf("LMIC.dn2Dr: %i\n",LMIC.dn2Dr);
|
||||||
|
gCatena.SafePrintf("LMIC.dn2Freq: %i\n",LMIC.dn2Freq);
|
||||||
|
gCatena.SafePrintf("LMIC.rx1DrOffset: %i\n",LMIC.rx1DrOffset);
|
||||||
|
|
||||||
|
// Terry ^^
|
||||||
|
|
||||||
|
|
||||||
sleepDoneCb(pSendJob);
|
sleepDoneCb(pSendJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -839,6 +849,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
|
||||||
|
if (port == 0)
|
||||||
|
{
|
||||||
|
gCatena.SafePrintf("MAC message:");
|
||||||
|
for (unsigned i = 0; i < LMIC.dataBeg; ++i)
|
||||||
|
{
|
||||||
|
gCatena.SafePrintf(" %02x", LMIC.frame[i]);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gCatena.SafePrintf("receiveMessage was called!!!!n");
|
||||||
|
gCatena.SafePrintf("Port: %s\n",port);
|
||||||
|
gCatena.SafePrintf("LMIC.rxDelay: %i\n",LMIC.rxDelay);
|
||||||
|
gCatena.SafePrintf("LMIC.dn2Dr: %i\n",LMIC.dn2Dr);
|
||||||
|
gCatena.SafePrintf("LMIC.dn2Freq: %i\n",LMIC.dn2Freq);
|
||||||
|
gCatena.SafePrintf("LMIC.rx1DrOffset: %i\n",LMIC.rx1DrOffset);
|
||||||
|
|
||||||
|
// Terry ^^
|
||||||
|
|
||||||
if (! (port == 1 && 2 <= nMessage && nMessage <= 3))
|
if (! (port == 1 && 2 <= nMessage && nMessage <= 3))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue