Remove node manager on controller
This commit is contained in:
parent
59366bc37b
commit
42a396363c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,136 +0,0 @@
|
|||
#ifndef config_h
|
||||
#define config_h
|
||||
|
||||
/**********************************
|
||||
* Sketch configuration
|
||||
*/
|
||||
|
||||
#define SKETCH_NAME "Serial gateway"
|
||||
#define SKETCH_VERSION "1.1"
|
||||
|
||||
/**********************************
|
||||
* MySensors node configuration
|
||||
*/
|
||||
|
||||
// General settings
|
||||
#define MY_BAUD_RATE 9600
|
||||
#define MY_DEBUG
|
||||
//#define MY_NODE_ID 32
|
||||
|
||||
// NRF24 radio settings
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RF24_ENABLE_ENCRYPTION
|
||||
//#define MY_RF24_CHANNEL 76
|
||||
#define MY_RF24_PA_LEVEL RF24_PA_HIGH
|
||||
#define MY_RF24_PA_LEVEL_GW RF24_PA_HIGH
|
||||
|
||||
//#define MY_DEBUG_VERBOSE_RF24
|
||||
|
||||
// RFM69 radio settings
|
||||
//#define MY_RADIO_RFM69
|
||||
//#define MY_RFM69_FREQUENCY RF69_868MHZ
|
||||
//#define MY_IS_RFM69HW
|
||||
//#define MY_DEBUG_VERBOSE_RFM69
|
||||
//#define MY_RFM69_NEW_DRIVER
|
||||
//#define MY_RFM69_ENABLE_ENCRYPTION
|
||||
//#define MY_RFM69_NETWORKID 100
|
||||
//#define MY_RF69_IRQ_PIN D1
|
||||
//#define MY_RF69_IRQ_NUM MY_RF69_IRQ_PIN
|
||||
//#define MY_RF69_SPI_CS D2
|
||||
|
||||
/**********************************
|
||||
* MySensors gateway configuration
|
||||
*/
|
||||
// Common gateway settings
|
||||
#define MY_REPEATER_FEATURE
|
||||
|
||||
// Serial gateway settings
|
||||
#define MY_GATEWAY_SERIAL
|
||||
|
||||
// Ethernet gateway settings
|
||||
//#define MY_GATEWAY_W5100
|
||||
|
||||
// ESP8266 gateway settings
|
||||
//#define MY_GATEWAY_ESP8266
|
||||
//#define MY_ESP8266_SSID ""
|
||||
//#define MY_ESP8266_PASSWORD ""
|
||||
|
||||
// Gateway networking settings
|
||||
//#define MY_IP_ADDRESS 192,168,178,87
|
||||
//#define MY_IP_GATEWAY_ADDRESS 192,168,178,1
|
||||
//#define MY_IP_SUBNET_ADDRESS 255,255,255,0
|
||||
//#define MY_PORT 5003
|
||||
//#define MY_GATEWAY_MAX_CLIENTS 2
|
||||
//#define MY_USE_UDP
|
||||
|
||||
// Gateway MQTT settings
|
||||
//#define MY_GATEWAY_MQTT_CLIENT
|
||||
//#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68
|
||||
//#define MY_PORT 1883
|
||||
//#define MY_MQTT_USER "username"
|
||||
//#define MY_MQTT_PASSWORD "password"
|
||||
//#define MY_MQTT_CLIENT_ID "mysensors-1"
|
||||
//#define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
|
||||
//#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
|
||||
|
||||
// Gateway inclusion mode
|
||||
//#define MY_INCLUSION_MODE_FEATURE
|
||||
//#define MY_INCLUSION_BUTTON_FEATURE
|
||||
//#define MY_INCLUSION_MODE_DURATION 60
|
||||
//#define MY_DEFAULT_LED_BLINK_PERIOD 300
|
||||
|
||||
// Gateway Leds settings
|
||||
//#define MY_DEFAULT_ERR_LED_PIN 4
|
||||
//#define MY_DEFAULT_RX_LED_PIN 5
|
||||
//#define MY_DEFAULT_TX_LED_PIN 6
|
||||
|
||||
/***********************************
|
||||
* NodeManager configuration
|
||||
*/
|
||||
|
||||
// if enabled, enable debug messages on serial port
|
||||
#define DEBUG 1
|
||||
|
||||
// if enabled, enable the capability to power on sensors with the arduino's pins to save battery while sleeping
|
||||
#define POWER_MANAGER 0
|
||||
// if enabled, will load the battery manager library to allow the battery level to be reported automatically or on demand
|
||||
#define BATTERY_MANAGER 0
|
||||
// if enabled, allow modifying the configuration remotely by interacting with the configuration child id
|
||||
#define REMOTE_CONFIGURATION 1
|
||||
// if enabled, persist the remote configuration settings on EEPROM
|
||||
#define PERSIST 1
|
||||
// if enabled, a battery sensor will be created at BATTERY_CHILD_ID and will report vcc voltage together with the battery level percentage
|
||||
#define BATTERY_SENSOR 0
|
||||
// if enabled, send a SLEEPING and AWAKE service messages just before entering and just after leaving a sleep cycle and STARTED when starting/rebooting
|
||||
#define SERVICE_MESSAGES 0
|
||||
|
||||
// Enable this module to use one of the following sensors: SENSOR_ANALOG_INPUT, SENSOR_LDR, SENSOR_THERMISTOR, SENSOR_MQ, SENSOR_ML8511, SENSOR_ACS712, SENSOR_RAIN_GAUGE
|
||||
#define MODULE_ANALOG_INPUT 0
|
||||
// Enable this module to use one of the following sensors: SENSOR_DIGITAL_INPUT
|
||||
#define MODULE_DIGITAL_INPUT 0
|
||||
// Enable this module to use one of the following sensors: SENSOR_DIGITAL_OUTPUT, SENSOR_RELAY, SENSOR_LATCHING_RELAY
|
||||
#define MODULE_DIGITAL_OUTPUT 0
|
||||
// Enable this module to use one of the following sensors: SENSOR_DHT11, SENSOR_DHT22
|
||||
#define MODULE_DHT 0
|
||||
// Enable this module to use one of the following sensors: SENSOR_SHT21
|
||||
#define MODULE_SHT21 0
|
||||
// Enable this module to use one of the following sensors: SENSOR_SWITCH, SENSOR_DOOR, SENSOR_MOTION
|
||||
#define MODULE_SWITCH 0
|
||||
// Enable this module to use one of the following sensors: SENSOR_DS18B20
|
||||
#define MODULE_DS18B20 0
|
||||
// Enable this module to use one of the following sensors: SENSOR_BH1750
|
||||
#define MODULE_BH1750 0
|
||||
// Enable this module to use one of the following sensors: SENSOR_MLX90614
|
||||
#define MODULE_MLX90614 0
|
||||
// Enable this module to use one of the following sensors: SENSOR_BME280
|
||||
#define MODULE_BME280 0
|
||||
// Enable this module to use one of the following sensors: SENSOR_SONOFF
|
||||
#define MODULE_SONOFF 0
|
||||
// Enable this module to use one of the following sensors: SENSOR_BMP085
|
||||
#define MODULE_BMP085 0
|
||||
// Enable this module to use one of the following sensors: SENSOR_HCSR04
|
||||
#define MODULE_HCSR04 0
|
||||
// Enable this module to use one of the following sensors: SENSOR_MCP9808
|
||||
#define MODULE_MCP9808 0
|
||||
#endif
|
||||
|
||||
|
|
@ -1,71 +1,89 @@
|
|||
/*
|
||||
NodeManager is intended to take care on your behalf of all those common tasks a MySensors node has to accomplish, speeding up the development cycle of your projects.
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ArduinoGateway prints data received from sensors on the serial link.
|
||||
* The gateway accepts input on seral which will be sent out on radio network.
|
||||
*
|
||||
* The GW code is designed for Arduino Nano 328p / 16MHz
|
||||
*
|
||||
* Wire connections (OPTIONAL):
|
||||
* - Inclusion button should be connected between digital pin 3 and GND
|
||||
* - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
|
||||
*
|
||||
* LEDs (OPTIONAL):
|
||||
* - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs
|
||||
* - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
|
||||
* - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
|
||||
* - ERR (red) - fast blink on error during transmission error or recieve crc error
|
||||
*
|
||||
*/
|
||||
|
||||
NodeManager includes the following main components:
|
||||
- Sleep manager: allows managing automatically the complexity behind battery-powered sensors spending most of their time sleeping
|
||||
- Power manager: allows powering on your sensors only while the node is awake
|
||||
- Battery manager: provides common functionalities to read and report the battery level
|
||||
- Remote configuration: allows configuring remotely the node without the need to have physical access to it
|
||||
- Built-in personalities: for the most common sensors, provide embedded code so to allow their configuration with a single line
|
||||
|
||||
Documentation available on: https://github.com/mysensors/NodeManager
|
||||
*/
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
|
||||
//#define MY_RF24_PA_LEVEL RF24_PA_LOW
|
||||
|
||||
// Enable serial gateway
|
||||
#define MY_GATEWAY_SERIAL
|
||||
|
||||
// Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
|
||||
#if F_CPU == 8000000L
|
||||
#define MY_BAUD_RATE 38400
|
||||
#endif
|
||||
|
||||
// Enable inclusion mode
|
||||
#define MY_INCLUSION_MODE_FEATURE
|
||||
// Enable Inclusion mode button on gateway
|
||||
//#define MY_INCLUSION_BUTTON_FEATURE
|
||||
|
||||
// Inverses behavior of inclusion button (if using external pullup)
|
||||
//#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
|
||||
|
||||
// Set inclusion mode duration (in seconds)
|
||||
#define MY_INCLUSION_MODE_DURATION 60
|
||||
// Digital pin used for inclusion mode button
|
||||
//#define MY_INCLUSION_MODE_BUTTON_PIN 3
|
||||
|
||||
// Set blinking period
|
||||
#define MY_DEFAULT_LED_BLINK_PERIOD 300
|
||||
|
||||
|
||||
// load user settings
|
||||
#include "config.h"
|
||||
// include supporting libraries
|
||||
// load MySensors library
|
||||
#include <MySensors.h>
|
||||
// load NodeManager library
|
||||
#include "NodeManager.h"
|
||||
|
||||
// create a NodeManager instance
|
||||
NodeManager nodeManager;
|
||||
|
||||
// before
|
||||
void before() {
|
||||
// setup the serial port baud rate
|
||||
Serial.begin(MY_BAUD_RATE);
|
||||
/*
|
||||
* Register below your sensors
|
||||
*/
|
||||
|
||||
/*
|
||||
* Register above your sensors
|
||||
*/
|
||||
nodeManager.before();
|
||||
void setup()
|
||||
{
|
||||
// Setup locally attached sensors
|
||||
sendSketchInfo("Controller", "1.1");
|
||||
}
|
||||
|
||||
// presentation
|
||||
void presentation() {
|
||||
// call NodeManager presentation routine
|
||||
nodeManager.presentation();
|
||||
void presentation()
|
||||
{
|
||||
// Present locally attached sensors
|
||||
}
|
||||
|
||||
// setup
|
||||
void setup() {
|
||||
// call NodeManager setup routine
|
||||
nodeManager.setup();
|
||||
void loop()
|
||||
{
|
||||
// Send locally attached sensor data here
|
||||
}
|
||||
|
||||
// loop
|
||||
void loop() {
|
||||
// call NodeManager loop routine
|
||||
nodeManager.loop();
|
||||
|
||||
}
|
||||
|
||||
// receive
|
||||
void receive(const MyMessage &message) {
|
||||
// call NodeManager receive routine
|
||||
nodeManager.receive(message);
|
||||
}
|
||||
|
||||
// receiveTime
|
||||
void receiveTime(unsigned long ts) {
|
||||
// call NodeManager receiveTime routine
|
||||
nodeManager.receiveTime(ts);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue