libpax integration 6 (trigger sendcycle)

This commit is contained in:
cyberman54 2021-04-01 12:17:46 +02:00
parent 9335161676
commit 0b271f95b3
8 changed files with 17 additions and 17 deletions

View File

@ -443,7 +443,7 @@ Send for example `83` `86` as Downlink on Port 2 to get battery status and time/
8 = reboot device to maintenance mode (local web server)
9 = reboot device to OTA update via Wifi mode
0x0A set LoRaWAN payload send cycle
0x0A set payload send cycle
0 ... 255 payload send cycle in seconds/2
e.g. 120 -> payload is transmitted each 240 seconds [default]

View File

@ -1,11 +1,13 @@
#ifndef _LIBPAX_HELPERS_H
#define _LIBPAX_HELPERS_H
#include "globals.h"
#include <stdio.h>
#include <libpax_api.h>
#include "globals.h"
#include "senddata.h"
#include "configmanager.h"
void init_libpax();
void init_libpax(void);
extern uint16_t volatile libpax_macs_ble, libpax_macs_wifi; // libpax values

View File

@ -16,7 +16,6 @@
#endif
extern struct count_payload_t count_from_libpax;
extern Ticker sendTimer;
void SendPayload(uint8_t port);
void sendData(void);

View File

@ -12,10 +12,11 @@ void process_count(void) {
count_from_libpax.wifi_count, count_from_libpax.ble_count);
libpax_macs_ble = count_from_libpax.ble_count;
libpax_macs_wifi = count_from_libpax.wifi_count;
setSendIRQ();
}
void init_libpax() {
libpax_counter_init(process_count, &count_from_libpax, SENDCYCLE * 2 * 1000,
void init_libpax(void) {
libpax_counter_init(process_count, &count_from_libpax, cfg.sendcycle * 2 * 1000,
1);
libpax_counter_start();
}

View File

@ -65,11 +65,11 @@ MatrixDisplayIRQ-> esp32 timer 3
ButtonIRQ -> external GPIO
PMUIRQ -> PMU chip GPIO
fired by software (Ticker.h)
TIMESYNC_IRQ -> setTimeSyncIRQ()
CYCLIC_IRQ -> setCyclicIRQ()
SENDCYCLE_IRQ -> setSendIRQ()
BME_IRQ -> setBMEIRQ()
fired by software
TIMESYNC_IRQ -> setTimeSyncIRQ() -> Ticker.h
CYCLIC_IRQ -> setCyclicIRQ() -> Ticker.h
SENDCYCLE_IRQ -> setSendIRQ() -> xTimer
BME_IRQ -> setBMEIRQ() -> Ticker.h
ClockTask (Core 1), see timekeeper.cpp
@ -484,7 +484,6 @@ void setup() {
#endif // HAS_BUTTON
// cyclic function interrupts
sendTimer.attach(cfg.sendcycle * 2, setSendIRQ);
cyclicTimer.attach(HOMECYCLE, setCyclicIRQ);
// only if we have a timesource we do timesync

View File

@ -67,9 +67,10 @@ void set_rssi(uint8_t val[]) {
void set_sendcycle(uint8_t val[]) {
cfg.sendcycle = val[0];
// update send cycle interrupt [seconds / 2]
sendTimer.attach(cfg.sendcycle * 2, setSendIRQ);
ESP_LOGI(TAG, "Remote command: set send cycle to %d seconds",
cfg.sendcycle * 2);
libpax_counter_stop();
init_libpax();
}
void set_sleepcycle(uint8_t val[]) {

View File

@ -102,7 +102,7 @@ void enter_deepsleep(const uint64_t wakeup_sec, gpio_num_t wakeup_gpio) {
wakeup_gpio = GPIO_NUM_MAX;
// stop further enqueuing of senddata and MAC processing
sendTimer.detach();
libpax_counter_stop();
// switch off radio and other power consuming hardware
#if (HAS_SDS011)

View File

@ -1,8 +1,6 @@
// Basic Config
#include "senddata.h"
Ticker sendTimer;
void setSendIRQ() { xTaskNotify(irqHandlerTask, SENDCYCLE_IRQ, eSetBits); }
// put data to send in RTos Queues used for transmit over channels Lora and SPI