Skip to content

Commit

Permalink
Merge pull request #204 from cyberman54/development
Browse files Browse the repository at this point in the history
v1.6.82
  • Loading branch information
cyberman54 authored Nov 19, 2018
2 parents 80dd731 + bf62d44 commit b921731
Show file tree
Hide file tree
Showing 58 changed files with 11,716 additions and 248 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Depending on board hardware following features are supported:
- Silicon unique ID
- Battery voltage monitoring
- GPS (Generic serial NMEA, or Quectel L76 I2C)
- MEMS sensor (Bosch BME680)

Target platform must be selected in [platformio.ini](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/platformio.ini).<br>
Hardware dependent settings (pinout etc.) are stored in board files in /hal directory. If you want to use a ESP32 board which is not yet supported, use hal file generic.h and tailor pin mappings to your needs. Pull requests for new boards welcome.<br>
Expand Down Expand Up @@ -198,6 +199,13 @@ Hereafter described is the default *plain* format, which uses MSB bit numbering.
byte 1: Beacon RSSI reception level
byte 2: Beacon identifier (0..255)

**Port #7:** BME680 query result

bytes 1-2: Temperature [°C]
bytes 3-4: Pressure [hPa]
bytes 5-6: Humidity [%]
bytes 7-8: Gas resistance [kOhm]

# Remote control

The device listenes for remote control commands on LoRaWAN Port 2. Multiple commands per downlink are possible by concatenating them.
Expand Down Expand Up @@ -310,6 +318,10 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.

Device answers with it's current status on Port 4.

0x85 get BME680 sensor data

Device answers with BME680 sensor data set on Port 7.


# License

Expand Down
15 changes: 15 additions & 0 deletions include/bme680read.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef _HAS_BME
#define _HAS_BME

#include "globals.h"
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"

extern bmeStatus_t
bme_status; // Make struct for storing gps data globally available

void bme_init();
bool bme_read();

#endif
4 changes: 4 additions & 0 deletions include/cyclic.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

#include "globals.h"
#include "senddata.h"
#include "rcommand.h"
#include "spislave.h"
#include <lmic.h>

void doHousekeeping(void);
void do_timesync(void);
uint64_t uptime(void);
void reset_counters(void);
int redirect_log(const char *fmt, va_list args);
Expand Down
11 changes: 11 additions & 0 deletions include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ typedef struct {
uint16_t altitude;
} gpsStatus_t;

typedef struct {
float temperature; // Temperature in degrees Centigrade
uint16_t pressure; // Barometic pressure in hecto pascals
float humidity; // Relative humidity in percent
uint16_t gas_resistance; // Resistance in MOhms
} bmeStatus_t;

// global variables
extern configData_t cfg; // current device configuration
extern char display_line6[], display_line7[]; // screen buffers
Expand All @@ -67,6 +74,10 @@ extern TaskHandle_t irqHandlerTask, wifiSwitchTask;
#include "gpsread.h"
#endif

#ifdef HAS_BME
#include "bme680read.h"
#endif

#ifdef HAS_LORA
#include "lorawan.h"
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/irqhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define DISPLAY_IRQ 0x01
#define BUTTON_IRQ 0x02
#define SENDPAYLOAD_IRQ 0x04
#define SENDCOUNTER_IRQ 0x04
#define CYCLIC_IRQ 0x08

#include "globals.h"
Expand Down
4 changes: 3 additions & 1 deletion include/lorawan.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ void os_getDevEui(u1_t *buf);
void showLoraKeys(void);
void switch_lora(uint8_t sf, uint8_t tx);
void lora_send(osjob_t *job);
void lora_enqueuedata(uint8_t messageType, MessageBuffer_t *message);
void lora_enqueuedata(MessageBuffer_t *message);
void lora_queuereset(void);
void lora_housekeeping(void);
void user_request_network_time_callback(void *pVoidUserUTCTime,
int flagSuccess);

