Updated serial gateway
This commit is contained in:
parent
79e5557907
commit
c977fde48a
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
#define SKETCH_NAME "Serial gateway"
|
||||
#define SKETCH_VERSION "1.0"
|
||||
#define SKETCH_VERSION "1.1"
|
||||
|
||||
/**********************************
|
||||
* MySensors node configuration
|
||||
|
|
@ -15,13 +15,15 @@
|
|||
// General settings
|
||||
#define MY_BAUD_RATE 9600
|
||||
#define MY_DEBUG
|
||||
//#define MY_NODE_ID 100
|
||||
//#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 RF24_PA_HIGH
|
||||
#define MY_RF24_PA_LEVEL_GW RF24_PA_HIGH
|
||||
|
||||
//#define MY_DEBUG_VERBOSE_RF24
|
||||
|
||||
// RFM69 radio settings
|
||||
|
|
@ -40,7 +42,7 @@
|
|||
* MySensors gateway configuration
|
||||
*/
|
||||
// Common gateway settings
|
||||
//#define MY_REPEATER_FEATURE
|
||||
#define MY_REPEATER_FEATURE
|
||||
|
||||
// Serial gateway settings
|
||||
#define MY_GATEWAY_SERIAL
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
This directory is intended for the project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link to executable file.
|
||||
|
||||
The source code of each library should be placed in separate directory, like
|
||||
"lib/private_lib/[here are source files]".
|
||||
|
||||
For example, see how can be organized `Foo` and `Bar` libraries:
|
||||
|
||||
|--lib
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |- readme.txt --> THIS FILE
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
Then in `src/main.c` you should use:
|
||||
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
// rest H/C/CPP code
|
||||
|
||||
PlatformIO will find your libraries automatically, configure preprocessor's
|
||||
include paths and build them.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- http://docs.platformio.org/page/librarymanager/ldf.html
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
[env:pro8MHzatmega328]
|
||||
platform = atmelavr
|
||||
framework = arduino
|
||||
board = pro8MHzatmega328
|
||||
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
// Enable debug prints
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable passive mode
|
||||
#define MY_PASSIVE_NODE
|
||||
#define MY_REPEATER_FEATURE
|
||||
|
||||
// Passive mode requires static node ID
|
||||
#define MY_NODE_ID 100
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
#define MY_RF24_PA_LEVEL RF24_PA_HIGH
|
||||
|
||||
//#define MY_RADIO_NRF5_ESB
|
||||
//#define MY_RADIO_RFM69
|
||||
//#define MY_RADIO_RFM95
|
||||
|
||||
#include <MySensors.h>
|
||||
|
||||
#define CHILD_ID 0 // Id of the sensor child
|
||||
|
||||
// Initialize general message
|
||||
MyMessage msg(CHILD_ID, V_TEMP);
|
||||
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void presentation()
|
||||
{
|
||||
// Send the sketch version information to the gateway and controller
|
||||
sendSketchInfo("Passive node", "1.0");
|
||||
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
present(CHILD_ID, S_TEMP);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// generate some random data
|
||||
send(msg.set(25.0+random(0,30)/10.0,2));
|
||||
wait(10000);
|
||||
}
|
||||
Loading…
Reference in New Issue