Added code to output configuration log and error messages
Config Log is output if logLevel>1 OR there is a fatal error in configuration
This commit is contained in:
parent
1d6f07a400
commit
db620e497e
|
|
@ -79,6 +79,16 @@ void Span::poll() {
|
||||||
|
|
||||||
if(!isInitialized){
|
if(!isInitialized){
|
||||||
|
|
||||||
|
if(logLevel>1 || isFatalError){
|
||||||
|
Serial.print(configLog);
|
||||||
|
Serial.print("\n*** End Config Log ***\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isFatalError){
|
||||||
|
Serial.print("\n*** PROGRAM HALTED DUE TO FATAL ERRORS IN CONFIGURATION! ***\n\n");
|
||||||
|
while(1);
|
||||||
|
}
|
||||||
|
|
||||||
Serial.print("\n");
|
Serial.print("\n");
|
||||||
|
|
||||||
nvs_flash_init(); // initialize non-volatile-storage partition in flash
|
nvs_flash_init(); // initialize non-volatile-storage partition in flash
|
||||||
|
|
@ -919,6 +929,8 @@ SpanAccessory::SpanAccessory(){
|
||||||
|
|
||||||
homeSpan.Accessories.push_back(this);
|
homeSpan.Accessories.push_back(this);
|
||||||
aid=homeSpan.Accessories.size();
|
aid=homeSpan.Accessories.size();
|
||||||
|
|
||||||
|
homeSpan.configLog+="+Accessory " + String(aid) + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
@ -948,16 +960,17 @@ SpanService::SpanService(const char *type, const char *hapName){
|
||||||
this->type=type;
|
this->type=type;
|
||||||
this->hapName=hapName;
|
this->hapName=hapName;
|
||||||
|
|
||||||
|
homeSpan.configLog+="-->Service " + String(hapName);
|
||||||
|
|
||||||
if(homeSpan.Accessories.empty()){
|
if(homeSpan.Accessories.empty()){
|
||||||
Serial.print("*** FATAL ERROR: Can't create new Service '");
|
homeSpan.configLog+=" *** ERROR! Missing Accessory! ***\n";
|
||||||
Serial.print(hapName);
|
homeSpan.isFatalError=true;
|
||||||
Serial.print("' without a defined Accessory. Program halted!\n\n");
|
return;
|
||||||
while(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
homeSpan.configLog+="\n";
|
||||||
homeSpan.Accessories.back()->Services.push_back(this);
|
homeSpan.Accessories.back()->Services.push_back(this);
|
||||||
iid=++(homeSpan.Accessories.back()->iidCount);
|
iid=++(homeSpan.Accessories.back()->iidCount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
@ -1009,20 +1022,21 @@ SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, char *hapName)
|
||||||
this->perms=perms;
|
this->perms=perms;
|
||||||
this->hapName=hapName;
|
this->hapName=hapName;
|
||||||
|
|
||||||
|
homeSpan.configLog+="---->Characteristic " + String(hapName);
|
||||||
|
|
||||||
if(homeSpan.Accessories.empty() || homeSpan.Accessories.back()->Services.empty()){
|
if(homeSpan.Accessories.empty() || homeSpan.Accessories.back()->Services.empty()){
|
||||||
Serial.print("*** FATAL ERROR: Can't create new Characteristic '");
|
homeSpan.configLog+=" *** ERROR! Missing Service! ***\n";
|
||||||
Serial.print(hapName);
|
homeSpan.isFatalError=true;
|
||||||
Serial.print("' without a defined Service. Program halted!\n\n");
|
return;
|
||||||
while(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
homeSpan.configLog+="\n";
|
||||||
homeSpan.Accessories.back()->Services.back()->Characteristics.push_back(this);
|
homeSpan.Accessories.back()->Services.back()->Characteristics.push_back(this);
|
||||||
iid=++(homeSpan.Accessories.back()->iidCount);
|
iid=++(homeSpan.Accessories.back()->iidCount);
|
||||||
service=homeSpan.Accessories.back()->Services.back();
|
service=homeSpan.Accessories.back()->Services.back();
|
||||||
aid=homeSpan.Accessories.back()->aid;
|
aid=homeSpan.Accessories.back()->aid;
|
||||||
|
|
||||||
ev=(boolean *)calloc(homeSpan.maxConnections,sizeof(boolean));
|
ev=(boolean *)calloc(homeSpan.maxConnections,sizeof(boolean));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,8 @@ struct Span{
|
||||||
char category[3]=""; // category ID of primary accessory - broadcast as Bonjour field "ci" (HAP Section 13)
|
char category[3]=""; // category ID of primary accessory - broadcast as Bonjour field "ci" (HAP Section 13)
|
||||||
unsigned long snapTime; // current time (in millis) snapped before entering Service loops() or updates()
|
unsigned long snapTime; // current time (in millis) snapped before entering Service loops() or updates()
|
||||||
boolean isInitialized=false; // flag indicating HomeSpan has been initialized
|
boolean isInitialized=false; // flag indicating HomeSpan has been initialized
|
||||||
|
boolean isFatalError=false; // flag indicating a fatal error in user-defined configuration
|
||||||
|
String configLog="*** Config Log ***\n\n"; // log of configuration process, including any errors
|
||||||
|
|
||||||
char *defaultSetupCode=DEFAULT_SETUP_CODE; // Setup Code used for pairing
|
char *defaultSetupCode=DEFAULT_SETUP_CODE; // Setup Code used for pairing
|
||||||
uint8_t statusPin=DEFAULT_STATUS_PIN; // pin for status LED
|
uint8_t statusPin=DEFAULT_STATUS_PIN; // pin for status LED
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,12 @@ void setup() {
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
homeSpan.setLogLevel(2);
|
||||||
|
|
||||||
homeSpan.begin(Category::Lighting,"HomeSpan Benchmark");
|
homeSpan.begin(Category::Lighting,"HomeSpan Benchmark");
|
||||||
|
|
||||||
new SpanAccessory(); // Begin by creating a new Accessory using SpanAccessory(), which takes no arguments
|
new SpanAccessory(); // Begin by creating a new Accessory using SpanAccessory(), which takes no arguments
|
||||||
|
|
||||||
new Characteristic::Model("HSL Test"); // Model of the Accessory (arbitrary text string, and can be the same for every Accessory)
|
|
||||||
|
|
||||||
new Service::AccessoryInformation(); // HAP requires every Accessory to implement an AccessoryInformation Service, which has 6 required Characteristics
|
new Service::AccessoryInformation(); // HAP requires every Accessory to implement an AccessoryInformation Service, which has 6 required Characteristics
|
||||||
new Characteristic::Name("HomeSpan Test"); // Name of the Accessory, which shows up on the HomeKit "tiles", and should be unique across Accessories
|
new Characteristic::Name("HomeSpan Test"); // Name of the Accessory, which shows up on the HomeKit "tiles", and should be unique across Accessories
|
||||||
new Characteristic::Manufacturer("HomeSpan"); // Manufacturer of the Accessory (arbitrary text string, and can be the same for every Accessory)
|
new Characteristic::Manufacturer("HomeSpan"); // Manufacturer of the Accessory (arbitrary text string, and can be the same for every Accessory)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue