Ajout de la coloration syntaxique et du système de handler

This commit is contained in:
anschrammh 2020-01-29 20:03:18 +01:00
parent 4f452fc2c1
commit ae8dee45bd
4 changed files with 73 additions and 4 deletions

View File

@ -1,6 +1,7 @@
#include "LoRaRadio.h"
lmic_pinmap lmic_pins = {0};
void (*LoRaRadio::downlinkHandler)(u1_t, u1_t, u1_t*) = NULL;
LoRaRadio::LoRaRadio(PinMap pinMap, dr_t dataRate, s1_t txPower) :_pinMap(pinMap), _dataRate(dataRate), _txPower(txPower)
{
@ -62,3 +63,31 @@ void LoRaRadio::run()
{
os_runloop_once();
}
void LoRaRadio::setDownlinkHandler(void (*funcP)(u1_t, u1_t, u1_t*))
{
downlinkHandler = funcP;
}
/*
* Here, we declare the onEvent function required by the LMIC
*/
void onEvent(ev_t ev)
{
switch(ev)
{
case EV_TXCOMPLETE:
//Event telling us that the data was transmitted
//It is also here that we check for downlinks
if(LMIC.dataLen)
{
//Data is available
if(LoRaRadio::downlinkHandler != NULL)
(*LoRaRadio::downlinkHandler)(LMIC.dataLen, LMIC.dataBeg, LMIC.frame);
}
break;
case EV_RXCOMPLETE:
// data received in ping slot
break;
}
}

View File

@ -5,6 +5,10 @@
#include <hal/hal.h>
#include <SPI.h>
#include <Arduino.h>
/*
* Here, we define the onEvent function required by the LMIC
*/
void onEvent(ev_t ev);
class PinMap
{
@ -32,6 +36,11 @@ class LoRaRadio
void setMCUClockError(u2_t percent = 30);
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*));
//Function pointers used to interact with events
//Parameters : dataLen, dataBeg, dataBuffer
static void (*downlinkHandler)(u1_t, u1_t, u1_t*);
protected:
private:
dr_t _dataRate;

View File

@ -7,10 +7,6 @@ u1_t dio[3] = {26,33,32};
void os_getArtEui (u1_t* buf) { }
void os_getDevEui (u1_t* buf) { }
void os_getDevKey (u1_t* buf) { }
void onEvent(ev_t ev)
{
}
static u1_t NWKSKEY[16] = { 0x1F, 0x9E, 0xE2, 0x7A, 0xC8, 0xBA, 0xE8, 0xEA, 0xF5, 0xC2, 0x5E, 0x47, 0x5D, 0xE0, 0x77, 0x55 };
static u1_t APPSKEY[16] = { 0x3B, 0x89, 0x86, 0x96, 0xBB, 0xAA, 0x38, 0x1E, 0x1F, 0xC4, 0xAD, 0x03, 0xEF, 0x3F, 0x56, 0x12 };

View File

@ -0,0 +1,35 @@
#######################################
# Syntax Coloring Map LoRaRadio
#######################################
#######################################
# Datatypes (KEYWORD1)
#######################################
LoRaRadio KEYWORD1
PinMap KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
init KEYWORD2
setTTNSession KEYWORD2
setRadioEUChannels KEYWORD2
setMCUClockError KEYWORD2
send KEYWORD2
run KEYWORD2
setDownlinkHandler KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################
bit_t LITERAL1
u1_t LITERAL1
u2_t LITERAL1
u4_t LITERAL1
s1_t LITERAL1
dr_t LITERAL1
devaddr_t LITERAL1
xref2u1_t LITERAL1
DR_SF7 LITERAL1
ev_t LITERAL1