Continuing destructor code...
This commit is contained in:
parent
554cefd3ce
commit
05f1204b4f
|
|
@ -1581,13 +1581,17 @@ SpanService::SpanService(const char *type, const char *hapName, boolean isCustom
|
||||||
|
|
||||||
SpanService::~SpanService(){
|
SpanService::~SpanService(){
|
||||||
|
|
||||||
|
while(Characteristics.rbegin()!=Characteristics.rend()) // delete all Characteristics in this Service
|
||||||
|
delete *Characteristics.rbegin();
|
||||||
|
|
||||||
auto svc=accessory->Services.begin(); // find Service in containing Accessory vector and erase entry
|
auto svc=accessory->Services.begin(); // find Service in containing Accessory vector and erase entry
|
||||||
while((*svc)!=this)
|
while((*svc)!=this)
|
||||||
svc++;
|
svc++;
|
||||||
accessory->Services.erase(svc);
|
accessory->Services.erase(svc);
|
||||||
|
|
||||||
for(svc=homeSpan.Loops.begin(); (*svc)!=this && svc!=homeSpan.Loops.end(); svc++); // find and erase entry in Loop vector
|
for(svc=homeSpan.Loops.begin(); svc!=homeSpan.Loops.end() && (*svc)!=this; svc++); // search for entry in Loop vector...
|
||||||
if(svc!=homeSpan.Loops.end()){
|
|
||||||
|
if(svc!=homeSpan.Loops.end()){ // ...if it exists, erase it
|
||||||
homeSpan.Loops.erase(svc);
|
homeSpan.Loops.erase(svc);
|
||||||
Serial.printf("Deleted Loop Entry\n");
|
Serial.printf("Deleted Loop Entry\n");
|
||||||
}
|
}
|
||||||
|
|
@ -1682,6 +1686,24 @@ SpanCharacteristic::SpanCharacteristic(HapChar *hapChar, boolean isCustom){
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
|
SpanCharacteristic::~SpanCharacteristic(){
|
||||||
|
|
||||||
|
auto chr=service->Characteristics.begin(); // find Characteristic in containing Service vector and erase entry
|
||||||
|
while((*chr)!=this)
|
||||||
|
chr++;
|
||||||
|
service->Characteristics.erase(chr);
|
||||||
|
|
||||||
|
free(ev);
|
||||||
|
free(desc);
|
||||||
|
free(unit);
|
||||||
|
free(validValues);
|
||||||
|
free(nvsKey);
|
||||||
|
|
||||||
|
Serial.printf("Deleted Characteristic AID=%d IID=%d\n",aid,iid);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////
|
||||||
|
|
||||||
int SpanCharacteristic::sprintfAttributes(char *cBuf, int flags){
|
int SpanCharacteristic::sprintfAttributes(char *cBuf, int flags){
|
||||||
int nBytes=0;
|
int nBytes=0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ struct SpanAccessory{
|
||||||
int iidCount=0; // running count of iid to use for Services and Characteristics associated with this Accessory
|
int iidCount=0; // running count of iid to use for Services and Characteristics associated with this Accessory
|
||||||
vector<SpanService *> Services; // vector of pointers to all Services in this Accessory
|
vector<SpanService *> Services; // vector of pointers to all Services in this Accessory
|
||||||
|
|
||||||
SpanAccessory(uint32_t aid=0);
|
SpanAccessory(uint32_t aid=0); // constructor
|
||||||
~SpanAccessory();
|
~SpanAccessory();
|
||||||
|
|
||||||
int sprintfAttributes(char *cBuf, int flags); // prints Accessory JSON database into buf, unless buf=NULL; return number of characters printed, excluding null terminator, even if buf=NULL
|
int sprintfAttributes(char *cBuf, int flags); // prints Accessory JSON database into buf, unless buf=NULL; return number of characters printed, excluding null terminator, even if buf=NULL
|
||||||
|
|
@ -362,6 +362,7 @@ struct SpanCharacteristic{
|
||||||
SpanService *service=NULL; // pointer to Service containing this Characteristic
|
SpanService *service=NULL; // pointer to Service containing this Characteristic
|
||||||
|
|
||||||
SpanCharacteristic(HapChar *hapChar, boolean isCustom=false); // contructor
|
SpanCharacteristic(HapChar *hapChar, boolean isCustom=false); // contructor
|
||||||
|
~SpanCharacteristic();
|
||||||
|
|
||||||
int sprintfAttributes(char *cBuf, int flags); // prints Characteristic JSON records into buf, according to flags mask; return number of characters printed, excluding null terminator
|
int sprintfAttributes(char *cBuf, int flags); // prints Characteristic JSON records into buf, according to flags mask; return number of characters printed, excluding null terminator
|
||||||
StatusCode loadUpdate(char *val, char *ev); // load updated val/ev from PUT /characteristic JSON request. Return intiial HAP status code (checks to see if characteristic is found, is writable, etc.)
|
StatusCode loadUpdate(char *val, char *ev); // load updated val/ev from PUT /characteristic JSON request. Return intiial HAP status code (checks to see if characteristic is found, is writable, etc.)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue