ESP32-PaxCounter/include/lorawan.h

61 lines
1.6 KiB
C
Raw Normal View History

2018-07-17 15:15:58 +02:00
#ifndef _LORAWAN_H
#define _LORAWAN_H
#include "globals.h"
#include "rcommand.h"
2019-02-24 01:44:55 +01:00
#include "timekeeper.h"
2019-08-31 15:19:49 +02:00
#if (TIME_SYNC_LORASERVER)
2019-03-09 00:53:11 +01:00
#include "timesync.h"
2019-03-07 00:01:51 +01:00
#endif
2018-07-15 14:28:05 +02:00
// LMIC-Arduino LoRaWAN Stack
#include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>
#include <arduino_lmic_hal_boards.h>
2018-07-15 14:28:05 +02:00
#include "loraconf.h"
// Needed for 24AA02E64, does not hurt anything if included and not used
#ifdef MCP_24AA02E64_I2C_ADDRESS
#include <Wire.h>
#endif
2019-08-30 18:54:53 +02:00
extern TaskHandle_t lmicTask, lorasendTask;
2019-08-31 18:36:49 +02:00
// table of LORAWAN MAC commands
typedef struct {
const uint8_t opcode;
const char cmdname[20];
const uint8_t params;
} mac_t;
2019-02-24 23:13:15 +01:00
esp_err_t lora_stack_init();
void lora_setupForNetwork(bool preJoin);
void lmictask(void *pvParameters);
void gen_lora_deveui(uint8_t *pdeveui);
void RevBytes(unsigned char *b, size_t c);
void get_hard_deveui(uint8_t *pdeveui);
2018-07-15 14:28:05 +02:00
void os_getDevKey(u1_t *buf);
void os_getArtEui(u1_t *buf);
void os_getDevEui(u1_t *buf);
2018-08-03 23:50:04 +02:00
void showLoraKeys(void);
void lora_send(void *pvParameters);
void lora_enqueuedata(MessageBuffer_t *message);
2018-11-03 20:29:02 +01:00
void lora_queuereset(void);
void myEventCallback(void *pUserData, ev_t ev);
2019-08-31 15:19:49 +02:00
void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg,
size_t nMsg);
void myTxCallback(void *pUserData, int fSuccess);
2019-09-07 14:52:18 +02:00
void mac_decode(const uint8_t cmd[], const uint8_t cmdlen, const mac_t table[],
const uint8_t tablesize);
2019-09-20 09:04:24 +02:00
uint8_t getBattLevel(void);
2019-09-20 09:51:33 +02:00
const char *getSfName(rps_t rps);
2019-09-20 13:22:45 +02:00
const char *getBwName(rps_t rps);
const char *getCrName(rps_t rps);
2019-08-31 18:36:49 +02:00
2019-03-31 15:32:22 +02:00
#if (TIME_SYNC_LORAWAN)
void user_request_network_time_callback(void *pVoidUserUTCTime,
int flagSuccess);
2019-03-31 15:32:22 +02:00
#endif
2018-07-15 14:28:05 +02:00
#endif