From 79f49b12c3aebc0d23321853195226962f5d8ddd Mon Sep 17 00:00:00 2001 From: tomoaki Date: Mon, 3 Sep 2018 09:04:55 +0900 Subject: [PATCH] Remove Constants of LoRaWAN definitions from ADB922S.h Add ST_LORAWAN_DISCOVERY libraly to the git repository Signed-off-by: tomoaki --- ADB922S.cpp | 4 + ADB922S.h | 67 +------------ AppDefine.h | 2 +- LoRaWANDef.h | 97 +++++++++++++++++++ examples/ADR_Sample/ADR_Sample.ino | 4 + examples/Basic_Sample/Basic_Sample.ino | 7 ++ examples/Downlink_Sample/Downlink_Sample.ino | 8 +- examples/End-node_Sample/End-node_Sample.ino | 7 ++ examples/GPS_Sample/GPS_Sample.ino | 7 ++ .../I2C_Temp_Sensor_and_GPS_Sample.ino | 7 ++ .../I2C_Temp_Sensor_and_GPS_Sample/KGPS.cpp | 2 +- .../I2C_Temp_Sensor_and_GPS_Sample/KGPS.h | 2 +- 12 files changed, 144 insertions(+), 70 deletions(-) create mode 100644 LoRaWANDef.h diff --git a/ADB922S.cpp b/ADB922S.cpp index cca67cd..0d2abc7 100644 --- a/ADB922S.cpp +++ b/ADB922S.cpp @@ -40,6 +40,10 @@ extern PortList_t thePortList[]; const char* loraTxUnconfirmCmd = "lorawan tx ucnf"; const char* loraTxConfirmCmd = "lorawan tx cnf"; +#define LoRa_Rx_PIN 11 +#define LoRa_Tx_PIN 12 +#define LoRa_WAKEUP_PIN 7 + // // // Class ADB922S diff --git a/ADB922S.h b/ADB922S.h index 3c215dd..cb733b9 100644 --- a/ADB922S.h +++ b/ADB922S.h @@ -27,77 +27,12 @@ #ifndef ADB922S_H_ #define ADB922S_H_ #include +#include #include #include namespace tomyApplication { -// -// LoRaWAN defines -// -#define LoRa_DEFAULT_PAYLOAD_SIZE 11 - -#define LoRa_INIT_WAIT_TIME 1000 -#define LoRa_SERIAL_WAIT_TIME 2000 -#define LoRa_RECEIVE_DELAY2 5000 -#define JOIN__WAIT_TIME 30000 - -#define LORA_RC_SUCCESS 0 -#define LORA_RC_DATA_TOO_LONG -1 -#define LORA_RC_NOT_JOINED -2 -#define LORA_RC_NO_FREE_CH -3 -#define LORA_RC_BUSY -4 -#define LORA_RC_ERROR -5 -#define LoRa_Rx_PIN 11 -#define LoRa_Tx_PIN 12 -#define LoRa_WAKEUP_PIN 7 - -#define ADR_ACK_LIMIT 5 -#define ADR_ACK_DELAY 2 - -#ifdef LORA_DEBUG -#define LoRaDebug(...) DebugPrint( __VA_ARGS__) -#define ECHOFLAG true -#else -#define LoRaDebug(...) -#define ECHOFLAG false -#endif - -#ifdef TEST_ADR -#define ADRDebug(...) DebugPrint( __VA_ARGS__) -#else -#define ADRDebug(...) -#endif - -#define MAX_NO_FREE_CH_CNT 5 -#ifndef PORT_LIST -#define PORT_LIST PortList_t thePortList[] -#define PORT(...) {__VA_ARGS__} -#define END_OF_PORT_LIST {0, 0} - -typedef enum -{ - DR0, DR1, DR2, DR3, DR4, DR5 -}LoRaDR; - -typedef enum -{ - CH0, CH1, CH2, CH3, CH4, CH5, CH6, CH7, CH8, CH9, CH10, CH11, CH12, CH13, CH14, CH15, CH16 -}CHID; - -typedef enum { - joined, not_joined -}JoineStatus; - -typedef struct PortList -{ - uint8_t port; - void (*callback)(void); -} PortList_t; -#endif - -#define LORA_TYPES - class ADB922S { public: diff --git a/AppDefine.h b/AppDefine.h index fc8c36e..f00ccfe 100644 --- a/AppDefine.h +++ b/AppDefine.h @@ -39,6 +39,6 @@ /* * Version */ -#define KGS_VERSION F("\n_/_/_/ KashiwaGeeks 0.10.2 _/_/_/\r\n\n") +#define KGS_VERSION F("\n_/_/_/ KashiwaGeeks 0.10.3 _/_/_/\r\n\n") #endif /* LIBRARIES_KASHIWAGEEKS_APPDEFINE_H_ */ diff --git a/LoRaWANDef.h b/LoRaWANDef.h new file mode 100644 index 0000000..34fce6a --- /dev/null +++ b/LoRaWANDef.h @@ -0,0 +1,97 @@ +/* + * LoRaWANDef.h + * + * The MIT License + * + * Copyright (c) 2017-2018 Tomoaki Yamaguchi tomoaki@tomy-tech.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in 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 above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 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 + * AUTHORS 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 IN + * THE SOFTWARE. + */ + +#ifndef LORAWANDEF_H_ +#define LORAWANDEF_H_ +namespace tomyApplication +{ + +// +// LoRaWAN defines +// +#define LoRa_DEFAULT_PAYLOAD_SIZE 11 + +#define LoRa_INIT_WAIT_TIME 1000 +#define LoRa_SERIAL_WAIT_TIME 2000 +#define LoRa_RECEIVE_DELAY2 5000 +#define JOIN__WAIT_TIME 30000 + +#define LORA_RC_SUCCESS 0 +#define LORA_RC_DATA_TOO_LONG -1 +#define LORA_RC_NOT_JOINED -2 +#define LORA_RC_NO_FREE_CH -3 +#define LORA_RC_BUSY -4 +#define LORA_RC_ERROR -5 + +#define ADR_ACK_LIMIT 5 +#define ADR_ACK_DELAY 2 + +#ifdef LORA_DEBUG +#define LoRaDebug(...) DebugPrint( __VA_ARGS__) +#define ECHOFLAG true +#else +#define LoRaDebug(...) +#define ECHOFLAG false +#endif + +#ifdef TEST_ADR +#define ADRDebug(...) DebugPrint( __VA_ARGS__) +#else +#define ADRDebug(...) +#endif + +#define MAX_NO_FREE_CH_CNT 5 +#ifndef PORT_LIST +#define PORT_LIST PortList_t thePortList[] +#define PORT(...) {__VA_ARGS__} +#define END_OF_PORT_LIST {0, 0} + +typedef enum +{ + DR0, DR1, DR2, DR3, DR4, DR5 +}LoRaDR; + +typedef enum +{ + CH0, CH1, CH2, CH3, CH4, CH5, CH6, CH7, CH8, CH9, CH10, CH11, CH12, CH13, CH14, CH15, CH16 +}CHID; + +typedef enum { + joined, not_joined +}JoineStatus; + +typedef struct PortList +{ + uint8_t port; + void (*callback)(void); +} PortList_t; +#endif + +#define LORA_TYPES + +} + +#endif /* LORAWANDEF_H_ */ diff --git a/examples/ADR_Sample/ADR_Sample.ino b/examples/ADR_Sample/ADR_Sample.ino index f0429ba..049bade 100644 --- a/examples/ADR_Sample/ADR_Sample.ino +++ b/examples/ADR_Sample/ADR_Sample.ino @@ -1,4 +1,8 @@ /**************************************************************** + * + * The MIT License + * + * Copyright (c) 2017-2018 tomoaki@tomy-tech.com * * I M P O R T A N T N O T I C E * diff --git a/examples/Basic_Sample/Basic_Sample.ino b/examples/Basic_Sample/Basic_Sample.ino index 1d1486d..5ddea05 100644 --- a/examples/Basic_Sample/Basic_Sample.ino +++ b/examples/Basic_Sample/Basic_Sample.ino @@ -1,3 +1,10 @@ +/**************************************************************** + * + * The MIT License + * + * Copyright (c) 2017-2018 tomoaki@tomy-tech.com + * + ***************************************************************/ #include void start(void) diff --git a/examples/Downlink_Sample/Downlink_Sample.ino b/examples/Downlink_Sample/Downlink_Sample.ino index 18aaa81..bb18ce3 100644 --- a/examples/Downlink_Sample/Downlink_Sample.ino +++ b/examples/Downlink_Sample/Downlink_Sample.ino @@ -1,4 +1,10 @@ - +/**************************************************************** + * + * The MIT License + * + * Copyright (c) 2017-2018 tomoaki@tomy-tech.com + * + ***************************************************************/ #include #define ECHO true diff --git a/examples/End-node_Sample/End-node_Sample.ino b/examples/End-node_Sample/End-node_Sample.ino index 20c04d7..3c4014b 100644 --- a/examples/End-node_Sample/End-node_Sample.ino +++ b/examples/End-node_Sample/End-node_Sample.ino @@ -1,3 +1,10 @@ +/**************************************************************** + * + * The MIT License + * + * Copyright (c) 2017-2018 tomoaki@tomy-tech.com + * + ***************************************************************/ #include #define ECHO true diff --git a/examples/GPS_Sample/GPS_Sample.ino b/examples/GPS_Sample/GPS_Sample.ino index 8141441..cbaba7c 100644 --- a/examples/GPS_Sample/GPS_Sample.ino +++ b/examples/GPS_Sample/GPS_Sample.ino @@ -1,3 +1,10 @@ +/**************************************************************** + * + * The MIT License + * + * Copyright (c) 2017-2018 tomoaki@tomy-tech.com + * + ***************************************************************/ #include #include diff --git a/examples/I2C_Temp_Sensor_and_GPS_Sample/I2C_Temp_Sensor_and_GPS_Sample.ino b/examples/I2C_Temp_Sensor_and_GPS_Sample/I2C_Temp_Sensor_and_GPS_Sample.ino index 7a03135..f2ab994 100644 --- a/examples/I2C_Temp_Sensor_and_GPS_Sample/I2C_Temp_Sensor_and_GPS_Sample.ino +++ b/examples/I2C_Temp_Sensor_and_GPS_Sample/I2C_Temp_Sensor_and_GPS_Sample.ino @@ -1,3 +1,10 @@ +/**************************************************************** + * + * The MIT License + * + * Copyright (c) 2017-2018 tomoaki@tomy-tech.com + * + ***************************************************************/ #include #include #include "KGPS.h" diff --git a/examples/I2C_Temp_Sensor_and_GPS_Sample/KGPS.cpp b/examples/I2C_Temp_Sensor_and_GPS_Sample/KGPS.cpp index 6b1bfff..68d1ee0 100644 --- a/examples/I2C_Temp_Sensor_and_GPS_Sample/KGPS.cpp +++ b/examples/I2C_Temp_Sensor_and_GPS_Sample/KGPS.cpp @@ -1,5 +1,5 @@ /* - * KGPS.cpp + * KGPS.cpp The MIT license * * COPYRIGHT(c) 2018 tomoaki < tomoaki@tomy-tech.com > * diff --git a/examples/I2C_Temp_Sensor_and_GPS_Sample/KGPS.h b/examples/I2C_Temp_Sensor_and_GPS_Sample/KGPS.h index 81fdf5c..c0c6c9f 100644 --- a/examples/I2C_Temp_Sensor_and_GPS_Sample/KGPS.h +++ b/examples/I2C_Temp_Sensor_and_GPS_Sample/KGPS.h @@ -1,5 +1,5 @@ /* - * KGPS.h + * KGPS.h The MIT license * * COPYRIGHT(c) 2018 tomoaki < tomoaki@tomy-tech.com > *