From 9944f4560398c0147040296a95f872a09ec2d7a1 Mon Sep 17 00:00:00 2001 From: Marcel Schulz Date: Tue, 21 Nov 2017 23:51:58 +0100 Subject: [PATCH] Changed the examples to run with the new lib architecture. Only some comments and the constructor to create a new networkDevice were changed. --- examples/BME280_Client/BME280_Client.ino | 9 ++++----- .../GettingStartedClient/GettingStartedClient.ino | 11 ++++------- .../GettingStartedMaster/GettingStartedMaster.ino | 13 +++++-------- .../UniversalSensorMaster/UniversalSensorMaster.ino | 12 +++++------- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/examples/BME280_Client/BME280_Client.ino b/examples/BME280_Client/BME280_Client.ino index 565eb2b..fb75c15 100644 --- a/examples/BME280_Client/BME280_Client.ino +++ b/examples/BME280_Client/BME280_Client.ino @@ -23,8 +23,6 @@ * https://github.com/sparkfun/SparkFun_BME280_Arduino_Library * * Step 4 - Run the project -* Open the file SBNetwork_config.h in the library folder ../libraries/SBNetwork/src/SBNetwork_config.h and comment out (put two // at the line start) the line 6. -* Line 6 should now look like this //#define RUN_AS_MASTER * Connect the Arduino via USB to the PC, select the right board and COM interface in the tools menu and run the project. */ @@ -38,9 +36,10 @@ //SBMacAddress deviceMac(0x01, 0x02, 0x03, 0x04, 0x05); SBMacAddress deviceMac(0x05, 0x04, 0x03, 0x02, 0x01); -// Create a new network device with Wemos D1 mini and set the _ce and _cs pin -//SBNetwork networkDevice(D2, D8); -SBNetwork networkDevice(6, 7); +// Create a new network device with Arduino and set the _ce and _cs pin +// The first argument defines the type of the device. false=master and true=client device +//SBNetwork networkDevice(false, D2, D8); +SBNetwork networkDevice(true, 6, 7); // time variables uint32_t wait = 20000; diff --git a/examples/GettingStartedClient/GettingStartedClient.ino b/examples/GettingStartedClient/GettingStartedClient.ino index ad42935..fb5791f 100644 --- a/examples/GettingStartedClient/GettingStartedClient.ino +++ b/examples/GettingStartedClient/GettingStartedClient.ino @@ -4,9 +4,7 @@ * See further library details on https://github.com/Schullebernd/SBNetwork * ************************************************************* * This Getting started is prepared for using it with a Arduino as a client device. -* If you want to use a Wemos, then change the line "SBNetwork networkDevice(6, 7);" to the correct pinout for a Wemos (D2, D8). -* To get shure, that the SBNetwork library is build for a Client-Device, open the SBNetwork_config.h in the libraries folder and get shure that line 6 is commented out. -* //#define RUN_AS_MASTER +* If you want to use a Wemos, then change the line 38 "SBNetwork networkDevice(true, 6, 7);" to the correct pinout for a Wemos "SBNetwork networkDevice(true, D2, D8);". * ************************************************************** * Step 1 - Prepare your device * Connect a nRF24L01 transmitter to the Arduino or to a Wemos D1 mini. @@ -21,8 +19,6 @@ * D5 > SCK 13 > SCK * * Step 2 - Build the sketch for the client device -* Open the file SBNetwork_config.h in the library folder ../libraries/SBNetwork/src/SBNetwork_config.h and comment out (put two // at the line start) the line 6. -* Line 6 should now look like this //#define RUN_AS_MASTER * Connect the Arduino via USB to the PC, select the right board and COM interface in the tools menu and run the project. * After building and loading up to the Arduino, the serial monitor should show some log data. * If you already run a master device you should now see the pairing process in the serial montor for both devices. @@ -37,8 +33,9 @@ SBMacAddress deviceMac(0x05, 0x04, 0x03, 0x02, 0x01); // Create a new network device with Wemos D1 mini and set the _ce and _cs pin -//SBNetwork networkDevice(D2, D8); -SBNetwork networkDevice(6, 7); +// The first argument defines the type of the device. false=master and true=client device +//SBNetwork networkDevice(false, D2, D8); +SBNetwork networkDevice(true, 6, 7); void setup() { diff --git a/examples/GettingStartedMaster/GettingStartedMaster.ino b/examples/GettingStartedMaster/GettingStartedMaster.ino index 9baca04..f676b79 100644 --- a/examples/GettingStartedMaster/GettingStartedMaster.ino +++ b/examples/GettingStartedMaster/GettingStartedMaster.ino @@ -4,9 +4,7 @@ * See further library details on https://github.com/Schullebernd/SBNetwork * ************************************************************* * This Getting started is prepared for using it with a Wemos D1 mini as a master device. -* If you want to use an Arduino, then change the line "SBNetwork networkDevice(D2, D8);" to the correct pinout for an Arduino (6,7). -* To get shure, that the SBNetwork library is build for a Master-Device open the SBNetwork_config.h in the libraries folder and get shure that line 6 is not commented out. -* #define RUN_AS_MASTER +* If you want to use an Arduino, then change the line 38 "SBNetwork networkDevice(false, D2, D8);" to the correct pinout for an Arduino "SBNetwork networkDevice(false, 6, 7);". * ************************************************************** * Step 1 - Prepare your device * Connect a nRF24L01 transmitter to a Wemos D1 mini or an Arduino Device @@ -21,8 +19,6 @@ * D5 > SCK 13 > SCK * * Step 2 - Build the sketch for the master device -* Open the file SBNetwork_config.h in the library folder ../libraries/SBNetwork/src/SBNetwork_config.h and comment out (put two // at the line start) the line 6. -* Line 6 should now look like this //#define RUN_AS_MASTER * Connect the Wemos via USB to the PC, select the right board and COM interface in the tools menu and run the project. * After building and loading up to the Wemos, the serial monitor should show some log data. * @@ -38,8 +34,9 @@ SBMacAddress deviceMac(0x01, 0x02, 0x03, 0x04, 0x05); //SBMacAddress deviceMac(0x05, 0x04, 0x03, 0x02, 0x01); // Create a new network device with Wemos D1 mini and set the _ce and _cs pin. -SBNetwork networkDevice(D2, D8); -//SBNetwork networkDevice(6, 7); +// The first argument defines the type of the device. false=master and true=client device +SBNetwork networkDevice(false, D2, D8); +//SBNetwork networkDevice(true, 6, 7); void setup() { // Init serial connection @@ -76,6 +73,6 @@ void loop() { // If the master has received a message, it will sent a message to the sender if (networkDevice.available()) { char* message = "Hello client, yes I can hear you well!"; - networkDevice.sendToDevice(networkDevice._MasterStorage.Slaves[0], message, strlen(message) + 1); + networkDevice.sendToDevice(networkDevice.MasterStorage.Slaves[0], message, strlen(message) + 1); } } // Loop diff --git a/examples/UniversalSensorMaster/UniversalSensorMaster.ino b/examples/UniversalSensorMaster/UniversalSensorMaster.ino index 17eee16..0a245b1 100644 --- a/examples/UniversalSensorMaster/UniversalSensorMaster.ino +++ b/examples/UniversalSensorMaster/UniversalSensorMaster.ino @@ -4,9 +4,8 @@ * See further library details on https://github.com/Schullebernd/SBNetwork * ************************************************************* * This Getting started is prepared for using it with a Wemos D1 mini as a master device. -* If you want to use an Arduino, then change the line 39 "SBNetwork networkDevice(D2, D8);" to the correct pinout for an Arduino (6,7). -* To get shure, that the SBNetwork library is build for a Master-Device open the SBNetwork_config.h in the libraries folder and get shure that line 6 is not commented out. -* #define RUN_AS_MASTER +* If you want to use an Arduino, then change the line 39 "SBNetwork networkDevice(false, D2, D8);" to the correct pinout for an Arduino "SBNetwork networkDevice(false, 6, 7)". +* * ************************************************************** * Step 1 - Prepare your device * Connect a nRF24L01 transmitter to a Wemos D1 mini or an Arduino Device @@ -21,8 +20,6 @@ * D5 > SCK 13 > SCK * * Step 2 - Build the sketch for the master device -* Open the file SBNetwork_config.h in the library folder ../libraries/SBNetwork/src/SBNetwork_config.h and comment out (put two // at the line start) the line 6. -* Line 6 should now look like this //#define RUN_AS_MASTER * Connect the Wemos via USB to the PC, select the right board and COM interface in the tools menu and run the project. * After building and loading up to the Wemos, the serial monitor should show some log data. */ @@ -36,8 +33,9 @@ SBMacAddress deviceMac(0x01, 0x02, 0x03, 0x04, 0x05); //SBMacAddress deviceMac(0x05, 0x04, 0x03, 0x02, 0x01); // Create a new network device with Wemos D1 mini and set the _ce and _cs pin. -SBNetwork networkDevice(D2, D8); -//SBNetwork networkDevice(6, 7); +// The first argument defines the type of the device. false=master and true=client device +SBNetwork networkDevice(false, D2, D8); +//SBNetwork networkDevice(true, 6, 7); void setup() { // Init serial connection