Changed the examples to run with the new lib architecture. Only some comments and the constructor to create a new networkDevice were changed.

This commit is contained in:
Marcel Schulz 2017-11-21 23:51:58 +01:00
parent a99d91c30b
commit 9944f45603
4 changed files with 18 additions and 27 deletions

View File

@ -23,8 +23,6 @@
* https://github.com/sparkfun/SparkFun_BME280_Arduino_Library * https://github.com/sparkfun/SparkFun_BME280_Arduino_Library
* *
* Step 4 - Run the project * 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. * 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(0x01, 0x02, 0x03, 0x04, 0x05);
SBMacAddress deviceMac(0x05, 0x04, 0x03, 0x02, 0x01); SBMacAddress deviceMac(0x05, 0x04, 0x03, 0x02, 0x01);
// Create a new network device with Wemos D1 mini and set the _ce and _cs pin // Create a new network device with Arduino and set the _ce and _cs pin
//SBNetwork networkDevice(D2, D8); // The first argument defines the type of the device. false=master and true=client device
SBNetwork networkDevice(6, 7); //SBNetwork networkDevice(false, D2, D8);
SBNetwork networkDevice(true, 6, 7);
// time variables // time variables
uint32_t wait = 20000; uint32_t wait = 20000;

View File

@ -4,9 +4,7 @@
* See further library details on https://github.com/Schullebernd/SBNetwork * 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. * 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). * 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);".
* 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
* ************************************************************** * **************************************************************
* Step 1 - Prepare your device * Step 1 - Prepare your device
* Connect a nRF24L01 transmitter to the Arduino or to a Wemos D1 mini. * Connect a nRF24L01 transmitter to the Arduino or to a Wemos D1 mini.
@ -21,8 +19,6 @@
* D5 > SCK 13 > SCK * D5 > SCK 13 > SCK
* *
* Step 2 - Build the sketch for the client device * 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. * 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. * 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. * 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); SBMacAddress deviceMac(0x05, 0x04, 0x03, 0x02, 0x01);
// Create a new network device with Wemos D1 mini and set the _ce and _cs pin // Create a new network device with Wemos D1 mini and set the _ce and _cs pin
//SBNetwork networkDevice(D2, D8); // The first argument defines the type of the device. false=master and true=client device
SBNetwork networkDevice(6, 7); //SBNetwork networkDevice(false, D2, D8);
SBNetwork networkDevice(true, 6, 7);
void setup() { void setup() {

View File

@ -4,9 +4,7 @@
* See further library details on https://github.com/Schullebernd/SBNetwork * 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. * 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). * 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);".
* 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
* ************************************************************** * **************************************************************
* Step 1 - Prepare your device * Step 1 - Prepare your device
* Connect a nRF24L01 transmitter to a Wemos D1 mini or an Arduino Device * Connect a nRF24L01 transmitter to a Wemos D1 mini or an Arduino Device
@ -21,8 +19,6 @@
* D5 > SCK 13 > SCK * D5 > SCK 13 > SCK
* *
* Step 2 - Build the sketch for the master device * 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. * 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. * 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); //SBMacAddress deviceMac(0x05, 0x04, 0x03, 0x02, 0x01);
// Create a new network device with Wemos D1 mini and set the _ce and _cs pin. // Create a new network device with Wemos D1 mini and set the _ce and _cs pin.
SBNetwork networkDevice(D2, D8); // The first argument defines the type of the device. false=master and true=client device
//SBNetwork networkDevice(6, 7); SBNetwork networkDevice(false, D2, D8);
//SBNetwork networkDevice(true, 6, 7);
void setup() { void setup() {
// Init serial connection // 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 the master has received a message, it will sent a message to the sender
if (networkDevice.available()) { if (networkDevice.available()) {
char* message = "Hello client, yes I can hear you well!"; 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 } // Loop

View File

@ -4,9 +4,8 @@
* See further library details on https://github.com/Schullebernd/SBNetwork * 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. * 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). * 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)".
* 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
* ************************************************************** * **************************************************************
* Step 1 - Prepare your device * Step 1 - Prepare your device
* Connect a nRF24L01 transmitter to a Wemos D1 mini or an Arduino Device * Connect a nRF24L01 transmitter to a Wemos D1 mini or an Arduino Device
@ -21,8 +20,6 @@
* D5 > SCK 13 > SCK * D5 > SCK 13 > SCK
* *
* Step 2 - Build the sketch for the master device * 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. * 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. * 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); //SBMacAddress deviceMac(0x05, 0x04, 0x03, 0x02, 0x01);
// Create a new network device with Wemos D1 mini and set the _ce and _cs pin. // Create a new network device with Wemos D1 mini and set the _ce and _cs pin.
SBNetwork networkDevice(D2, D8); // The first argument defines the type of the device. false=master and true=client device
//SBNetwork networkDevice(6, 7); SBNetwork networkDevice(false, D2, D8);
//SBNetwork networkDevice(true, 6, 7);
void setup() { void setup() {
// Init serial connection // Init serial connection