Compare commits
38 Commits
706e6fb0d1
...
2019.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 32df3b9a2d | |||
| 764d42095c | |||
| cb1de9bc8c | |||
| 715d0ee1a8 | |||
| 3f92cc41a1 | |||
| 66a23299f3 | |||
| cf1c0d1737 | |||
| dcf7bcbf71 | |||
| e73b620ef4 | |||
| 1a6e219f3a | |||
| fca0241c2d | |||
| 8b930cc554 | |||
| 36dfb179dd | |||
| c9c6a3d003 | |||
| 70756dd33d | |||
| 596d6869c8 | |||
| 80dedb1490 | |||
| 2e3ad42102 | |||
| e71159cd35 | |||
| e93dc481e0 | |||
| 35a9f287ef | |||
| b5f75f9f18 | |||
| ed1c5c4337 | |||
| ff26a7aeb8 | |||
| 81ff742abe | |||
| 980aa93429 | |||
| e3638aea76 | |||
| e333e16041 | |||
| c2719666e0 | |||
| 6a5abe4b47 | |||
| 05d5ee476b | |||
| 240b2d795e | |||
| 094dd7f5b0 | |||
| 61d8025238 | |||
| a2c1bbffd4 | |||
| 765c47ba2a | |||
| 9629865668 | |||
| 2eecb2d02c |
@@ -0,0 +1,89 @@
|
|||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
# BasedOnStyle: LLVM
|
||||||
|
AccessModifierOffset: -2
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlinesLeft: true
|
||||||
|
AlignOperands: true
|
||||||
|
AlignTrailingComments: false
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: true
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: false
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
IndentBraces: false
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 100
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||||
|
Priority: 2
|
||||||
|
- Regex: '^(<|"(gtest|isl|json)/)'
|
||||||
|
Priority: 3
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 1
|
||||||
|
IncludeIsMainRegex: '$'
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: true
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: Inner
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
PointerAlignment: Left
|
||||||
|
ReflowComments: true
|
||||||
|
SortIncludes: false
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterTemplateKeyword: false
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeParens: Never
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInContainerLiterals: false
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Cpp11
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
+13
-1
@@ -1,4 +1,16 @@
|
|||||||
*.pyc
|
*.pyc
|
||||||
BUILD
|
BUILD
|
||||||
mbed_settings.py
|
|
||||||
mbed_config.h
|
mbed_config.h
|
||||||
|
|
||||||
|
mbed-os
|
||||||
|
Cayenne-LPP
|
||||||
|
mbed-lora-radio-drv
|
||||||
|
sensors/DHT
|
||||||
|
sensors/HX711
|
||||||
|
|
||||||
|
*.bin
|
||||||
|
devices.txt
|
||||||
|
|
||||||
|
# mbed vscode export generated files
|
||||||
|
GettingStarted.html
|
||||||
|
.vscode
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
mbed-os/features/netsocket/*
|
||||||
|
mbed-os/features/cellular/*
|
||||||
|
mbed-os/features/frameworks/greentea-client/*
|
||||||
|
mbed-os/features/frameworks/utest/*
|
||||||
|
mbed-os/features/frameworks/unity/*
|
||||||
|
mbed-os/features/nanostack/*
|
||||||
|
mbed-os/features/lwipstack/*
|
||||||
|
mbed-os/components/wifi/esp8266-driver/*
|
||||||
@@ -1,20 +1,51 @@
|
|||||||
# RAK811 Tracker Board mbed test
|
# WaveOfHoney - a lorawan beehive sensor
|
||||||
|
|
||||||
## Compilation
|
## Compilation
|
||||||
|
|
||||||
Clone this repository, then :
|
Clone this repository, then :
|
||||||
|
|
||||||
```
|
```sh
|
||||||
mbed deploy
|
mbed deploy
|
||||||
# modify lora.device-eui, lora.application-eui and lora.application-key in mbed_app.json
|
mbed config root .
|
||||||
mbed compile --profile mbed-os/tools/profiles/release.json
|
# set the desired compiler
|
||||||
|
mbed toolchain GCC_ARM
|
||||||
|
# set the desired board
|
||||||
|
mbed target NUCLEO_L073RZ
|
||||||
|
# set-up the compiler path if needed
|
||||||
|
mbed config -G GCC_ARM_PATH /opt/gcc-arm-none-eabi-7-2017-q4-major/bin
|
||||||
```
|
```
|
||||||
|
|
||||||
Then you can use stm32flash or may be better a stlink interface to copy the generated .bin file onto the RAK811.
|
### Bootstrap mode
|
||||||
|
|
||||||
|
This mode is used to initialize a mbed NVStore on the flash and store board-specific parameters.
|
||||||
|
To compile the bootstrap binary you have to set "mode-bootstrap" to true into mbed_app.json and set
|
||||||
|
lorawan EUIs and key.
|
||||||
|
|
||||||
|
```
|
||||||
|
mbed compile --profile profiles/release.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can use flash the board and start it. You can check the serial console to see reporting.
|
||||||
|
|
||||||
|
### Production mode
|
||||||
|
|
||||||
|
Just reset "mode-boostrap" to false and compile it (you can delete BUILD folder from previous compilation) :
|
||||||
|
|
||||||
|
```
|
||||||
|
mbed compile --profile profiles/release.json
|
||||||
|
```
|
||||||
|
|
||||||
|
In this mode, lorawan parameters are ignored (because the program get it from the flash) but
|
||||||
|
leave it as-is because they are used to determine the stored size ot the euis and key.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
### use STLink from a Nucleo board
|
### Tested boards
|
||||||
|
|
||||||
|
- MTB_RAK811
|
||||||
|
- NUCLEO_L073RZ + SX1272MB2xAS
|
||||||
|
|
||||||
|
### use STLink from a Nucleo board with the RAK811 board
|
||||||
|
|
||||||
From STlink CN4 Connector to RAK811 "shortest" connector (pin 1 at the same side of antenna connectors)
|
From STlink CN4 Connector to RAK811 "shortest" connector (pin 1 at the same side of antenna connectors)
|
||||||
|
|
||||||
@@ -24,3 +55,21 @@ From STlink CN4 Connector to RAK811 "shortest" connector (pin 1 at the same side
|
|||||||
4 -> 4 (DATA)
|
4 -> 4 (DATA)
|
||||||
5 -> 2 (RST)
|
5 -> 2 (RST)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### rewire STLink on a cutted Nucleo board
|
||||||
|
|
||||||
|
From STlink CN4 Connector to Nucleo CN7
|
||||||
|
|
||||||
|
```
|
||||||
|
2 -> 15 (CLK)
|
||||||
|
3 -> 19,20,22 (GND)
|
||||||
|
4 -> 13 (DATA)
|
||||||
|
5 -> 14 (RST)
|
||||||
|
```
|
||||||
|
|
||||||
|
From STLink CN3 Connector to Nucleo CN7 (stdio through USB)
|
||||||
|
|
||||||
|
```
|
||||||
|
rx -> 1 (USART4_TX)
|
||||||
|
tx -> 2 (USART4_RX)
|
||||||
|
```
|
||||||
+3
-11
@@ -20,10 +20,6 @@
|
|||||||
#ifndef APP_LORA_RADIO_HELPER_H_
|
#ifndef APP_LORA_RADIO_HELPER_H_
|
||||||
#define APP_LORA_RADIO_HELPER_H_
|
#define APP_LORA_RADIO_HELPER_H_
|
||||||
|
|
||||||
#if MBED_CONF_APP_LORAWAN_ENABLED
|
|
||||||
|
|
||||||
#ifdef DEVICE_SPI
|
|
||||||
|
|
||||||
#include "SX1272_LoRaRadio.h"
|
#include "SX1272_LoRaRadio.h"
|
||||||
#include "SX1276_LoRaRadio.h"
|
#include "SX1276_LoRaRadio.h"
|
||||||
|
|
||||||
@@ -32,7 +28,7 @@
|
|||||||
|
|
||||||
#if (MBED_CONF_APP_LORA_RADIO == SX1272)
|
#if (MBED_CONF_APP_LORA_RADIO == SX1272)
|
||||||
|
|
||||||
SX1272_LoRaRadio radio(MBED_CONF_APP_LORA_SPI_MOSI,
|
SX1272_LoRaRadio radio(MBED_CONF_APP_LORA_SPI_MOSI,
|
||||||
MBED_CONF_APP_LORA_SPI_MISO,
|
MBED_CONF_APP_LORA_SPI_MISO,
|
||||||
MBED_CONF_APP_LORA_SPI_SCLK,
|
MBED_CONF_APP_LORA_SPI_SCLK,
|
||||||
MBED_CONF_APP_LORA_CS,
|
MBED_CONF_APP_LORA_CS,
|
||||||
@@ -53,7 +49,7 @@
|
|||||||
|
|
||||||
#elif (MBED_CONF_APP_LORA_RADIO == SX1276)
|
#elif (MBED_CONF_APP_LORA_RADIO == SX1276)
|
||||||
|
|
||||||
SX1276_LoRaRadio radio(MBED_CONF_APP_LORA_SPI_MOSI,
|
SX1276_LoRaRadio radio(MBED_CONF_APP_LORA_SPI_MOSI,
|
||||||
MBED_CONF_APP_LORA_SPI_MISO,
|
MBED_CONF_APP_LORA_SPI_MISO,
|
||||||
MBED_CONF_APP_LORA_SPI_SCLK,
|
MBED_CONF_APP_LORA_SPI_SCLK,
|
||||||
MBED_CONF_APP_LORA_CS,
|
MBED_CONF_APP_LORA_CS,
|
||||||
@@ -73,11 +69,7 @@
|
|||||||
MBED_CONF_APP_LORA_TCXO);
|
MBED_CONF_APP_LORA_TCXO);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "Unknown LoRa radio specified (SX1272,SX1276 are valid)"
|
#error "Unknown LoRa radio specified (SX1272,SX1276 are valid)"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //DEVICE_SPI
|
|
||||||
|
|
||||||
#endif //MBED_CONF_APP_LORAWAN_ENABLED
|
|
||||||
|
|
||||||
#endif /* APP_LORA_RADIO_HELPER_H_ */
|
#endif /* APP_LORA_RADIO_HELPER_H_ */
|
||||||
@@ -1,84 +1,218 @@
|
|||||||
#include "mbed.h"
|
#include "CayenneLPP.h"
|
||||||
#include "lorawan/LoRaWANInterface.h"
|
|
||||||
#include "lorawan/system/lorawan_data_structures.h"
|
|
||||||
#include "events/EventQueue.h"
|
#include "events/EventQueue.h"
|
||||||
#include "lora_radio_helper.h"
|
#include "lora_radio_helper.h"
|
||||||
#include "CayenneLPP.h"
|
#include "lorawan/LoRaWANInterface.h"
|
||||||
|
#include "lorawan/system/lorawan_data_structures.h"
|
||||||
|
#include "mbed.h"
|
||||||
|
#include "nvstore.h"
|
||||||
|
|
||||||
|
#define NVKEY_LORA_DEVICE_EUI 0x01
|
||||||
|
#define NVKEY_LORA_APP_EUI 0x02
|
||||||
|
#define NVKEY_LORA_APP_KEY 0x03
|
||||||
|
#define NVKEY_HX711_OFFSET 0x04
|
||||||
|
#define NVKEY_HX711_SCALE 0x05
|
||||||
|
|
||||||
|
#if MBED_CONF_APP_MODE_BOOTSTRAP
|
||||||
|
|
||||||
|
const static uint8_t dev_eui[] = MBED_CONF_LORA_DEVICE_EUI;
|
||||||
|
const static uint8_t app_eui[] = MBED_CONF_LORA_APPLICATION_EUI;
|
||||||
|
const static uint8_t app_key[] = MBED_CONF_LORA_APPLICATION_KEY;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int rc;
|
||||||
|
uint16_t key;
|
||||||
|
|
||||||
|
NVStore &nvstore = NVStore::get_instance();
|
||||||
|
|
||||||
|
rc = nvstore.init();
|
||||||
|
if (rc != NVSTORE_SUCCESS) {
|
||||||
|
printf("Unable to init NVStore : %d\n", rc);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
rc = nvstore.reset();
|
||||||
|
if (rc != NVSTORE_SUCCESS) {
|
||||||
|
printf("Unable to reset NVStore : %d\n", rc);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("NVStore initiated and reseted\n");
|
||||||
|
|
||||||
|
key = NVKEY_LORA_DEVICE_EUI;
|
||||||
|
if (nvstore.set(key, sizeof(dev_eui), dev_eui) != NVSTORE_SUCCESS) {
|
||||||
|
printf("Unable to write LoRa Device EUI\n");
|
||||||
|
}
|
||||||
|
key = NVKEY_LORA_APP_EUI;
|
||||||
|
if (nvstore.set(key, sizeof(app_eui), app_eui) != NVSTORE_SUCCESS) {
|
||||||
|
printf("Unable to write LoRa Application EUI\n");
|
||||||
|
}
|
||||||
|
key = NVKEY_LORA_APP_KEY;
|
||||||
|
if (nvstore.set(key, sizeof(app_key), app_key) != NVSTORE_SUCCESS) {
|
||||||
|
printf("Unable to write LoRa Application key\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
printf("Bootstrap done\n");
|
||||||
|
wait(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // MBED_CONF_APP_MODE_BOOTSTRAP
|
||||||
|
|
||||||
|
static uint8_t dev_eui[] = MBED_CONF_LORA_DEVICE_EUI;
|
||||||
|
static uint8_t app_eui[] = MBED_CONF_LORA_APPLICATION_EUI;
|
||||||
|
static uint8_t app_key[] = MBED_CONF_LORA_APPLICATION_KEY;
|
||||||
|
|
||||||
|
#if MBED_CONF_APP_DHT_ENABLED
|
||||||
#include "DHT.h"
|
#include "DHT.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MBED_CONF_APP_HX711_ENABLED
|
||||||
|
#include "HX711.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace events;
|
using namespace events;
|
||||||
|
|
||||||
uint8_t rx_buffer[LORAMAC_PHY_MAXPAYLOAD];
|
uint8_t rx_buffer[LORAMAC_PHY_MAXPAYLOAD];
|
||||||
|
|
||||||
/*
|
|
||||||
* Sets up an application dependent transmission timer in ms. Used only when Duty Cycling is off for testing
|
|
||||||
*/
|
|
||||||
#define TX_TIMER 600000
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum number of events for the event queue.
|
* Maximum number of events for the event queue.
|
||||||
* 16 is the safe number for the stack events, however, if application
|
* 16 is the safe number for the stack events, however, if application
|
||||||
* also uses the queue for whatever purposes, this number should be increased.c
|
* also uses the queue for whatever purposes, this number should be increased.c
|
||||||
*/
|
*/
|
||||||
#define MAX_NUMBER_OF_EVENTS 16
|
#define MAX_NUMBER_OF_EVENTS 10
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum number of retries for CONFIRMED messages before giving up
|
* Maximum number of retries for CONFIRMED messages before giving up
|
||||||
*/
|
*/
|
||||||
#define CONFIRMED_MSG_RETRY_COUNTER 3
|
#define CONFIRMED_MSG_RETRY_COUNTER 3
|
||||||
|
|
||||||
static EventQueue ev_queue(MAX_NUMBER_OF_EVENTS * EVENTS_EVENT_SIZE);
|
static EventQueue ev_queue(MAX_NUMBER_OF_EVENTS* EVENTS_EVENT_SIZE);
|
||||||
static void lora_event_handler(lorawan_event_t event);
|
static void lora_event_handler(lorawan_event_t event);
|
||||||
static LoRaWANInterface lorawan(radio);
|
static LoRaWANInterface lorawan(radio);
|
||||||
static lorawan_app_callbacks_t callbacks;
|
static lorawan_app_callbacks_t callbacks;
|
||||||
static CayenneLPP cayenne(51);
|
static CayenneLPP cayenne(51);
|
||||||
DHT dht(PA_1, DHT::DHT22);
|
|
||||||
|
|
||||||
AnalogIn bat(PA_2);
|
#if MBED_CONF_APP_BATTERY_ENABLED
|
||||||
DigitalOut led(LED1);
|
AnalogIn bat(MBED_CONF_APP_BATTERY_ADC);
|
||||||
|
AnalogIn vref(ADC_VREF);
|
||||||
|
|
||||||
|
static float battery_voltage() {
|
||||||
|
float vbat = bat.read();
|
||||||
|
float vrefin = vref.read();
|
||||||
|
|
||||||
|
float vrefcal = (float)(*(uint16_t*)VREFINT_CAL_ADDR) * (1.0f / (float)0xFFF);
|
||||||
|
float vdda = 3.0f * vrefcal / vrefin;
|
||||||
|
|
||||||
|
return vbat * vdda * MBED_CONF_APP_BATTERY_RATIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t battery_level() {
|
||||||
|
float vbat = battery_voltage();
|
||||||
|
|
||||||
|
if (vbat >= MBED_CONF_APP_BATTERY_MAX) {
|
||||||
|
return 254;
|
||||||
|
} else if (vbat > MBED_CONF_APP_BATTERY_MIN && vbat < MBED_CONF_APP_BATTERY_MAX) {
|
||||||
|
return ( 253 * ( vbat - MBED_CONF_APP_BATTERY_MIN ) ) / ( MBED_CONF_APP_BATTERY_MAX - MBED_CONF_APP_BATTERY_MIN ) + 1;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MBED_CONF_APP_DHT_ENABLED
|
||||||
|
DHT dht(MBED_CONF_APP_DHT_DATA, MBED_CONF_APP_DHT_TYPE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MBED_CONF_APP_HX711_ENABLED
|
||||||
|
HX711 loadcell(MBED_CONF_APP_HX711_DATA, MBED_CONF_APP_HX711_CLK);
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|
||||||
lorawan_status_t retcode;
|
lorawan_status_t retcode;
|
||||||
// Initialize LoRaWAN stack
|
lorawan_connect_t connect;
|
||||||
if (lorawan.initialize(&ev_queue) != LORAWAN_STATUS_OK) {
|
int rc;
|
||||||
printf("\r\n LoRa initialization failed! \r\n");
|
uint16_t key;
|
||||||
|
uint16_t readsize;
|
||||||
|
|
||||||
|
// NVStore is a sigleton, get its instance
|
||||||
|
NVStore &nvstore = NVStore::get_instance();
|
||||||
|
|
||||||
|
if (nvstore.init() != NVSTORE_SUCCESS) {
|
||||||
|
debug("\r\n NVStore initialization failed! \r\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\r\n Mbed LoRaWANStack initialized \r\n");
|
key = NVKEY_LORA_DEVICE_EUI;
|
||||||
|
rc = nvstore.get(key, sizeof(dev_eui), dev_eui, readsize);
|
||||||
|
if (rc != NVSTORE_SUCCESS || readsize != sizeof(dev_eui)) {
|
||||||
|
debug("\r\n Failed to read LoRa Device EUI from NVStore! \r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
key = NVKEY_LORA_APP_EUI;
|
||||||
|
rc = nvstore.get(key, sizeof(app_eui), app_eui, readsize);
|
||||||
|
if (rc != NVSTORE_SUCCESS || readsize != sizeof(app_eui)) {
|
||||||
|
debug("\r\n Failed to read LoRa Application EUI from NVStore! \r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
key = NVKEY_LORA_APP_KEY;
|
||||||
|
rc =nvstore.get(key, sizeof(app_key), app_key, readsize);
|
||||||
|
if (rc != NVSTORE_SUCCESS || readsize != sizeof(app_key)) {
|
||||||
|
debug("\r\n Failed to read LoRa Application Key from NVStore! \r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
connect.connect_type = LORAWAN_CONNECTION_OTAA;
|
||||||
|
connect.connection_u.otaa.app_eui = const_cast<uint8_t *>(app_eui);
|
||||||
|
connect.connection_u.otaa.dev_eui = const_cast<uint8_t *>(dev_eui);
|
||||||
|
connect.connection_u.otaa.app_key = const_cast<uint8_t *>(app_key);
|
||||||
|
connect.connection_u.otaa.nb_trials = MBED_CONF_LORA_NB_TRIALS;
|
||||||
|
|
||||||
|
#if MBED_CONF_APP_HX711_ENABLED
|
||||||
|
loadcell.powerDown();
|
||||||
|
loadcell.setScale(MBED_CONF_APP_HX711_SCALE);
|
||||||
|
loadcell.setOffset(MBED_CONF_APP_HX711_OFFSET);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Initialize LoRaWAN stack
|
||||||
|
if(lorawan.initialize(&ev_queue) != LORAWAN_STATUS_OK) {
|
||||||
|
debug("\r\n LoRa initialization failed! \r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("\r\n Mbed LoRaWANStack initialized \r\n");
|
||||||
|
|
||||||
callbacks.events = mbed::callback(lora_event_handler);
|
callbacks.events = mbed::callback(lora_event_handler);
|
||||||
|
#if MBED_CONF_APP_BATTERY_ENABLED
|
||||||
|
callbacks.battery_level = mbed::callback(battery_level);
|
||||||
|
#endif
|
||||||
lorawan.add_app_callbacks(&callbacks);
|
lorawan.add_app_callbacks(&callbacks);
|
||||||
|
|
||||||
// Set number of retries in case of CONFIRMED messages
|
// Set number of retries in case of CONFIRMED messages
|
||||||
if (lorawan.set_confirmed_msg_retries(CONFIRMED_MSG_RETRY_COUNTER)
|
if(lorawan.set_confirmed_msg_retries(CONFIRMED_MSG_RETRY_COUNTER) != LORAWAN_STATUS_OK) {
|
||||||
!= LORAWAN_STATUS_OK) {
|
debug("\r\n set_confirmed_msg_retries failed! \r\n\r\n");
|
||||||
printf("\r\n set_confirmed_msg_retries failed! \r\n\r\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\r\n CONFIRMED message retries : %d \r\n",
|
debug("\r\n CONFIRMED message retries : %d \r\n", CONFIRMED_MSG_RETRY_COUNTER);
|
||||||
CONFIRMED_MSG_RETRY_COUNTER);
|
|
||||||
|
|
||||||
// Enable adaptive data rate
|
// Enable adaptive data rate
|
||||||
if (lorawan.enable_adaptive_datarate() != LORAWAN_STATUS_OK) {
|
if(lorawan.enable_adaptive_datarate() != LORAWAN_STATUS_OK) {
|
||||||
printf("\r\n enable_adaptive_datarate failed! \r\n");
|
debug("\r\n enable_adaptive_datarate failed! \r\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\r\n Adaptive data rate (ADR) - Enabled \r\n");
|
debug("\r\n Adaptive data rate (ADR) - Enabled \r\n");
|
||||||
|
|
||||||
retcode = lorawan.connect();
|
retcode = lorawan.connect(connect);
|
||||||
|
|
||||||
if (retcode == LORAWAN_STATUS_OK ||
|
if(retcode == LORAWAN_STATUS_OK || retcode == LORAWAN_STATUS_CONNECT_IN_PROGRESS) {
|
||||||
retcode == LORAWAN_STATUS_CONNECT_IN_PROGRESS) {
|
|
||||||
} else {
|
} else {
|
||||||
printf("\r\n Connection error, code = %d \r\n", retcode);
|
debug("\r\n Connection error, code = %d \r\n", retcode);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\r\n Connection - In Progress ...\r\n");
|
debug("\r\n Connection - In Progress ...\r\n");
|
||||||
|
|
||||||
// make your event queue dispatching events forever
|
// make your event queue dispatching events forever
|
||||||
ev_queue.dispatch_forever();
|
ev_queue.dispatch_forever();
|
||||||
@@ -89,107 +223,124 @@ int main(void) {
|
|||||||
/**
|
/**
|
||||||
* Sends a message to the Network Server
|
* Sends a message to the Network Server
|
||||||
*/
|
*/
|
||||||
static void send_message()
|
static void send_message() {
|
||||||
{
|
|
||||||
int16_t retcode;
|
int16_t retcode;
|
||||||
|
int eid;
|
||||||
|
|
||||||
// vbat
|
// setup next transmission
|
||||||
float vbat = bat.read();
|
eid = ev_queue.call_in(MBED_CONF_APP_TX_TIMER, send_message);
|
||||||
vbat = vbat*5/3*3.3f;
|
|
||||||
cayenne.addAnalogInput(1, vbat);
|
|
||||||
|
|
||||||
// dht
|
// check backoff time before sending new frame
|
||||||
|
if (MBED_CONF_LORA_DUTY_CYCLE_ON) {
|
||||||
|
lorawan_status_t status;
|
||||||
|
int backoff;
|
||||||
|
|
||||||
|
status = lorawan.get_backoff_metadata(backoff);
|
||||||
|
if (status == LORAWAN_STATUS_OK && backoff > 0) {
|
||||||
|
debug("\r\n %d ms backoff, delay next send \r\n", backoff);
|
||||||
|
ev_queue.cancel(eid);
|
||||||
|
ev_queue.call_in(backoff+MBED_CONF_APP_TX_TIMER, send_message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if MBED_CONF_APP_DHT_ENABLED
|
||||||
int err = dht.read();
|
int err = dht.read();
|
||||||
if (err == DHT::SUCCESS) {
|
if(err == DHT::SUCCESS) {
|
||||||
cayenne.addTemperature(1, dht.getTemperature());
|
cayenne.addTemperature(MBED_CONF_APP_DHT_TEMP_LPP_ID, dht.getTemperature());
|
||||||
cayenne.addRelativeHumidity(2, dht.getHumidity());
|
cayenne.addRelativeHumidity(MBED_CONF_APP_DHT_HUM_LPP_ID, dht.getHumidity());
|
||||||
} else {
|
} else {
|
||||||
printf("Error code : %d\r\n", err);
|
debug("Error code : %d\r\n", err);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MBED_CONF_APP_HX711_ENABLED
|
||||||
|
loadcell.powerUp();
|
||||||
|
if(loadcell.waitReadyRetry(20, 100)) {
|
||||||
|
cayenne.addAnalogInput(MBED_CONF_APP_HX711_LPP_ID, loadcell.getUnits(5));
|
||||||
|
}
|
||||||
|
loadcell.powerDown();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MBED_CONF_APP_BATTERY_ENABLED && MBED_CONF_APP_BATTERY_IN_LPP
|
||||||
|
cayenne.addAnalogInput(MBED_CONF_APP_BATTERY_LPP_ID, battery_voltage());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// No data to send
|
||||||
|
if(cayenne.getSize() == 0) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, cayenne.getBuffer(), cayenne.getSize(),
|
retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, cayenne.getBuffer(), cayenne.getSize(),
|
||||||
MSG_UNCONFIRMED_FLAG);
|
MSG_UNCONFIRMED_FLAG);
|
||||||
|
|
||||||
if (retcode < 0) {
|
if(retcode < 0) {
|
||||||
retcode == LORAWAN_STATUS_WOULD_BLOCK ? printf("send - WOULD BLOCK\r\n")
|
retcode == LORAWAN_STATUS_WOULD_BLOCK ? debug("send - WOULD BLOCK\r\n")
|
||||||
: printf("\r\n send() - Error code %d \r\n", retcode);
|
: debug("\r\n send() - Error code %d \r\n", retcode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\r\n %d bytes scheduled for transmission \r\n", retcode);
|
debug("\r\n %d bytes scheduled for transmission \r\n", retcode);
|
||||||
cayenne.reset();
|
cayenne.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receive a message from the Network Server
|
* Receive a message from the Network Server
|
||||||
*/
|
*/
|
||||||
static void receive_message()
|
static void receive_message() {
|
||||||
{
|
|
||||||
int16_t retcode;
|
int16_t retcode;
|
||||||
retcode = lorawan.receive(MBED_CONF_LORA_APP_PORT, rx_buffer,
|
retcode = lorawan.receive(MBED_CONF_LORA_APP_PORT, rx_buffer, LORAMAC_PHY_MAXPAYLOAD,
|
||||||
LORAMAC_PHY_MAXPAYLOAD,
|
MSG_CONFIRMED_FLAG | MSG_UNCONFIRMED_FLAG);
|
||||||
MSG_CONFIRMED_FLAG|MSG_UNCONFIRMED_FLAG);
|
|
||||||
|
|
||||||
if (retcode < 0) {
|
if(retcode < 0) {
|
||||||
printf("\r\n receive() - Error code %d \r\n", retcode);
|
debug("\r\n receive() - Error code %d \r\n", retcode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" Data:");
|
debug(" Data:");
|
||||||
|
|
||||||
for (uint8_t i = 0; i < retcode; i++) {
|
for(uint8_t i = 0; i < retcode; i++) {
|
||||||
printf("%x", rx_buffer[i]);
|
debug("%x", rx_buffer[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\r\n Data Length: %d\r\n", retcode);
|
debug("\r\n Data Length: %d\r\n", retcode);
|
||||||
|
|
||||||
memset(rx_buffer, 0, LORAMAC_PHY_MAXPAYLOAD);
|
memset(rx_buffer, 0, LORAMAC_PHY_MAXPAYLOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lora_event_handler(lorawan_event_t event)
|
static void lora_event_handler(lorawan_event_t event) {
|
||||||
{
|
switch(event) {
|
||||||
switch (event) {
|
|
||||||
case CONNECTED:
|
case CONNECTED:
|
||||||
printf("\r\n Connection - Successful \r\n");
|
debug("\r\n Connection - Successful \r\n");
|
||||||
if (MBED_CONF_LORA_DUTY_CYCLE_ON) {
|
|
||||||
send_message();
|
send_message();
|
||||||
} else {
|
|
||||||
ev_queue.call_every(TX_TIMER, send_message);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DISCONNECTED:
|
case DISCONNECTED:
|
||||||
ev_queue.break_dispatch();
|
ev_queue.break_dispatch();
|
||||||
printf("\r\n Disconnected Successfully \r\n");
|
debug("\r\n Disconnected Successfully \r\n");
|
||||||
break;
|
break;
|
||||||
case TX_DONE:
|
case TX_DONE:
|
||||||
printf("\r\n Message Sent to Network Server \r\n");
|
debug("\r\n Message Sent to Network Server \r\n");
|
||||||
if (MBED_CONF_LORA_DUTY_CYCLE_ON) {
|
|
||||||
send_message();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case TX_TIMEOUT:
|
case TX_TIMEOUT:
|
||||||
case TX_ERROR:
|
case TX_ERROR:
|
||||||
case TX_CRYPTO_ERROR:
|
case TX_CRYPTO_ERROR:
|
||||||
case TX_SCHEDULING_ERROR:
|
case TX_SCHEDULING_ERROR:
|
||||||
printf("\r\n Transmission Error - EventCode = %d \r\n", event);
|
debug("\r\n Transmission Error - EventCode = %d \r\n", event);
|
||||||
// try again
|
|
||||||
if (MBED_CONF_LORA_DUTY_CYCLE_ON) {
|
|
||||||
send_message();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case RX_DONE:
|
case RX_DONE:
|
||||||
printf("\r\n Received message from Network Server \r\n");
|
debug("\r\n Received message from Network Server \r\n");
|
||||||
receive_message();
|
receive_message();
|
||||||
break;
|
break;
|
||||||
case RX_TIMEOUT:
|
case RX_TIMEOUT:
|
||||||
case RX_ERROR:
|
case RX_ERROR:
|
||||||
printf("\r\n Error in reception - Code = %d \r\n", event);
|
debug("\r\n Error in reception - Code = %d \r\n", event);
|
||||||
break;
|
break;
|
||||||
case JOIN_FAILURE:
|
case JOIN_FAILURE:
|
||||||
printf("\r\n OTAA Failed - Check Keys \r\n");
|
debug("\r\n OTAA Failed - Check Keys \r\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
MBED_ASSERT("Unknown Event");
|
MBED_ASSERT("Unknown Event");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // MBED_APP_MODE_BOOTSTRAP
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
https://github.com/ARMmbed/mbed-semtech-lora-rf-drivers/#16958f814d505cfbbedfa16d9bf8b9dff0e0442b
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
https://github.com/ARMmbed/mbed-os/#367dbdf5145f4d6aa3e483c147fe7bda1ce23a36
|
https://github.com/ARMmbed/mbed-os/#51d55508e8400b60af467005646c4e2164738d48
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
https://github.com/ARMmbed/mbed-semtech-lora-rf-drivers/#c5ee52293fee29aea3479d20e92ca2c1fc1ddaff
|
|
||||||
+55
-185
@@ -1,13 +1,12 @@
|
|||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
|
"mode-bootstrap": { "value": false },
|
||||||
|
"tx-timer": { "value": 600000 },
|
||||||
"lora-radio": {
|
"lora-radio": {
|
||||||
"help": "Which radio to use (options: SX1272,SX1276)",
|
"help": "Which radio to use (options: SX1272,SX1276)",
|
||||||
"value": "SX1276"
|
"value": "SX1276"
|
||||||
},
|
},
|
||||||
"main_stack_size": { "value": 4096 },
|
"main_stack_size": { "value": 4096 },
|
||||||
|
|
||||||
"lorawan-enabled": { "value": false},
|
|
||||||
|
|
||||||
"lora-spi-mosi": { "value": "NC" },
|
"lora-spi-mosi": { "value": "NC" },
|
||||||
"lora-spi-miso": { "value": "NC" },
|
"lora-spi-miso": { "value": "NC" },
|
||||||
"lora-spi-sclk": { "value": "NC" },
|
"lora-spi-sclk": { "value": "NC" },
|
||||||
@@ -25,22 +24,47 @@
|
|||||||
"lora-rxctl": { "value": "NC" },
|
"lora-rxctl": { "value": "NC" },
|
||||||
"lora-ant-switch": { "value": "NC" },
|
"lora-ant-switch": { "value": "NC" },
|
||||||
"lora-pwr-amp-ctl": { "value": "NC" },
|
"lora-pwr-amp-ctl": { "value": "NC" },
|
||||||
"lora-tcxo": { "value": "NC" }
|
"lora-tcxo": { "value": "NC" },
|
||||||
|
"battery-enabled": { "value": false },
|
||||||
|
"battery-lpp-id": { "value": 1 },
|
||||||
|
"battery-in-lpp": { "value": false },
|
||||||
|
"battery-adc": { "value": "NC" },
|
||||||
|
"battery-min": { "value": "3.20f" },
|
||||||
|
"battery-max": { "value": "4.15f" },
|
||||||
|
"battery-ratio": { "value": "2.0f" },
|
||||||
|
"hx711-enabled": { "value": false },
|
||||||
|
"hx711-lpp-id": { "value": 2 },
|
||||||
|
"hx711-clk": { "value": "NC" },
|
||||||
|
"hx711-data": { "value": "NC" },
|
||||||
|
"hx711-scale": { "value": "1.0f" },
|
||||||
|
"hx711-offset": { "value": 0 },
|
||||||
|
"dht-enabled": { "value": false },
|
||||||
|
"dht-temp-lpp-id": { "value": 3 },
|
||||||
|
"dht-hum-lpp-id": { "value": 4 },
|
||||||
|
"dht-type": { "value": "DHT::DHT22" },
|
||||||
|
"dht-data": { "value": "NC" }
|
||||||
},
|
},
|
||||||
"target_overrides": {
|
"target_overrides": {
|
||||||
"*": {
|
"*": {
|
||||||
|
"mode-bootstrap": false,
|
||||||
|
"tx-timer": 600000,
|
||||||
|
"platform.stdio-convert-newlines": true,
|
||||||
|
"platform.stdio-baud-rate": 115200,
|
||||||
|
"platform.default-serial-baud-rate": 115200,
|
||||||
"lora.app-port": 3,
|
"lora.app-port": 3,
|
||||||
"lora.over-the-air-activation": true,
|
"lora.duty-cycle-on": true,
|
||||||
"lora.duty-cycle-on": false,
|
|
||||||
"lora.phy": 0,
|
"lora.phy": 0,
|
||||||
"lora.device-eui": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }",
|
"lora.device-eui": "{ 0xAB, 0xBA, 0xAB, 0xBA, 0xAB, 0xBA, 0xAB, 0xBA }",
|
||||||
"lora.application-eui": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }",
|
"lora.application-eui": "{ 0xAC, 0xCA, 0xAC, 0xCA, 0xAC, 0xCA, 0xAC, 0xCA }",
|
||||||
"lora.application-key": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }"
|
"lora.application-key": "{ 0xAD, 0xDA, 0xAD, 0xDA, 0xAD, 0xDA, 0xAD, 0xDA, 0xAD, 0xDA, 0xAD, 0xDA, 0xAD, 0xDA, 0xAD, 0xDA }"
|
||||||
},
|
},
|
||||||
|
|
||||||
"K64F": {
|
"NUCLEO_L073RZ": {
|
||||||
"lorawan-enabled": true,
|
"main_stack_size": 1024,
|
||||||
|
"target.lpticker_lptim": 0,
|
||||||
|
"target.clock_source": "USE_PLL_HSI",
|
||||||
|
"sx1272-lora-driver.radio-variant": "SX1272MB2XAS",
|
||||||
|
"lora-radio": "SX1272",
|
||||||
"lora-spi-mosi": "D11",
|
"lora-spi-mosi": "D11",
|
||||||
"lora-spi-miso": "D12",
|
"lora-spi-miso": "D12",
|
||||||
"lora-spi-sclk": "D13",
|
"lora-spi-sclk": "D13",
|
||||||
@@ -50,189 +74,30 @@
|
|||||||
"lora-dio1": "D3",
|
"lora-dio1": "D3",
|
||||||
"lora-dio2": "D4",
|
"lora-dio2": "D4",
|
||||||
"lora-dio3": "D5",
|
"lora-dio3": "D5",
|
||||||
"lora-dio4": "D8",
|
|
||||||
"lora-dio5": "D9",
|
|
||||||
"lora-rf-switch-ctl1": "NC",
|
|
||||||
"lora-rf-switch-ctl2": "NC",
|
|
||||||
"lora-txctl": "NC",
|
|
||||||
"lora-rxctl": "NC",
|
|
||||||
"lora-ant-switch": "A4",
|
|
||||||
"lora-pwr-amp-ctl": "NC",
|
|
||||||
"lora-tcxo": "NC"
|
|
||||||
},
|
|
||||||
|
|
||||||
"DISCO_L072CZ_LRWAN1": {
|
|
||||||
"main_stack_size": 3072,
|
|
||||||
"lorawan-enabled": true,
|
|
||||||
|
|
||||||
"lora-radio": "SX1276",
|
|
||||||
"lora-spi-mosi": "PA_7",
|
|
||||||
"lora-spi-miso": "PA_6",
|
|
||||||
"lora-spi-sclk": "PB_3",
|
|
||||||
"lora-cs": "PA_15",
|
|
||||||
"lora-reset": "PC_0",
|
|
||||||
"lora-dio0": "PB_4",
|
|
||||||
"lora-dio1": "PB_1",
|
|
||||||
"lora-dio2": "PB_0",
|
|
||||||
"lora-dio3": "PC_13",
|
|
||||||
"lora-dio4": "NC",
|
"lora-dio4": "NC",
|
||||||
"lora-dio5": "NC",
|
"lora-dio5": "NC",
|
||||||
"lora-rf-switch-ctl1": "NC",
|
"lora-rf-switch-ctl1": "NC",
|
||||||
"lora-rf-switch-ctl2": "NC",
|
"lora-rf-switch-ctl2": "NC",
|
||||||
"lora-txctl": "PC_2",
|
|
||||||
"lora-rxctl": "PA_1",
|
|
||||||
"lora-ant-switch": "NC",
|
|
||||||
"lora-pwr-amp-ctl": "PC_1",
|
|
||||||
"lora-tcxo": "PA_12"
|
|
||||||
},
|
|
||||||
|
|
||||||
"MTB_MURATA_ABZ": {
|
|
||||||
"lorawan-enabled": true,
|
|
||||||
|
|
||||||
"lora-radio": "SX1276",
|
|
||||||
"lora-spi-mosi": "PA_7",
|
|
||||||
"lora-spi-miso": "PA_6",
|
|
||||||
"lora-spi-sclk": "PB_3",
|
|
||||||
"lora-cs": "PA_15",
|
|
||||||
"lora-reset": "PC_0",
|
|
||||||
"lora-dio0": "PB_4",
|
|
||||||
"lora-dio1": "PB_1",
|
|
||||||
"lora-dio2": "PB_0",
|
|
||||||
"lora-dio3": "PC_13",
|
|
||||||
"lora-dio4": "NC",
|
|
||||||
"lora-dio5": "NC",
|
|
||||||
"lora-rf-switch-ctl1": "NC",
|
|
||||||
"lora-rf-switch-ctl2": "NC",
|
|
||||||
"lora-txctl": "PC_2",
|
|
||||||
"lora-rxctl": "PA_1",
|
|
||||||
"lora-ant-switch": "NC",
|
|
||||||
"lora-pwr-amp-ctl": "PC_1",
|
|
||||||
"lora-tcxo": "PA_12"
|
|
||||||
},
|
|
||||||
|
|
||||||
"XDOT_L151CC": {
|
|
||||||
"lorawan-enabled": true,
|
|
||||||
|
|
||||||
"lora-radio": "SX1272",
|
|
||||||
"lora-spi-mosi": "LORA_MOSI",
|
|
||||||
"lora-spi-miso": "LORA_MISO",
|
|
||||||
"lora-spi-sclk": "LORA_SCK",
|
|
||||||
"lora-cs": "LORA_NSS",
|
|
||||||
"lora-reset": "LORA_RESET",
|
|
||||||
"lora-dio0": "LORA_DIO0",
|
|
||||||
"lora-dio1": "LORA_DIO1",
|
|
||||||
"lora-dio2": "LORA_DIO2",
|
|
||||||
"lora-dio3": "LORA_DIO3",
|
|
||||||
"lora-dio4": "LORA_DIO4",
|
|
||||||
"lora-dio5": "NC",
|
|
||||||
"lora-rf-switch-ctl1": "NC",
|
|
||||||
"lora-rf-switch-ctl2": "NC",
|
|
||||||
"lora-txctl": "NC",
|
"lora-txctl": "NC",
|
||||||
"lora-rxctl": "NC",
|
"lora-rxctl": "NC",
|
||||||
"lora-ant-switch": "NC",
|
"lora-ant-switch": "NC",
|
||||||
"lora-pwr-amp-ctl": "NC",
|
"lora-pwr-amp-ctl": "NC",
|
||||||
"lora-tcxo": "NC"
|
"lora-tcxo": "NC",
|
||||||
},
|
"battery-enabled": true,
|
||||||
|
"battery-in-lpp": true,
|
||||||
"MTB_MTS_XDOT": {
|
"battery-adc": "A1",
|
||||||
"lorawan-enabled": true,
|
"battery-ratio": "2.0f",
|
||||||
|
"hx711-enabled": true,
|
||||||
"lora-radio": "SX1272",
|
"hx711-clk": "D6",
|
||||||
"lora-spi-mosi": "LORA_MOSI",
|
"hx711-data": "D7",
|
||||||
"lora-spi-miso": "LORA_MISO",
|
"hx711-scale": "21000.0f",
|
||||||
"lora-spi-sclk": "LORA_SCK",
|
"hx711-offset": 59600,
|
||||||
"lora-cs": "LORA_NSS",
|
"dht-enabled": true,
|
||||||
"lora-reset": "LORA_RESET",
|
"dht-data": "D8",
|
||||||
"lora-dio0": "LORA_DIO0",
|
"dht-type": "DHT::DHT22"
|
||||||
"lora-dio1": "LORA_DIO1",
|
|
||||||
"lora-dio2": "LORA_DIO2",
|
|
||||||
"lora-dio3": "LORA_DIO3",
|
|
||||||
"lora-dio4": "LORA_DIO4",
|
|
||||||
"lora-dio5": "NC",
|
|
||||||
"lora-rf-switch-ctl1": "NC",
|
|
||||||
"lora-rf-switch-ctl2": "NC",
|
|
||||||
"lora-txctl": "NC",
|
|
||||||
"lora-rxctl": "NC",
|
|
||||||
"lora-ant-switch": "NC",
|
|
||||||
"lora-pwr-amp-ctl": "NC",
|
|
||||||
"lora-tcxo": "NC"
|
|
||||||
},
|
|
||||||
|
|
||||||
"LTEK_FF1705": {
|
|
||||||
"lorawan-enabled": true,
|
|
||||||
|
|
||||||
"lora-radio": "SX1272",
|
|
||||||
"lora-spi-mosi": "LORA_MOSI",
|
|
||||||
"lora-spi-miso": "LORA_MISO",
|
|
||||||
"lora-spi-sclk": "LORA_SCK",
|
|
||||||
"lora-cs": "LORA_NSS",
|
|
||||||
"lora-reset": "LORA_RESET",
|
|
||||||
"lora-dio0": "LORA_DIO0",
|
|
||||||
"lora-dio1": "LORA_DIO1",
|
|
||||||
"lora-dio2": "LORA_DIO2",
|
|
||||||
"lora-dio3": "LORA_DIO3",
|
|
||||||
"lora-dio4": "LORA_DIO4",
|
|
||||||
"lora-dio5": "NC",
|
|
||||||
"lora-rf-switch-ctl1": "NC",
|
|
||||||
"lora-rf-switch-ctl2": "NC",
|
|
||||||
"lora-txctl": "NC",
|
|
||||||
"lora-rxctl": "NC",
|
|
||||||
"lora-ant-switch": "NC",
|
|
||||||
"lora-pwr-amp-ctl": "NC",
|
|
||||||
"lora-tcxo": "NC"
|
|
||||||
},
|
|
||||||
|
|
||||||
"MTS_MDOT_F411RE": {
|
|
||||||
"lorawan-enabled": true,
|
|
||||||
|
|
||||||
"lora-radio": "SX1272",
|
|
||||||
"lora-spi-mosi": "LORA_MOSI",
|
|
||||||
"lora-spi-miso": "LORA_MISO",
|
|
||||||
"lora-spi-sclk": "LORA_SCK",
|
|
||||||
"lora-cs": "LORA_NSS",
|
|
||||||
"lora-reset": "LORA_RESET",
|
|
||||||
"lora-dio0": "LORA_DIO0",
|
|
||||||
"lora-dio1": "LORA_DIO1",
|
|
||||||
"lora-dio2": "LORA_DIO2",
|
|
||||||
"lora-dio3": "LORA_DIO3",
|
|
||||||
"lora-dio4": "LORA_DIO4",
|
|
||||||
"lora-dio5": "LORA_DIO5",
|
|
||||||
"lora-rf-switch-ctl1": "NC",
|
|
||||||
"lora-rf-switch-ctl2": "NC",
|
|
||||||
"lora-txctl": "LORA_TXCTL",
|
|
||||||
"lora-rxctl": "LORA_RXCTL",
|
|
||||||
"lora-ant-switch": "NC",
|
|
||||||
"lora-pwr-amp-ctl": "NC",
|
|
||||||
"lora-tcxo": "NC"
|
|
||||||
},
|
|
||||||
|
|
||||||
"MTB_ADV_WISE_1510": {
|
|
||||||
"lorawan-enabled": true,
|
|
||||||
|
|
||||||
"lora-radio": "SX1276",
|
|
||||||
"lora-spi-mosi": "SPI_RF_MOSI",
|
|
||||||
"lora-spi-miso": "SPI_RF_MISO",
|
|
||||||
"lora-spi-sclk": "SPI_RF_SCK",
|
|
||||||
"lora-cs": "SPI_RF_CS",
|
|
||||||
"lora-reset": "SPI_RF_RESET",
|
|
||||||
"lora-dio0": "DIO0",
|
|
||||||
"lora-dio1": "DIO1",
|
|
||||||
"lora-dio2": "DIO2",
|
|
||||||
"lora-dio3": "DIO3",
|
|
||||||
"lora-dio4": "DIO4",
|
|
||||||
"lora-dio5": "DIO5",
|
|
||||||
"lora-rf-switch-ctl1": "NC",
|
|
||||||
"lora-rf-switch-ctl2": "NC",
|
|
||||||
"lora-txctl": "NC",
|
|
||||||
"lora-rxctl": "NC",
|
|
||||||
"lora-ant-switch": "ANT_SWITCH",
|
|
||||||
"lora-pwr-amp-ctl": "NC",
|
|
||||||
"lora-tcxo": "NC"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"MTB_RAK811": {
|
"MTB_RAK811": {
|
||||||
"lorawan-enabled": true,
|
|
||||||
|
|
||||||
"lora-radio": "SX1276",
|
"lora-radio": "SX1276",
|
||||||
"lora-spi-mosi": "SPI_RF_MOSI",
|
"lora-spi-mosi": "SPI_RF_MOSI",
|
||||||
"lora-spi-miso": "SPI_RF_MISO",
|
"lora-spi-miso": "SPI_RF_MISO",
|
||||||
@@ -251,7 +116,12 @@
|
|||||||
"lora-rxctl": "ANT_CRX_RX",
|
"lora-rxctl": "ANT_CRX_RX",
|
||||||
"lora-ant-switch": "NC",
|
"lora-ant-switch": "NC",
|
||||||
"lora-pwr-amp-ctl": "NC",
|
"lora-pwr-amp-ctl": "NC",
|
||||||
"lora-tcxo": "RF_TCXO_EN"
|
"lora-tcxo": "RF_TCXO_EN",
|
||||||
|
"battery-enabled": true,
|
||||||
|
"battery-adc": "PA_2",
|
||||||
|
"dht-enabled": true,
|
||||||
|
"dht-data": "PA_1",
|
||||||
|
"dht-type": "DHT::DHT22"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_lora_config.h\""]
|
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_lora_config.h\""]
|
||||||
|
|||||||
+19
-2671
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"GCC_ARM": {
|
||||||
|
"common": ["-c", "-Wall", "-Wextra",
|
||||||
|
"-Wno-unused-parameter", "-Wno-missing-field-initializers",
|
||||||
|
"-fmessage-length=0", "-fno-exceptions", "-fno-builtin",
|
||||||
|
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
|
||||||
|
"-MMD", "-fno-delete-null-pointer-checks",
|
||||||
|
"-fomit-frame-pointer", "-Os", "-DNDEBUG", "-g1"],
|
||||||
|
"asm": ["-x", "assembler-with-cpp"],
|
||||||
|
"c": ["-std=gnu99"],
|
||||||
|
"cxx": ["-std=gnu++98", "-fno-rtti", "-Wvla"],
|
||||||
|
"ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r",
|
||||||
|
"-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_memalign_r",
|
||||||
|
"-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit",
|
||||||
|
"-Wl,-n", "--specs=nano.specs", "-u _printf_float"]
|
||||||
|
},
|
||||||
|
"ARMC6": {
|
||||||
|
"common": ["-c", "--target=arm-arm-none-eabi", "-mthumb", "-Oz",
|
||||||
|
"-Wno-armcc-pragma-push-pop", "-Wno-armcc-pragma-anon-unions",
|
||||||
|
"-DMULADDC_CANNOT_USE_R7", "-fdata-sections",
|
||||||
|
"-fno-exceptions", "-MMD", "-D_LIBCPP_EXTERN_TEMPLATE(...)=",
|
||||||
|
"-fshort-enums", "-fshort-wchar"],
|
||||||
|
"asm": [],
|
||||||
|
"c": ["-D__ASSERT_MSG", "-std=gnu99"],
|
||||||
|
"cxx": ["-fno-rtti", "-std=gnu++98"],
|
||||||
|
"ld": ["--show_full_path", "--legacyalign"]
|
||||||
|
},
|
||||||
|
"ARM": {
|
||||||
|
"common": ["-c", "--gnu", "-Ospace", "--split_sections",
|
||||||
|
"--apcs=interwork", "--brief_diagnostics", "--restrict",
|
||||||
|
"--multibyte_chars", "-O3", "-DNDEBUG"],
|
||||||
|
"asm": [],
|
||||||
|
"c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
|
||||||
|
"cxx": ["--cpp", "--no_rtti", "--no_vla"],
|
||||||
|
"ld": ["--show_full_path"]
|
||||||
|
},
|
||||||
|
"uARM": {
|
||||||
|
"common": ["-c", "--gnu", "-Ospace", "--split_sections",
|
||||||
|
"--apcs=interwork", "--brief_diagnostics", "--restrict",
|
||||||
|
"--multibyte_chars", "-O3", "-D__MICROLIB",
|
||||||
|
"--library_type=microlib", "-DMBED_RTOS_SINGLE_THREAD", "-DNDEBUG"],
|
||||||
|
"asm": [],
|
||||||
|
"c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
|
||||||
|
"cxx": ["--cpp", "--no_rtti", "--no_vla"],
|
||||||
|
"ld": ["--library_type=microlib"]
|
||||||
|
},
|
||||||
|
"IAR": {
|
||||||
|
"common": [
|
||||||
|
"--no_wrap_diagnostics", "-e",
|
||||||
|
"--diag_suppress=Pa050,Pa084,Pa093,Pa082", "-Ohz", "-DNDEBUG", "--enable_restrict"],
|
||||||
|
"asm": [],
|
||||||
|
"c": ["--vla", "--diag_suppress=Pe546"],
|
||||||
|
"cxx": ["--guard_calls", "--no_static_destruction"],
|
||||||
|
"ld": ["--skip_dynamic_initialization", "--threaded_lib"]
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
+47
@@ -0,0 +1,47 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# patterns
|
||||||
|
DEVICEEUI=ABBAABBAABBAABBA
|
||||||
|
APPEUI=ACCAACCAACCAACCA
|
||||||
|
APPKEY=ADDAADDAADDAADDAADDAADDAADDAADDA
|
||||||
|
|
||||||
|
if [ $# -ne 2 ]; then
|
||||||
|
echo "gen_images <master_binary> <devices_file>\n"
|
||||||
|
echo "devices file must be in the form :\n"
|
||||||
|
echo "dev1name:dev1eui:dev1appeui:dev1appkey"
|
||||||
|
echo "dev2name:dev2eui:dev2appeui:dev2appkey\n"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
SED=sed
|
||||||
|
MASTER=$1
|
||||||
|
DEVICES=$2
|
||||||
|
|
||||||
|
if [[ $OSTYPE == "darwin"* ]]; then
|
||||||
|
if ! command -v gsed > /dev/null 2>&1; then
|
||||||
|
echo "You need gnu-sed on darwin system (available with homebrew)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
SED=gsed
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e $MASTER ]; then
|
||||||
|
echo "The master file $MASTER doesn't exists"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e $DEVICES ]; then
|
||||||
|
echo "The devices file $DEVICES doesn't exists"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
for DEVICE in $(cat $DEVICES); do
|
||||||
|
name=$(echo $DEVICE | cut -d : -f 1)
|
||||||
|
deviceeui=$(echo $DEVICE | cut -d : -f 2)
|
||||||
|
appeui=$(echo $DEVICE | cut -d : -f 3)
|
||||||
|
appkey=$(echo $DEVICE | cut -d : -f 4)
|
||||||
|
echo "Generating device $name ($deviceeui)"
|
||||||
|
hexdump -ve '1/1 "%.2X"' $MASTER | $SED "s/${DEVICEEUI}/${deviceeui}/; s/${APPEUI}/${appeui}/; s/${APPKEY}/${appkey}/" | xxd -r -p - ${deviceeui}.bin
|
||||||
|
done
|
||||||
|
|
||||||
|
exit;
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
https://github.com/atoy40/mbed-dht/#0aa899f3a68e02eec69e74a6f68c35249530d89d
|
https://github.com/atoy40/mbed-dht/#5e378f5eaf8d3ba88af711e035652d6277124a06
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
https://github.com/atoy40/mbed-hx711/#30e787849a54a53c0e055e21ad45d0f7b2c982b6
|
||||||
Reference in New Issue
Block a user