Ajout d'un callback appelé une fois l'envoi de la trame effectuée

This commit is contained in:
anschrammh 2020-05-11 12:31:52 +02:00
parent 19589100ea
commit 182901d5bc
4 changed files with 29 additions and 4 deletions

View File

@ -1,7 +1,10 @@
#include "LoRaRadio.h"
boolean _transmitted = false;
lmic_pinmap lmic_pins = {0};
void (*LoRaRadio::downlinkHandler)(u1_t, u1_t, u1_t*) = NULL;
void (*LoRaRadio::sendCompleteHandler)(void) = NULL;
LoRaRadio::LoRaRadio(PinMap pinMap, dr_t dataRate, s1_t txPower) :_pinMap(pinMap), _dataRate(dataRate), _txPower(txPower)
{
@ -69,6 +72,11 @@ void LoRaRadio::setDownlinkHandler(void (*funcP)(u1_t, u1_t, u1_t*))
downlinkHandler = funcP;
}
void LoRaRadio::setSendCompleteHandler(void (*funcP)(void))
{
sendCompleteHandler = funcP;
}
/*
* Here, we declare the onEvent function required by the LMIC
*/
@ -78,6 +86,9 @@ void onEvent(ev_t ev)
{
case EV_TXCOMPLETE:
//Event telling us that the data was transmitted
if(LoRaRadio::sendCompleteHandler != NULL)
(*LoRaRadio::sendCompleteHandler)();
//It is also here that we check for downlinks
if(LMIC.dataLen)
{

View File

@ -1,3 +1,13 @@
/**
* Anatole SCHRAMM-HENRY
* Tim THUREL
* Projet température de la ruche GROUPE 3
* Wrapper C++ afin d'utiliser la LMIC (en C) façon objets.
* Commenté en anglais pour le plaisir des yeux.
*
* Tout droits réservés
*/
#ifndef LORARADIO_H
#define LORARADIO_H
@ -5,9 +15,10 @@
#include <hal/hal.h>
#include <SPI.h>
#include <Arduino.h>
/*
* Here, we define the onEvent function required by the LMIC
*/
/**
* Here, we define the onEvent function required by the LMIC
**/
void onEvent(ev_t ev);
class PinMap
@ -37,12 +48,14 @@ class LoRaRadio
void send(u1_t port, uint8_t *data, uint8_t length, u1_t confirmed = false);
void run();
void setDownlinkHandler(void (*funcP)(u1_t, u1_t, u1_t*));
void setSendCompleteHandler(void (*funcP)(void));
void disableEUChannel(u1_t channel);
void disableAllEUChannelsBut(u1_t channel);
//Function pointers used to interact with events
//Parameters : dataLen, dataBeg, dataBuffer
static void (*downlinkHandler)(u1_t, u1_t, u1_t*);
static void (*sendCompleteHandler)(void);
protected:
private:
dr_t _dataRate;

View File

@ -21,6 +21,7 @@ run KEYWORD2
setDownlinkHandler KEYWORD2
disableEUChannel KEYWORD2
disableAllEUChannelsBut KEYWORD2
setSendCompleteHandler KEYWORD2
#######################################
# Constants (LITERAL1)