Skip to content

Commit

Permalink
API v27
Browse files Browse the repository at this point in the history
  • Loading branch information
Libelium committed Feb 7, 2017
1 parent 0913773 commit 7ba8a3c
Show file tree
Hide file tree
Showing 37 changed files with 3,097 additions and 2,482 deletions.
547 changes: 416 additions & 131 deletions libraries/Frame/WaspFrame.cpp

Large diffs are not rendered by default.

91 changes: 49 additions & 42 deletions libraries/Frame/WaspFrame.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! \file WaspFrame.h
\brief Library for creating formated frames
Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
Copyright (C) 2017 Libelium Comunicaciones Distribuidas S.L.
http://www.libelium.com
This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -49,6 +49,14 @@
* Definitions & Declarations
******************************************************************************/

//! DEBUG_FRAME
/*! Possible values:
* 0: No debug mode enabled
* 1: debug mode enabled for error output messages
* 2: debug mode enabled for both error and ok messages
*/
#define DEBUG_FRAME 0

// define print message
#define PRINT_FRAME(str) USB.print(F("[FRAME] ")); USB.print(str);

Expand Down Expand Up @@ -108,31 +116,13 @@
#define SERVICE2_FRAME 5
#define INFORMATION_FRAME_V15 6

/*! \def AES128_ECB_FRAME_V12
\brief Encrypted frame using AES-128 key size and ECB mode (Waspmote v12)
*/
/*! \def AES192_ECB_FRAME_V12
\brief Encrypted frame using AES-192 key size and ECB mode (Waspmote v12)
*/
/*! \def AES256_ECB_FRAME_V12
\brief Encrypted frame using AES-256 key size and ECB mode (Waspmote v12)
*/
/*! \def AES128_ECB_FRAME_V15
\brief Encrypted frame using AES-128 key size and ECB mode (Waspmote v15)
*/
/*! \def AES192_ECB_FRAME_V15
\brief Encrypted frame using AES-192 key size and ECB mode (Waspmote v15)
*/
/*! \def AES256_ECB_FRAME_V15
\brief Encrypted frame using AES-256 key size and ECB mode (Waspmote v15)
*/
#define AES128_ECB_FRAME_V15 94
#define AES192_ECB_FRAME_V15 95
#define AES256_ECB_FRAME_V15 96
// Define frame types for encrypted frames in different formats
#define AES_ECB_FRAME_V15 96
#define AES128_ECB_FRAME_V12 97
#define AES192_ECB_FRAME_V12 98
#define AES256_ECB_FRAME_V12 99

#define AES_ECB_END_TO_END_V15 100
#define AES_ECB_END_TO_END_V12 101


/*! \def TYPE_UINT8
Expand Down Expand Up @@ -172,6 +162,8 @@
//! Variable : Waspmote serial id
extern volatile uint8_t _serial_id[8];

const uint8_t max_fields = 20;


/******************************************************************************
* Class
Expand Down Expand Up @@ -210,25 +202,17 @@ class WaspFrame
*/
uint8_t sequence;

//! Variable : number of sensor values within the frame
/*!
*/
uint8_t numFields;

//! Variable : frame format: ASCII (0) or BINARY (1)
/*!
*/
uint8_t _mode;

//! Variable : maximum frame size
/*!
*/
uint16_t _maxSize;

//! Variable : buffer for Waspmote ID. 16B maximum
/*!
*/
char _waspmoteID[17];
char _waspmoteID[17];

//! Variable: encryption flag for End-to-End encryption from device to Cloud
uint8_t _encryptionToCloud;

public:

Expand Down Expand Up @@ -303,6 +287,10 @@ class WaspFrame
*/
uint8_t encryptFrame( uint16_t AESmode, char* password );

/*! Function: Enabled/Disabled the encryption mode to Cloud
\param uint8_t flag: ENABLED or DISABLED
*/
void encryptionToCloud(uint8_t flag);

//! Function : set the frame type
/*! This function sets the frame type (fourth byte of the frame header)
Expand Down Expand Up @@ -340,20 +328,39 @@ class WaspFrame

void setID(char* moteID);
void getID(char* moteID);

void decrementSequence(void);

//! Function: add special timestamp field
int8_t addTimestamp(void);

//! Variable : buffer where the frame is created in
/*!
*/
uint8_t buffer[MAX_FRAME+1];

//! Variable : length of the frame
/*!
*/
uint16_t length;
uint16_t length;

//! Variable : number of sensor values within the frame
uint8_t numFields;

//! Function: set new tiny frame max length
void setTinyLength(uint8_t length);
//! Function: generate new frame from internal strcutures
uint8_t generateTinyFrame();