esp_err_t lora_stack_init();

Expand Down
11 changes: 9 additions & 2 deletions include/payload.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,25 @@
#define LPP_BATT_CHANNEL 23
#define LPP_BUTTON_CHANNEL 24
#define LPP_ADR_CHANNEL 25
#define LPP_TEMP_CHANNEL 26
#define LPP_TEMPERATURE_CHANNEL 26
#define LPP_ALARM_CHANNEL 27
#define LPP_MSG_CHANNEL 28
#define LPP_HUMIDITY_CHANNEL 29
#define LPP_BAROMETER_CHANNEL 30
#define LPP_GAS_CHANNEL 31

#endif

// MyDevices CayenneLPP types
#define LPP_GPS 136 // 3 byte lon/lat 0.0001 °, 3 bytes alt 0.01m
#define LPP_TEMPERATURE 103 // 2 bytes, 0.1°C signed
#define LPP_TEMPERATURE 103 // 2 bytes, 0.1°C signed MSB
#define LPP_DIGITAL_INPUT 0 // 1 byte
#define LPP_DIGITAL_OUTPUT 1 // 1 byte
#define LPP_ANALOG_INPUT 2 // 2 bytes, 0.01 signed
#define LPP_LUMINOSITY 101 // 2 bytes, 1 lux unsigned
#define LPP_PRESENCE 102 // 1 byte
#define LPP_HUMIDITY 104 // 1 byte, 0.5 % unsigned
#define LPP_BAROMETER 115 // 2 bytes, hPa unsigned MSB

