Skip to content

Commit

Permalink
add while(!Serial) and if(!mesh.begin())
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Jun 14, 2021
1 parent 76f99b0 commit 2e76b79
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 24 deletions.
19 changes: 11 additions & 8 deletions examples/RF24Mesh_Example/RF24Mesh_Example.ino
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,21 @@ struct payload_t {
void setup() {

Serial.begin(115200);
//printf_begin();
while (!Serial) {
// some boards need this because of native USB capability
}

// Set the nodeID manually
mesh.setNodeID(nodeID);

// Connect to the mesh
Serial.println(F("Connecting to the mesh..."));
mesh.begin();
if (!mesh.begin()) {
Serial.println(F("Radio hardware not responding or could not connect to network."));
while (1) {
// hold in an infinite loop
}
}
}


Expand Down Expand Up @@ -89,9 +98,3 @@ void loop() {
Serial.println(payload.ms);
}
}






10 changes: 9 additions & 1 deletion examples/RF24Mesh_Example_Master/RF24Mesh_Example_Master.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,20 @@ uint32_t displayTimer = 0;

void setup() {
Serial.begin(115200);
while (!Serial) {
// some boards need this because of native USB capability
}

// Set the nodeID to 0 for the master node
mesh.setNodeID(0);
Serial.println(mesh.getNodeID());
// Connect to the mesh
mesh.begin();
if (!mesh.begin()) {
Serial.println(F("Radio hardware not responding or could not connect to network."));
while (1) {
// hold in an infinite loop
}
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@ RF24Mesh mesh(radio, network);

void setup() {
Serial.begin(115200);
while (!Serial) {
// some boards need this because of native USB capability
}

// Set the nodeID to 0 for the master node
mesh.setNodeID(0);
Serial.println(mesh.getNodeID());
// Connect to the mesh
mesh.begin();
if (!mesh.begin()) {
Serial.println(F("Radio hardware not responding or could not connect to network."));
while (1) {
// hold in an infinite loop
}
}

// In this case, assign a static address to nodeIDs 23,24 at RF24Network address 02 && 03
// This will prevent this master node from assigning the address to another node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@ uint32_t ctr = 0;

void setup() {
Serial.begin(115200);
while (!Serial) {
// some boards need this because of native USB capability
}

// Set the nodeID to 0 for the master node
mesh.setNodeID(0);
Serial.println(mesh.getNodeID());
// Connect to the mesh
mesh.begin();
if (!mesh.begin()) {
Serial.println(F("Radio hardware not responding or could not connect to network."));
while (1) {
// hold in an infinite loop
}
}

}

Expand Down
13 changes: 11 additions & 2 deletions examples/RF24Mesh_Example_Node2Node/RF24Mesh_Example_Node2Node.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,21 @@ uint32_t millisTimer = 0;
void setup() {

Serial.begin(115200);
while (!Serial) {
// some boards need this because of native USB capability
}

// Set the nodeID
mesh.setNodeID(nodeID);

// Connect to the mesh
Serial.println(F("Connecting to the mesh..."));
mesh.begin();
if (!mesh.begin()) {
Serial.println(F("Radio hardware not responding or could not connect to network."));
while (1) {
// hold in an infinite loop
}
}
}


Expand Down Expand Up @@ -78,4 +88,3 @@ void loop() {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,21 @@ uint32_t delayTime = 120;
void setup() {

Serial.begin(115200);
//printf_begin();
while (!Serial) {
// some boards need this because of native USB capability
}

// Set the nodeID manually
mesh.setNodeID(nodeID);

// Connect to the mesh
Serial.println(F("Connecting to the mesh..."));
mesh.begin();
if (!mesh.begin()) {
Serial.println(F("Radio hardware not responding or could not connect to network."));
while (1) {
// hold in an infinite loop
}
}
}

unsigned int sizeCtr = 2;
Expand Down
11 changes: 9 additions & 2 deletions examples/RF24Mesh_SerialConfig/RF24Mesh_SerialConfig.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ RF24Mesh mesh(radio, network);
void setup() {

Serial.begin(115200);
printf_begin();
while (!Serial) {
// some boards need this because of native USB capability
}

// If this is a new node, the nodeID will return 0. Once the node is configured with an ID other than 0, this
// bit will no longer run.
Expand All @@ -46,7 +48,12 @@ void setup() {
}

// Now that this node has a unique ID, connect to the mesh
mesh.begin();
if (!mesh.begin()) {
Serial.println(F("Radio hardware not responding or could not connect to network."));
while (1) {
// hold in an infinite loop
}
}

}

Expand Down
5 changes: 4 additions & 1 deletion examples_RPi/RF24Mesh_Example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ int main(int argc, char **argv)
mesh.setNodeID(4);
// Connect to the mesh
printf("start nodeID %d\n", mesh.getNodeID());
mesh.begin();
if (!mesh.begin()) {
printf("Radio hardware not responding or could not connect to network.\n");
return 0;
}
radio.printDetails();

while (1)
Expand Down
6 changes: 4 additions & 2 deletions examples_RPi/RF24Mesh_Example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ def delay(ms):
sleep(ms / 1000.0)

# radio setup for RPi B Rev2: CS0=Pin 24
radio = RF24(22,0)
radio = RF24(22, 0)
network = RF24Network(radio)
mesh = RF24Mesh(radio, network)

mesh.setNodeID(4)
print("start nodeID", mesh.getNodeID())
mesh.begin()
if not mesh.begin():
print("Radio hardware not responding or could not connect to network.")
exit()
radio.setPALevel(RF24_PA_MAX) # Power Amplifier
radio.printDetails()

Expand Down
5 changes: 4 additions & 1 deletion examples_RPi/RF24Mesh_Example_Master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ int main(int argc, char **argv)
mesh.setNodeID(0);
// Connect to the mesh
printf("start\n");
mesh.begin();
if (!mesh.begin()) {
printf("Radio hardware not responding or could not connect to network.\n");
return 0;
}
radio.printDetails();

while (1)
Expand Down
4 changes: 3 additions & 1 deletion examples_RPi/RF24Mesh_Example_Master.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
mesh = RF24Mesh(radio, network)

mesh.setNodeID(0)
mesh.begin()
if not mesh.begin():
print("Radio hardware not responding or could not connect to network.")
exit()
radio.setPALevel(RF24_PA_MAX) # Power Amplifier
radio.printDetails()

Expand Down
7 changes: 5 additions & 2 deletions examples_RPi/ncurses/RF24Mesh_Ncurses_Master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

RF24 radio(22, 0);
RF24Network network(radio);
RF24Mesh mesh(radio,network);
RF24Mesh mesh(radio, network);

void printNodes(uint8_t boldID);
void pingNode(uint8_t listNo);
Expand All @@ -41,7 +41,10 @@ int main()

printf("Establishing mesh...\n");
mesh.setNodeID(0);
mesh.begin();
if (!mesh.begin()) {
printf("Radio hardware not responding or could not connect to network.\n");
return 0;
}
radio.printDetails();

initscr(); /* Start curses mode */
Expand Down

0 comments on commit 2e76b79

Please sign in to comment.