int8_t addTimestamp(void);
//! Variable : buffer where the Tiny Frame is created
uint8_t bufferTiny[100];
uint8_t lengthTiny;
uint8_t _maxTinyLength;

//! Structure for storing all fields in binary frame
struct
{
uint8_t flag; // flag to indicate if data has been added ('0':not added; '1' added)
uint8_t start; // index of starting byte of field
uint8_t size; // total size of sensor field: id+data
}field[max_fields];

};

extern WaspFrame frame;
Expand Down
50 changes: 47 additions & 3 deletions libraries/Frame/WaspFrameConstantsv15.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! \file WaspFrameConstantsv15.h
\brief Header file for Waspmote v15 Frame Constants
Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
Copyright (C) 2017 Libelium Comunicaciones Distribuidas S.L.
http://www.libelium.com
This program is free software: you can redistribute it and/or modify
Expand All @@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Version: 3.1
Version: 3.2
Design: David Gascón
Implementation: Yuri Carmona, Javier Siscart, Joaquín Ruiz, Alejandro Gallego
Expand Down Expand Up @@ -225,6 +225,12 @@
#define SENSOR_AMBIENT_PRES 77
#define SENSOR_AMBIENT_LUXES 78

// 4-20 mA
#define SENSOR_4_20_CURRENT_SOCKET_A 175
#define SENSOR_4_20_CURRENT_SOCKET_B 176
#define SENSOR_4_20_CURRENT_SOCKET_C 177
#define SENSOR_4_20_CURRENT_SOCKET_D 178


// Common sensors
#define SENSOR_DUST_PM1 70
Expand Down Expand Up @@ -460,6 +466,14 @@ const char str_frame_169[] PROGMEM = ""; // reserved
const char str_frame_170[] PROGMEM = "TCB";
const char str_frame_171[] PROGMEM = "HUMB";
const char str_frame_172[] PROGMEM = "LUM";
const char str_frame_173[] PROGMEM = "";
const char str_frame_174[] PROGMEM = "";

// 4-20 mA
const char str_frame_175[] PROGMEM = "CUR_A";
const char str_frame_176[] PROGMEM = "CUR_B";
const char str_frame_177[] PROGMEM = "CUR_C";
const char str_frame_178[] PROGMEM = "CUR_D";



Expand Down Expand Up @@ -645,6 +659,12 @@ const char* const FRAME_SENSOR_TABLE[] PROGMEM=
str_frame_170,
str_frame_171,
str_frame_172,
str_frame_173,
str_frame_174,
str_frame_175,
str_frame_176,
str_frame_177,
str_frame_178,

};

Expand Down Expand Up @@ -865,6 +885,14 @@ const uint8_t FRAME_SENSOR_TYPE_TABLE[] PROGMEM=
2, // 170
2, // 171
2, // 172
0, // 173
0, // 174

//// 4-20 mA
2, // 175
2, // 176
2, // 177
2, // 178
};


Expand Down Expand Up @@ -1080,6 +1108,14 @@ const uint8_t FRAME_SENSOR_FIELD_TABLE[] PROGMEM=
1, // 170
1, // 171
1, // 172
1, // 173
1, // 174

//// 4-20 mA
1, // 175
1, // 176
1, // 177
1, // 178

};

Expand Down Expand Up @@ -1286,12 +1322,20 @@ const uint8_t FRAME_DECIMAL_TABLE[] PROGMEM =
2, // 166
2, // 167
2, // 168
0, // 169
0, // 169

//// Ambient Control
2, // 170
1, // 171
3, // 172
0, // 173
0, // 174

//// 4-20 mA
3, // 175
3, // 176
3, // 177
3, // 178


};
Expand Down
18 changes: 14 additions & 4 deletions libraries/Frame/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ setID KEYWORD2
getID KEYWORD2
addTimestamp KEYWORD2
decrementSequence KEYWORD2
setTinyLength KEYWORD2
generateTinyFrame KEYWORD2
bufferTiny KEYWORD2
lengthTiny KEYWORD2
encryptionToCloud KEYWORD2


_serial_id KEYWORD2
Expand Down Expand Up @@ -60,12 +65,12 @@ TYPE_ULONG LITERAL1
BINARY LITERAL1
ASCII LITERAL1
ENCRYPTED_FRAME LITERAL1
AES128_ECB_FRAME_V15 LITERAL1
AES192_ECB_FRAME_V15 LITERAL1
AES256_ECB_FRAME_V15 LITERAL1
AES_ECB_FRAME_V15 LITERAL1
AES128_ECB_FRAME_V12 LITERAL1
AES192_ECB_FRAME_V12 LITERAL1
AES256_ECB_FRAME_V12 LITERAL1
AES_ECB_END_TO_END_V15 LITERAL1
AES_ECB_END_TO_END_V12 LITERAL1



