KETCube
Macros | Functions | Variables
ketCube_lora.c File Reference

This file contains the KETCube module wrapper for Semtech's LoRa. More...

#include <stdio.h>
#include <string.h>
#include "ketCube_lora.h"
#include "ketCube_cfg.h"
#include "ketCube_common.h"
#include "ketCube_mcu.h"
#include "ketCube_terminal.h"
#include "ketCube_remote_terminal.h"
#include "ketCube_modules.h"
#include "ketCube_rxDisplay.h"
#include "hw.h"
#include "lora.h"
#include "timeServer.h"
#include "lora_mac_version.h"
#include "ketCube_radio.h"
#include "ketCube_spi.h"
#include "ketCube_ad.h"
#include "ketCube_batMeas.h"

Macros

#define LORAWAN_ADR_ON   1
 
#define LORAWAN_DEFAULT_CONFIRM_MSG_STATE   LORAWAN_UNCONFIRMED_MSG
 
#define LORAWAN_APP_PORT   2
 
#define LORAWAN_ASYNCAPP_PORT   3
 
#define LORAWAN_HEX_DISPLAY_PORT   10
 
#define LORAWAN_STRING_DISPLAY_PORT   11
 
#define LORAWAN_CUSTOM_DATA_PORT   12
 
#define LORAWAN_REMOTE_TERMINAL_PORT   13
 
#define LORAWAN_UART2WAN_PORT   14
 

Functions

static void ketCube_lora_TxNeeded (void)
 
static void ketCube_lora_RxData (lora_AppData_t *AppData)
 LoRa Rx Data callback ... More...
 
static void ketCube_lora_HasJoined (void)
 
static void ketCube_lora_ConfirmClass (DeviceClass_t Class)
 
static void ketCube_lora_MacProcessNotify (void)
 
static void ketCube_lora_DataConfirm (void)
 
static ketCube_cfg_ModError_t ketCube_lora_SendData (lora_AppData_t *AppData)
 
ketCube_cfg_ModError_t ketCube_lora_Init (ketCube_InterModMsg_t ***msg)
 Load basic module configuration data from EEPROM. More...
 
ketCube_cfg_ModError_t ketCube_lora_Send (uint8_t *buffer, uint8_t *len)
 Process lora state and prepare data... More...
 
ketCube_cfg_ModError_t ketCube_lora_AsyncSend (uint8_t *buffer, uint8_t *len)
 Process lora state and prepare data (for asynchronous send)... More...
 
ketCube_cfg_ModError_t ketCube_lora_RemoteTerminalSend (uint8_t *buffer, uint8_t *len)
 Process lora state and prepare data for remote terminal sending. More...
 
ketCube_cfg_ModError_t ketCube_lora_SleepEnter (void)
 Prepare sleep mode. More...
 
ketCube_cfg_ModError_t ketCube_lora_SleepExit (void)
 Exit sleep mode. More...
 
__weak void ketCube_lora_processCustomData (uint8_t *buffer, uint8_t len)
 Process custom data. More...
 

Variables

ketCube_lora_moduleCfg_t ketCube_lora_moduleCfg
 
static volatile bool evntJoined = FALSE
 
static volatile bool isJoined = FALSE
 
static volatile bool evntClassSwitched = FALSE
 
static volatile bool evntTxNeeded = FALSE
 
static volatile bool evntACKRx = FALSE
 
static LoRaMainCallback_t LoRaMainCallbacks
 
LoraFlagStatus LoraMacProcessRequest = LORA_RESET
 
static LoRaParam_t LoRaParamInit
 
ketCube_InterModMsg_t ketCube_lora_rxData
 
uint8_t ketCube_lora_rxDataBuff [KETCUBE_LORA_RX_BUFFER_LEN]
 
static ketCube_InterModMsg_tmodMsgQueue [2]
 

Detailed Description

This file contains the KETCube module wrapper for Semtech's LoRa.

Author
Jan Belohoubek, Jan Zaruba
Version
0.2
Date
2019-05-15
Attention

© Copyright (c) 2018 University of West Bohemia in Pilsen All rights reserved.

Developed by: The SmartCampus Team Department of Technologies and Measurement www.smartcampus.cz | www.zcu.cz

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.

Macro Definition Documentation

◆ LORAWAN_ADR_ON

#define LORAWAN_ADR_ON   1

LoRaWAN Adaptive Data Rate

Note
Please note that when ADR is enabled the end-device should be stationary

◆ LORAWAN_APP_PORT

#define LORAWAN_APP_PORT   2

LoRaWAN application port

Note
do not use 224. It is reserved for certification

◆ LORAWAN_ASYNCAPP_PORT

#define LORAWAN_ASYNCAPP_PORT   3

LoRaWAN application port for Async messagess

Note
do not use 224. It is reserved for certification

