Skip to content

Commit 7f9fd84

Browse files
committed
Merge pull request #160 from TD22057/master
Updated mock sensor code to newer hardware and radio API.
2 parents fbec4a4 + 5b3e955 commit 7f9fd84

File tree

1 file changed

+44
-17
lines changed

1 file changed

+44
-17
lines changed

libraries/MySensors/examples/MockMySensors/MockMySensors.ino

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66
* Barduino 2015
77
*/
88

9+
#include <MySigningNone.h>
10+
#include <MyTransportRFM69.h>
11+
#include <MyTransportNRF24.h>
12+
#include <MyHwATMega328.h>
13+
#include <MySigningAtsha204Soft.h>
14+
#include <MySigningAtsha204.h>
15+
916
#include <SPI.h>
1017
#include <MySensor.h>
18+
#include <MyMessage.h>
1119

12-
// SPI Pins
13-
#define CE_PIN 9
14-
#define CS_PIN 10
20+
#define RADIO_ERROR_LED_PIN 4 // Error led pin
21+
#define RADIO_RX_LED_PIN 6 // Receive led pin
22+
#define RADIO_TX_LED_PIN 5 // the PCB, on board LED
1523

1624
// Wait times
1725
#define LONG_WAIT 500
@@ -30,7 +38,10 @@
3038
////#define ID_S_ARDUINO_NODE //auto defined in initialization
3139
////#define ID_S_ARDUINO_REPEATER_NODE //auto defined in initialization
3240

33-
//#define ID_S_DOOR 1
41+
// Some of these ID's have not been updated for v1.5. Uncommenting too many of them
42+
// will make the sketch too large for a pro mini's memory so it's probably best to try
43+
// one at a time.
44+
#define ID_S_DOOR 1
3445
//#define ID_S_MOTION 2
3546
//#define ID_S_SMOKE 3
3647
//#define ID_S_LIGHT 4
@@ -43,26 +54,42 @@
4354
//#define ID_S_RAIN 11
4455
//#define ID_S_UV 12
4556
//#define ID_S_WEIGHT 13
46-
#define ID_S_POWER 14
47-
#define ID_S_HEATER 15
48-
#define ID_S_DISTANCE 16
49-
#define ID_S_LIGHT_LEVEL 17
50-
#define ID_S_LOCK 18
51-
#define ID_S_IR 19
52-
#define ID_S_WATER 20
53-
#define ID_S_AIR_QUALITY 21
54-
#define ID_S_DUST 22
55-
#define ID_S_SCENE_CONTROLLER 23
56-
57-
#define ID_S_CUSTOM 24
57+
//#define ID_S_POWER 14
58+
//#define ID_S_HEATER 15
59+
//#define ID_S_DISTANCE 16
60+
//#define ID_S_LIGHT_LEVEL 17
61+
//#define ID_S_LOCK 18
62+
//#define ID_S_IR 19
63+
//#define ID_S_WATER 20
64+
//#define ID_S_AIR_QUALITY 21
65+
//#define ID_S_DUST 22
66+
//#define ID_S_SCENE_CONTROLLER 23
67+
//#define ID_S_CUSTOM 24
5868

5969
// Global Vars
6070
unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds)
6171
boolean metric = true;
6272
long randNumber;
6373

6474
// Instanciate MySersors Gateway
65-
MySensor gw(CE_PIN,CS_PIN);
75+
MyTransportNRF24 transport(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
76+
//MyTransportRFM69 transport;
77+
78+
// Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
79+
//MySigningNone signer;
80+
//MySigningAtsha204Soft signer;
81+
//MySigningAtsha204 signer;
82+
83+
// Hardware profile
84+
MyHwATMega328 hw;
85+
86+
// Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
87+
// To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h
88+
#ifdef WITH_LEDS_BLINKING
89+
MySensor gw(transport, hw /*, signer*/, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
90+
#else
91+
MySensor gw(transport, hw /*, signer*/);
92+
#endif
6693

6794
//Instanciate Messages objects
6895

0 commit comments

Comments
 (0)