Expand Down Expand Up @@ -334,7 +339,7 @@ SENSOR_CITIES_PRO_HCL LITERAL1
SENSOR_CITIES_PRO_HCN LITERAL1
SENSOR_CITIES_PRO_PH3 LITERAL1
SENSOR_CITIES_PRO_SO2 LITERAL1
SENSOR_CITIES_PRO_AUDIO LITERAL1
SENSOR_CITIES_PRO_NOISE LITERAL1
SENSOR_CITIES_PRO_SOCKET_A LITERAL1
SENSOR_CITIES_PRO_SOCKET_B LITERAL1
SENSOR_CITIES_PRO_SOCKET_C LITERAL1
Expand Down Expand Up @@ -421,6 +426,11 @@ SENSOR_AMBIENT_TC LITERAL1
SENSOR_AMBIENT_HUM LITERAL1
SENSOR_AMBIENT_PRES LITERAL1

SENSOR_4_20_CURRENT_SOCKET_A LITERAL1
SENSOR_4_20_CURRENT_SOCKET_B LITERAL1
SENSOR_4_20_CURRENT_SOCKET_C LITERAL1
SENSOR_4_20_CURRENT_SOCKET_D LITERAL1

SENSOR_DUST_PM1 LITERAL1
SENSOR_DUST_PM2_5 LITERAL1
SENSOR_DUST_PM10 LITERAL1
Expand Down
10 changes: 5 additions & 5 deletions libraries/LoRaWAN/WaspLoRaWAN.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Library for managing managing the LoRaWAN module
*
* Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
* Copyright (C) 2017 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version: 3.1
* Version: 3.2
* Design: David Gascón
* Implementation: Luis Miguel Martí
*/
Expand Down Expand Up @@ -661,7 +661,7 @@ uint8_t WaspLoRaWAN::check()
/*!
* @brief This function is used to reset LoRaWAN configuration and set working band.
*
* @param char* band: working LoRaWAN band: "433","868" or "900"
* @param char* band: working LoRaWAN band: "433", EU or US
*
* @return
* @arg '0' if OK
Expand Down Expand Up @@ -1344,7 +1344,7 @@ uint8_t WaspLoRaWAN::setAppSessionKey(char* key)
* @brief This function is used to configure the LoRaWAN RF power level
*
* @param uint8_t index: power level to be set [0..5] for 433 MHz,
* [1..5] for 868 MHz and [5..10] for 900
* [1..5] for EU and [5..10] for US
*
* @arg 0 -> 20 dBm (if supported)
* @arg 1 -> 14 dBm
Expand Down Expand Up @@ -5228,7 +5228,7 @@ uint8_t WaspLoRaWAN::getRadioBW()


/*!
* @brief This function sets data rate and frecuency used for the
* @brief This function sets data rate and frequency used for the
* second receive window.
*
* @remarks The configuration of the receive window parameters should
Expand Down
2 changes: 2 additions & 0 deletions libraries/LoRaWAN/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ setRadioBitRateFSK KEYWORD2
getRadioBitRateFSK KEYWORD2
setRadioFreqDeviation KEYWORD2
getRadioFreqDeviation KEYWORD2
getMaxPayload KEYWORD2
_maxPayload KEYWORD2

LORAWAN_ANSWER_OK LITERAL1
LORAWAN_ANSWER_ERROR LITERAL1
Expand Down
12 changes: 9 additions & 3 deletions libraries/ModbusMaster/ModbusMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
Written by Doc Walker (Rx)
Copyright © 2009-2013 Doc Walker <4-20ma at wvfans dot net>
Modified for Waspmote by Libelium, 2016
Modified for Waspmote by Libelium, 2017
Version: 3.1
Version: 3.2
*/

#include "ModbusMaster.h"
Expand Down Expand Up @@ -123,8 +123,14 @@ void ModbusMaster::begin(unsigned long BaudRate , uint8_t socket)

if (_protocol == RS232_COM)
{

_u8SerialPort = socket;
beginSerial(BaudRate, _u8SerialPort);
beginSerial(BaudRate, _u8SerialPort);

if (socket == SOCKET0) Utils.setMuxSocket0();
if (socket == SOCKET1) Utils.setMuxSocket1();
// power on the socket
PWR.powerSocket(socket, HIGH);
}
else
{
Expand Down
Loading

0 comments on commit 7ba8a3c

Please sign in to comment.