class PayloadConvert {

Expand All @@ -39,6 +45,7 @@ class PayloadConvert {
uint8_t reset1, uint8_t reset2);
void addAlarm(int8_t rssi, uint8_t message);
void addGPS(gpsStatus_t value);
void addBME(bmeStatus_t value);
void addButton(uint8_t value);

#if PAYLOAD_ENCODER == 1 // format plain
Expand Down
4 changes: 2 additions & 2 deletions include/senddata.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "lorawan.h"
#include "cyclic.h"

void SendData(uint8_t port);
void sendPayload(void);
void SendPayload(uint8_t port);
void sendCounter(void);
void checkSendQueues(void);
void flushQueues();

Expand Down
2 changes: 1 addition & 1 deletion include/spislave.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ licenses. Refer to LICENSE.txt file in repository for more details.

esp_err_t spi_init();

void spi_enqueuedata(uint8_t messageType, MessageBuffer_t *message);
void spi_enqueuedata(MessageBuffer_t *message);
void spi_queuereset();

void spi_housekeeping();
Expand Down
119 changes: 61 additions & 58 deletions lib/arduino-lmic-mcci-v2.2.2/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Arduino-LMIC library
====================
# Arduino-LMIC library

This repository contains the IBM LMIC (LoraMAC-in-C) library, slightly
modified to run in the Arduino environment, allowing using the SX1272,
Expand All @@ -25,56 +24,56 @@ requires C99 mode to be enabled by default.
We strongly recommend updating using VS Code, the markdown-toc extension and the
bierner.markdown-preview-github-styles extension.
-->
<!-- TOC depthFrom:1 -->
<!-- TOC depthFrom:2 -->

- [Installing](#installing)
- [Features](#features)
- [Configuration](#configuration)
- [Selecting the LoRaWAN Region Configuration](#selecting-the-lorawan-region-configuration)
- [eu868, as923, in866](#eu868-as923-in866)
- [us915, au921](#us915-au921)
- [Selecting the target radio transceiver](#selecting-the-target-radio-transceiver)
- [Controlling use of interrupts](#controlling-use-of-interrupts)
- [Disabling PING](#disabling-ping)
- [Disabling Beacons](#disabling-beacons)
- [Rarely changed variables](#rarely-changed-variables)
- [Changing debug output](#changing-debug-output)
- [Getting debug from the RF library](#getting-debug-from-the-rf-library)
- [Selecting the AES library](#selecting-the-aes-library)
- [Defining the OS Tick Frequency](#defining-the-os-tick-frequency)
- [Setting the SPI-bus frequency](#setting-the-spi-bus-frequency)
- [Changing handling of runtime assertion failures](#changing-handling-of-runtime-assertion-failures)
- [Disabling JOIN](#disabling-join)
- [Disabling Class A MAC commands](#disabling-class-a-mac-commands)
- [Disabling Class B MAC commands](#disabling-class-b-mac-commands)
- [Special purpose](#special-purpose)
- [Selecting the LoRaWAN Region Configuration](#selecting-the-lorawan-region-configuration)
- [eu868, as923, in866](#eu868-as923-in866)
- [us915, au921](#us915-au921)
- [Selecting the target radio transceiver](#selecting-the-target-radio-transceiver)
- [Controlling use of interrupts](#controlling-use-of-interrupts)
- [Disabling PING](#disabling-ping)
- [Disabling Beacons](#disabling-beacons)
- [Rarely changed variables](#rarely-changed-variables)
- [Changing debug output](#changing-debug-output)
- [Getting debug from the RF library](#getting-debug-from-the-rf-library)
- [Selecting the AES library](#selecting-the-aes-library)
- [Defining the OS Tick Frequency](#defining-the-os-tick-frequency)
- [Setting the SPI-bus frequency](#setting-the-spi-bus-frequency)
- [Changing handling of runtime assertion failures](#changing-handling-of-runtime-assertion-failures)
- [Disabling JOIN](#disabling-join)
- [Disabling Class A MAC commands](#disabling-class-a-mac-commands)
- [Disabling Class B MAC commands](#disabling-class-b-mac-commands)
- [Special purpose](#special-purpose)
- [Supported hardware](#supported-hardware)
- [Connections](#connections)
- [Power](#power)
- [SPI](#spi)
- [DIO pins](#dio-pins)
- [Reset](#reset)
- [RXTX](#rxtx)
- [RXTX Polarity](#rxtx-polarity)
- [Pin mapping](#pin-mapping)
- [Adafruit Feather M0 LoRa](#adafruit-feather-m0-lora)
- [Adafruit Feather 32u4 LoRa](#adafruit-feather-32u4-lora)
- [LoRa Nexus by Ideetron](#lora-nexus-by-ideetron)
- [MCCI Catena 4450/4460](#mcci-catena-44504460)
- [MCCI Catena 4551](#mcci-catena-4551)
- [Power](#power)
- [SPI](#spi)
- [DIO pins](#dio-pins)
- [Reset](#reset)
- [RXTX](#rxtx)
- [RXTX Polarity](#rxtx-polarity)
- [Pin mapping](#pin-mapping)
- [Adafruit Feather M0 LoRa](#adafruit-feather-m0-lora)
- [Adafruit Feather 32u4 LoRa](#adafruit-feather-32u4-lora)
- [LoRa Nexus by Ideetron](#lora-nexus-by-ideetron)
- [MCCI Catena 4450/4460](#mcci-catena-44504460)
- [MCCI Catena 4551](#mcci-catena-4551)
- [Example Sketches](#example-sketches)
- [Timing](#timing)
- [`LMIC_setClockError()`](#lmic_setclockerror)
- [`LMIC_setClockError()`](#lmic_setclockerror)
- [Downlink datarate](#downlink-datarate)
- [Encoding Utilities](#encoding-utilities)
- [sflt16](#sflt16)
- [JavaScript decoder](#javascript-decoder)
- [uflt16](#uflt16)
- [JavaScript decoder](#javascript-decoder-1)
- [sflt12](#sflt12)
- [JavaScript decoder](#javascript-decoder-2)
- [uflt12](#uflt12)
- [JavaScript decoder](#javascript-decoder-3)
- [sflt16](#sflt16)
- [JavaScript decoder](#javascript-decoder)
- [uflt16](#uflt16)
- [JavaScript decoder](#javascript-decoder-1)
- [sflt12](#sflt12)
- [JavaScript decoder](#javascript-decoder-2)
- [uflt12](#uflt12)
- [JavaScript decoder](#javascript-decoder-3)
- [Release History](#release-history)
- [Contributions](#contributions)
- [Trademark Acknowledgements](#trademark-acknowledgements)
Expand All @@ -86,12 +85,12 @@ requires C99 mode to be enabled by default.

To install this library:

- install it using the Arduino Library manager ("Sketch" -> "Include
- install it using the Arduino Library manager ("Sketch" -> "Include
Library" -> "Manage Libraries..."), or
- download a zipfile from github using the "Download ZIP" button and
- download a zipfile from github using the "Download ZIP" button and
install it using the IDE ("Sketch" -> "Include Library" -> "Add .ZIP
Library..."
- clone this git repository into your sketchbook/libraries folder.
- clone this git repository into your sketchbook/libraries folder.

For more info, see https://www.arduino.cc/en/Guide/Libraries

Expand All @@ -105,19 +104,19 @@ The library has only been tested with LoRaWAN 1.0.2 networks and does not have t

What certainly works:

- Sending packets uplink, taking into account duty cycling.
- Encryption and message integrity checking.
- Receiving downlink packets in the RX2 window.
- Custom frequencies and datarate settings.
- Over-the-air activation (OTAA / joining).
- Receiving downlink packets in the RX1 and RX2 windows.
- Some MAC command processing.
- Sending packets uplink, taking into account duty cycling.
- Encryption and message integrity checking.
- Receiving downlink packets in the RX2 window.
- Custom frequencies and datarate settings.
- Over-the-air activation (OTAA / joining).
- Receiving downlink packets in the RX1 and RX2 windows.
- Some MAC command processing.

What has not been tested:

- Receiving and processing all MAC commands.
- Class B operation.
- FSK has not been extensively tested.
- Receiving and processing all MAC commands.
- Class B operation.
- FSK has not been extensively tested.

If you try one of these untested features and it works, be sure to let
us know (creating a github issue is probably the best way for that).
Expand All @@ -131,7 +130,7 @@ directory is the only directory that contains files that you
should edit to match your project; we organize things this way
so that your local changes are more clearly separated from
the distribution files. The Arduino environment doesn't give
us a better way to do this.
us a better way to do this, unless you change `BOARDS.txt`.

Unlike other ports of the LMIC code, in this port, you should not edit `src/lmic/config.h` to configure this package.

Expand All @@ -147,6 +146,7 @@ The library supports the following regions:
`-D CFG_us915` | `LMIC_REGION_us915` | 2 | 2.2 | US 902-928 MHz ISM
`-D CFG_au921` | `LMIC_REGION_au921` | 5 | 2.5 | Australia 915-928 MHz ISM
`-D CFG_as923` | `LMIC_REGION_as923` | 7 | 2.7 | Asia 923 MHz ISM
`-D CFG_as923jp` | `LMIC_REGION_as923` and `LMIC_COUNTRY_CODE_JP` | 7 | 2.7 | Asia 923 MHz ISM with Japan listen-before-talk (LBT) rules
`-D CFG_in866` | `LMIC_REGION_in866` | 9 | 2.9 | India 865-867 MHz ISM

You should define exactly one of `CFG_...` variables. If you don't,
Expand Down Expand Up @@ -205,8 +205,7 @@ By default, PING support is included in the library.
If defined, removes all code needed for handling beacons. Removes the APIs `LMIC_enableTracking()` and `LMIC_disableTracking()`.
Class A devices don't support beacons, so defining `DISABLE_BEACONS` might be a good idea.


### Rarely changed variables ###
### Rarely changed variables

The remaining variables are rarely used, but we list them here for completeness.

Expand Down Expand Up @@ -1022,6 +1021,10 @@ function uflt122f(rawUflt12)

## Release History

- Interim bug fixes: added a new API (`radio_irq_handler_v2()`), which allows the caller to provide the timestamp of the interrupt. This allows for more accurate timing, because the knowledge of interrupt overhead can be moved to a platform-specific layer ([#148](https://github.com/mcci-catena/arduino-lmic/issues/148)). Fixed compile issues on ESP32 ([#140](https://github.com/mcci-catena/arduino-lmic/issues/140) and [#153](https://github.com/mcci-catena/arduino-lmic/issues/150)). We added ESP32 and 32u4 as targets in CI testing. We switched CI testing to Arduino IDE 1.8.7.
Fixed issue [#161](https://github.com/mcci-catena/arduino-lmic/issues/161) selecting the Japan version of as923 using `CFG_as923jp` (selecting via `CFG_as923` and `LMIC_COUNTRY_CODE=LMIC_COUNTRY_CODE_JP` worked).
Fixed [#38](https://github.com/mcci-catena/arduino-lmic/issues/38) -- now any call to hal_init() will put the NSS line in the idle (high/inactive) state. As a side effect, RXTX is initialized, and RESET code changed to set value before transitioning state. Likely no net effect, but certainly more correct.

- V2.2.2 adds `ttn-abp-feather-us915-dht22.ino` example, and fixes some documentation typos. It also fixes encoding of the `Margin` field of the `DevStatusAns` MAC message ([#130](https://github.com/mcci-catena/arduino-lmic/issues/130)). This makes Arduino LMIC work with newtorks implemented with [LoraServer](https://www.loraserver.io/).

- V2.2.1 corrects the value of `ARDUINO_LMIC_VERSION` ([#123](https://github.com/mcci-catena/arduino-lmic/issues/123)), allows ttn-otaa-feather-us915 example to compile for the Feather 32u4 LoRa ([#116](https://github.com/mcci-catena/arduino-lmic/issues/116)), and addresses documentation issues ([#122](https://github.com/mcci-catena/arduino-lmic/issues/122), [#120](https://github.com/mcci-catena/arduino-lmic/issues/120)).
Expand Down
8,569 changes: 8,569 additions & 0 deletions lib/arduino-lmic-mcci-v2.2.2/assets/Feather-M0-LoRa-Wire.ai

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions lib/arduino-lmic-mcci-v2.2.2/examples/header_test/header_test.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Module: header_test.ino
Function:
Simple hello-world (and compile-test) app
Copyright notice and License:
See LICENSE file accompanying this project.
Author:
Terry Moore, MCCI Corporation April 2018
*/

#include <lmic.h>

# define STATIC_ASSERT(e) \
void STATIC_ASSERT__(int MCCIADK_C_ASSERT_x[(e) ? 1: -1])

STATIC_ASSERT(ARDUINO_LMIC_VERSION >= ARDUINO_LMIC_VERSION_CALC(2,1,5,0));

STATIC_ASSERT(ARDUINO_LMIC_VERSION_CALC(1,2,3,4) == 0x01020304);

STATIC_ASSERT(ARDUINO_LMIC_VERSION_GET_MAJOR(ARDUINO_LMIC_VERSION_CALC(1,2,3,4)) == 1);
STATIC_ASSERT(ARDUINO_LMIC_VERSION_GET_MINOR(ARDUINO_LMIC_VERSION_CALC(1,2,3,4)) == 2);
STATIC_ASSERT(ARDUINO_LMIC_VERSION_GET_PATCH(ARDUINO_LMIC_VERSION_CALC(1,2,3,4)) == 3);
STATIC_ASSERT(ARDUINO_LMIC_VERSION_GET_LOCAL(ARDUINO_LMIC_VERSION_CALC(1,2,3,4)) == 4);

void setup()
{
}

void loop()
{
}
Loading

0 comments on commit b921731

Please sign in to comment.