Minor changes and corrections in debug logs and example sketches.

This commit is contained in:
Marcel Schulz 2017-12-12 21:51:50 +01:00
parent 4815cc7f02
commit ce8133b817
3 changed files with 29 additions and 6 deletions

View File

@ -37,6 +37,10 @@ SBMacAddress deviceMac(0x05, 0x04, 0x03, 0x02, 0x01);
//SBNetwork networkDevice(false, D2, D8);
SBNetwork networkDevice(true, 6, 7);
// time variables
uint32_t wait = 4000;
uint32_t lastWait = wait;
void setup() {
Serial.begin(19200);
@ -44,11 +48,9 @@ void setup() {
// Initialize the network device
networkDevice.initialize(deviceMac);
}
// time variables
uint32_t wait = 4000;
uint32_t lastWait = wait;
lastWait = millis();
}
void loop() {

View File

@ -45,6 +45,9 @@ void setup() {
// Initialize the network device
networkDevice.initialize(deviceMac);
// Enables the master to automatically add new clients
networkDevice.enableAutomaticClientAdding(true);
Serial.println(F("*** PRESS 'N' to reset the device"));
}
@ -58,6 +61,20 @@ void loop() {
if (c == 'N') {
networkDevice.resetData();
}
if (c == 'E') {
// Only master should handle the switch of adding new clients
if (!networkDevice.RunAsClient) {
Serial.println("*****");
if (networkDevice.isAutomaticClientAddingEnabled()) {
Serial.println("Deactivating AutomaticClientAdding");
}
else {
Serial.println("Activating AutomaticClientAdding");
}
Serial.println("*****");
networkDevice.enableAutomaticClientAdding(!networkDevice.isAutomaticClientAddingEnabled());
}
}
}
// Call this in the loop() function to maintain the network device

View File

@ -176,7 +176,9 @@ bool SBNetwork::sendToDevice(SBMacAddress mac, void* message, uint8_t messageSiz
//Serial.print(F("Fragment count = "));
//Serial.println(fragmentCount, DEC);
for (uint8_t i = 0; i < fragmentCount; i++){
#if defined(_DEBUG)
Serial.print(".");
#endif
uint8_t buffer[32];
if (i != (fragmentCount - 1)){
memcpy(buffer, (uint8_t*)message + (i * maxPackageSize), maxPackageSize);
@ -193,11 +195,15 @@ bool SBNetwork::sendToDevice(SBMacAddress mac, void* message, uint8_t messageSiz
bool bSuccess = this->sendToDevice(frame);
if (!bSuccess){
#if defined(_DEBUG)
Serial.println(" Failed");
#endif
return false;
}
}
#if defined(_DEBUG)
Serial.println(" Done");
#endif
return true;
}
}
@ -396,14 +402,12 @@ bool SBNetwork::connectToNetwork(){
}
bool bMasterAvailable = this->pingDevice(this->NetworkDevice.MasterMAC);
#ifdef _DEBUG
if (bMasterAvailable) {
Serial.println(F("Done - Master available"));
}
else {
Serial.println(F("Failed - Master not responding"));
}
#endif
return bMasterAvailable;
}
else {