◆ LORAWAN_CUSTOM_DATA_PORT

#define LORAWAN_CUSTOM_DATA_PORT   12

◆ LORAWAN_DEFAULT_CONFIRM_MSG_STATE

#define LORAWAN_DEFAULT_CONFIRM_MSG_STATE   LORAWAN_UNCONFIRMED_MSG

LoRaWAN default confirm state

◆ LORAWAN_HEX_DISPLAY_PORT

#define LORAWAN_HEX_DISPLAY_PORT   10

◆ LORAWAN_REMOTE_TERMINAL_PORT

#define LORAWAN_REMOTE_TERMINAL_PORT   13

◆ LORAWAN_STRING_DISPLAY_PORT

#define LORAWAN_STRING_DISPLAY_PORT   11

◆ LORAWAN_UART2WAN_PORT

#define LORAWAN_UART2WAN_PORT   14

Function Documentation

◆ ketCube_lora_ConfirmClass()

static void ketCube_lora_ConfirmClass ( DeviceClass_t  Class)
static

◆ ketCube_lora_DataConfirm()

static void ketCube_lora_DataConfirm ( void  )
static

◆ ketCube_lora_HasJoined()

static void ketCube_lora_HasJoined ( void  )
static

◆ ketCube_lora_MacProcessNotify()

static void ketCube_lora_MacProcessNotify ( void  )
static

◆ ketCube_lora_RemoteTerminalSend()

ketCube_cfg_ModError_t ketCube_lora_RemoteTerminalSend ( uint8_t *  buffer,
uint8_t *  len 
)

Process lora state and prepare data for remote terminal sending.

◆ ketCube_lora_RxData()

static void ketCube_lora_RxData ( lora_AppData_t *  AppData)
static

LoRa Rx Data callback ...

◆ ketCube_lora_SendData()

static ketCube_cfg_ModError_t ketCube_lora_SendData ( lora_AppData_t *  AppData)
static

◆ ketCube_lora_TxNeeded()

static void ketCube_lora_TxNeeded ( void  )
static

Variable Documentation

◆ evntACKRx

volatile bool evntACKRx = FALSE
static

◆ evntClassSwitched

volatile bool evntClassSwitched = FALSE
static

◆ evntJoined

volatile bool evntJoined = FALSE
static

◆ evntTxNeeded

volatile bool evntTxNeeded = FALSE
static

◆ isJoined

volatile bool isJoined = FALSE
static

◆ ketCube_lora_rxData

ketCube_InterModMsg_t ketCube_lora_rxData

◆ ketCube_lora_rxDataBuff

uint8_t ketCube_lora_rxDataBuff[KETCUBE_LORA_RX_BUFFER_LEN]

◆ LoraMacProcessRequest

LoraFlagStatus LoraMacProcessRequest = LORA_RESET

◆ LoRaMainCallbacks

LoRaMainCallback_t LoRaMainCallbacks
static

◆ LoRaParamInit

LoRaParam_t LoRaParamInit
static
Initial value:
DR_0,
LORAWAN_PUBLIC_NETWORK}

Initialises the Lora Parameters

◆ modMsgQueue

ketCube_InterModMsg_t* modMsgQueue[2]
static
ketCube_batMeas_GetBatteryByte
uint8_t ketCube_batMeas_GetBatteryByte(void)
This function returns the battery level.
Definition: ketCube_batMeas.c:118
ketCube_MCU_GetUniqueId
void ketCube_MCU_GetUniqueId(uint8_t *id)
This function returns a unique MCU ID.
Definition: ketCube_mcu.c:104
ketCube_lora_MacProcessNotify
static void ketCube_lora_MacProcessNotify(void)
Definition: ketCube_lora.c:449
ketCube_lora_TxNeeded
static void ketCube_lora_TxNeeded(void)
Definition: ketCube_lora.c:477
ketCube_AD_GetTemperature
uint16_t ketCube_AD_GetTemperature(void)
ketCube_lora_HasJoined
static void ketCube_lora_HasJoined(void)
Definition: ketCube_lora.c:454
ketCube_MCU_GetRandomSeed
uint32_t ketCube_MCU_GetRandomSeed(void)
This function return a random seed.
Definition: ketCube_mcu.c:95
ketCube_lora_RxData
static void ketCube_lora_RxData(lora_AppData_t *AppData)
LoRa Rx Data callback ...
Definition: ketCube_lora.c:381
LORAWAN_ADR_ON
#define LORAWAN_ADR_ON
Definition: ketCube_lora.c:73
ketCube_lora_DataConfirm
static void ketCube_lora_DataConfirm(void)
Definition: ketCube_lora.c:488
ketCube_lora_ConfirmClass
static void ketCube_lora_ConfirmClass(DeviceClass_t Class)
Definition: ketCube_lora.c:464