Converted IID from int to uint32_t everywhere
This commit is contained in:
parent
723c343277
commit
d1dd565478
|
|
@ -864,7 +864,7 @@ void Span::processSerialCommand(const char *c){
|
||||||
char pNames[][7]={"PR","PW","EV","AA","TW","HD","WR"};
|
char pNames[][7]={"PR","PW","EV","AA","TW","HD","WR"};
|
||||||
|
|
||||||
for(auto acc=Accessories.begin(); acc!=Accessories.end(); acc++){
|
for(auto acc=Accessories.begin(); acc!=Accessories.end(); acc++){
|
||||||
LOG0("\u27a4 Accessory: AID=%d\n",(*acc)->aid);
|
LOG0("\u27a4 Accessory: AID=%u\n",(*acc)->aid);
|
||||||
boolean foundInfo=false;
|
boolean foundInfo=false;
|
||||||
|
|
||||||
if(acc==Accessories.begin() && (*acc)->aid!=1)
|
if(acc==Accessories.begin() && (*acc)->aid!=1)
|
||||||
|
|
@ -877,7 +877,7 @@ void Span::processSerialCommand(const char *c){
|
||||||
vector<uint32_t, Mallocator<uint32_t>> iidValues;
|
vector<uint32_t, Mallocator<uint32_t>> iidValues;
|
||||||
|
|
||||||
for(auto svc=(*acc)->Services.begin(); svc!=(*acc)->Services.end(); svc++){
|
for(auto svc=(*acc)->Services.begin(); svc!=(*acc)->Services.end(); svc++){
|
||||||
LOG0(" \u279f Service %s: IID=%d, %sUUID=\"%s\"\n",(*svc)->hapName,(*svc)->iid,(*svc)->isCustom?"Custom-":"",(*svc)->type);
|
LOG0(" \u279f Service %s: IID=%u, %sUUID=\"%s\"\n",(*svc)->hapName,(*svc)->iid,(*svc)->isCustom?"Custom-":"",(*svc)->type);
|
||||||
|
|
||||||
if(!strcmp((*svc)->type,"3E")){
|
if(!strcmp((*svc)->type,"3E")){
|
||||||
foundInfo=true;
|
foundInfo=true;
|
||||||
|
|
@ -893,7 +893,7 @@ void Span::processSerialCommand(const char *c){
|
||||||
iidValues.push_back((*svc)->iid);
|
iidValues.push_back((*svc)->iid);
|
||||||
|
|
||||||
for(auto chr=(*svc)->Characteristics.begin(); chr!=(*svc)->Characteristics.end(); chr++){
|
for(auto chr=(*svc)->Characteristics.begin(); chr!=(*svc)->Characteristics.end(); chr++){
|
||||||
LOG0(" \u21e8 Characteristic %s(%.33s%s): IID=%d, %sUUID=\"%s\", %sPerms=",
|
LOG0(" \u21e8 Characteristic %s(%.33s%s): IID=%u, %sUUID=\"%s\", %sPerms=",
|
||||||
(*chr)->hapName,(*chr)->uvPrint((*chr)->value).c_str(),strlen((*chr)->uvPrint((*chr)->value).c_str())>33?"...\"":"",(*chr)->iid,(*chr)->isCustom?"Custom-":"",(*chr)->type,(*chr)->perms!=(*chr)->hapChar->perms?"Custom-":"");
|
(*chr)->hapName,(*chr)->uvPrint((*chr)->value).c_str(),strlen((*chr)->uvPrint((*chr)->value).c_str())>33?"...\"":"",(*chr)->iid,(*chr)->isCustom?"Custom-":"",(*chr)->type,(*chr)->perms!=(*chr)->hapChar->perms?"Custom-":"");
|
||||||
|
|
||||||
int foundPerms=0;
|
int foundPerms=0;
|
||||||
|
|
@ -996,7 +996,7 @@ void Span::processSerialCommand(const char *c){
|
||||||
for(int i=0;i<Accessories.size();i++){ // identify all services with over-ridden loop() methods
|
for(int i=0;i<Accessories.size();i++){ // identify all services with over-ridden loop() methods
|
||||||
for(int j=0;j<Accessories[i]->Services.size();j++){
|
for(int j=0;j<Accessories[i]->Services.size();j++){
|
||||||
SpanService *s=Accessories[i]->Services[j];
|
SpanService *s=Accessories[i]->Services[j];
|
||||||
LOG0("%-30s %8.8s %10u %3d %6s %4s %6s ",s->hapName,s->type,Accessories[i]->aid,s->iid,
|
LOG0("%-30s %8.8s %10u %3u %6s %4s %6s ",s->hapName,s->type,Accessories[i]->aid,s->iid,
|
||||||
(void(*)())(s->*(&SpanService::update))!=(void(*)())(&SpanService::update)?"YES":"NO",
|
(void(*)())(s->*(&SpanService::update))!=(void(*)())(&SpanService::update)?"YES":"NO",
|
||||||
(void(*)())(s->*(&SpanService::loop))!=(void(*)())(&SpanService::loop)?"YES":"NO",
|
(void(*)())(s->*(&SpanService::loop))!=(void(*)())(&SpanService::loop)?"YES":"NO",
|
||||||
(void(*)(int,boolean))(s->*(&SpanService::button))!=(void(*)(int,boolean))(&SpanService::button)?"YES":"NO"
|
(void(*)(int,boolean))(s->*(&SpanService::button))!=(void(*)(int,boolean))(&SpanService::button)?"YES":"NO"
|
||||||
|
|
@ -1004,7 +1004,7 @@ void Span::processSerialCommand(const char *c){
|
||||||
if(s->linkedServices.empty())
|
if(s->linkedServices.empty())
|
||||||
LOG0("-");
|
LOG0("-");
|
||||||
for(int k=0;k<s->linkedServices.size();k++){
|
for(int k=0;k<s->linkedServices.size();k++){
|
||||||
LOG0("%d",s->linkedServices[k]->iid);
|
LOG0("%u",s->linkedServices[k]->iid);
|
||||||
if(k<s->linkedServices.size()-1)
|
if(k<s->linkedServices.size()-1)
|
||||||
LOG0(",");
|
LOG0(",");
|
||||||
}
|
}
|
||||||
|
|
@ -1323,7 +1323,7 @@ boolean Span::deleteAccessory(uint32_t n){
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
SpanCharacteristic *Span::find(uint32_t aid, int iid){
|
SpanCharacteristic *Span::find(uint32_t aid, uint32_t iid){
|
||||||
|
|
||||||
int index=-1;
|
int index=-1;
|
||||||
for(int i=0;i<Accessories.size();i++){ // loop over all Accessories to find aid
|
for(int i=0;i<Accessories.size();i++){ // loop over all Accessories to find aid
|
||||||
|
|
@ -1394,7 +1394,7 @@ int Span::updateCharacteristics(char *buf, SpanBuf *pObj){
|
||||||
okay|=1;
|
okay|=1;
|
||||||
} else
|
} else
|
||||||
if(!strcmp(t2,"iid") && (t3=strtok_r(t1,"}[]:, \"\t\n\r",&p2))){
|
if(!strcmp(t2,"iid") && (t3=strtok_r(t1,"}[]:, \"\t\n\r",&p2))){
|
||||||
pObj[nObj].iid=atoi(t3);
|
sscanf(t3,"%u",&pObj[nObj].iid);
|
||||||
okay|=2;
|
okay|=2;
|
||||||
} else
|
} else
|
||||||
if(!strcmp(t2,"value") && (t3=strtok_r(t1,"}[]:,\"",&p2))){
|
if(!strcmp(t2,"value") && (t3=strtok_r(t1,"}[]:,\"",&p2))){
|
||||||
|
|
@ -1464,10 +1464,7 @@ int Span::updateCharacteristics(char *buf, SpanBuf *pObj){
|
||||||
|
|
||||||
if(pObj[j].characteristic->service==pObj[i].characteristic->service){ // if service of this characteristic matches service that was updated
|
if(pObj[j].characteristic->service==pObj[i].characteristic->service){ // if service of this characteristic matches service that was updated
|
||||||
pObj[j].status=status; // save statusCode for this object
|
pObj[j].status=status; // save statusCode for this object
|
||||||
LOG1("Updating aid=");
|
LOG1("Updating aid=%u iid=%u",pObj[j].characteristic->aid,pObj[j].characteristic->iid);
|
||||||
LOG1(pObj[j].characteristic->aid);
|
|
||||||
LOG1(" iid=");
|
|
||||||
LOG1(pObj[j].characteristic->iid);
|
|
||||||
if(status==StatusCode::OK){ // if status is okay
|
if(status==StatusCode::OK){ // if status is okay
|
||||||
pObj[j].characteristic->uvSet(pObj[j].characteristic->value,pObj[j].characteristic->newValue); // update characteristic value with new value
|
pObj[j].characteristic->uvSet(pObj[j].characteristic->value,pObj[j].characteristic->newValue); // update characteristic value with new value
|
||||||
if(pObj[j].characteristic->nvsKey){ // if storage key found
|
if(pObj[j].characteristic->nvsKey){ // if storage key found
|
||||||
|
|
@ -1555,13 +1552,13 @@ void Span::printfAttributes(SpanBuf *pObj, int nObj){
|
||||||
boolean Span::printfAttributes(char **ids, int numIDs, int flags){
|
boolean Span::printfAttributes(char **ids, int numIDs, int flags){
|
||||||
|
|
||||||
uint32_t aid;
|
uint32_t aid;
|
||||||
int iid;
|
uint32_t iid;
|
||||||
|
|
||||||
SpanCharacteristic *Characteristics[numIDs];
|
SpanCharacteristic *Characteristics[numIDs];
|
||||||
StatusCode status[numIDs];
|
StatusCode status[numIDs];
|
||||||
|
|
||||||
for(int i=0;i<numIDs;i++){ // PASS 1: loop over all ids requested to check status codes - only errors are if characteristic not found, or not readable
|
for(int i=0;i<numIDs;i++){ // PASS 1: loop over all ids requested to check status codes - only errors are if characteristic not found, or not readable
|
||||||
sscanf(ids[i],"%u.%d",&aid,&iid); // parse aid and iid
|
sscanf(ids[i],"%u.%u",&aid,&iid); // parse aid and iid
|
||||||
Characteristics[i]=find(aid,iid); // find matching chararacteristic
|
Characteristics[i]=find(aid,iid); // find matching chararacteristic
|
||||||
|
|
||||||
if(Characteristics[i]){ // if found
|
if(Characteristics[i]){ // if found
|
||||||
|
|
@ -1585,7 +1582,7 @@ boolean Span::printfAttributes(char **ids, int numIDs, int flags){
|
||||||
if(Characteristics[i]) // if found
|
if(Characteristics[i]) // if found
|
||||||
Characteristics[i]->printfAttributes(flags); // get JSON attributes for characteristic (may or may not include status=0 attribute)
|
Characteristics[i]->printfAttributes(flags); // get JSON attributes for characteristic (may or may not include status=0 attribute)
|
||||||
else{ // else create JSON status attribute based on requested aid/iid
|
else{ // else create JSON status attribute based on requested aid/iid
|
||||||
sscanf(ids[i],"%u.%d",&aid,&iid);
|
sscanf(ids[i],"%u.%u",&aid,&iid);
|
||||||
hapOut << "{\"iid\":" << iid << ",\"aid\":" << aid << ",\"status\":" << (int)status[i] << "}";
|
hapOut << "{\"iid\":" << iid << ",\"aid\":" << aid << ",\"status\":" << (int)status[i] << "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1600,7 +1597,7 @@ boolean Span::printfAttributes(char **ids, int numIDs, int flags){
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
Span& Span::resetIID(int newIID){
|
Span& Span::resetIID(uint32_t newIID){
|
||||||
|
|
||||||
if(Accessories.empty()){
|
if(Accessories.empty()){
|
||||||
LOG0("\nFATAL ERROR! Can't reset the Accessory IID count without a defined Accessory ***\n");
|
LOG0("\nFATAL ERROR! Can't reset the Accessory IID count without a defined Accessory ***\n");
|
||||||
|
|
@ -1767,7 +1764,7 @@ SpanService::~SpanService(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG1("Deleted Service AID=%d IID=%d\n",accessory->aid,iid);
|
LOG1("Deleted Service AID=%u IID=%u\n",accessory->aid,iid);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
@ -1872,7 +1869,7 @@ SpanCharacteristic::~SpanCharacteristic(){
|
||||||
free(newValue.STRING);
|
free(newValue.STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG1("Deleted Characteristic AID=%d IID=%d\n",aid,iid);
|
LOG1("Deleted Characteristic AID=%u IID=%u\n",aid,iid);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
@ -1961,13 +1958,7 @@ StatusCode SpanCharacteristic::loadUpdate(char *val, char *ev, boolean wr){
|
||||||
if(evFlag && !(perms&EV)) // notification is not supported for characteristic
|
if(evFlag && !(perms&EV)) // notification is not supported for characteristic
|
||||||
return(StatusCode::NotifyNotAllowed);
|
return(StatusCode::NotifyNotAllowed);
|
||||||
|
|
||||||
LOG1("Notification Request for aid=");
|
LOG1("Notification Request for aid=%u iid=%u: %s\n",aid,iid,evFlag?"true":"false");
|
||||||
LOG1(aid);
|
|
||||||
LOG1(" iid=");
|
|
||||||
LOG1(iid);
|
|
||||||
LOG1(": ");
|
|
||||||
LOG1(evFlag?"true":"false");
|
|
||||||
LOG1("\n");
|
|
||||||
this->ev[HAPClient::conNum]=evFlag;
|
this->ev[HAPClient::conNum]=evFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ struct SpanConfig{
|
||||||
|
|
||||||
struct SpanBuf{ // temporary storage buffer for use with putCharacteristicsURL() and checkTimedResets()
|
struct SpanBuf{ // temporary storage buffer for use with putCharacteristicsURL() and checkTimedResets()
|
||||||
uint32_t aid=0; // updated aid
|
uint32_t aid=0; // updated aid
|
||||||
int iid=0; // updated iid
|
uint32_t iid=0; // updated iid
|
||||||
boolean wr=false; // flag to indicate write-response has been requested
|
boolean wr=false; // flag to indicate write-response has been requested
|
||||||
char *val=NULL; // updated value (optional, though either at least 'val' or 'ev' must be specified)
|
char *val=NULL; // updated value (optional, though either at least 'val' or 'ev' must be specified)
|
||||||
char *ev=NULL; // updated event notification flag (optional, though either at least 'val' or 'ev' must be specified)
|
char *ev=NULL; // updated event notification flag (optional, though either at least 'val' or 'ev' must be specified)
|
||||||
|
|
@ -280,7 +280,7 @@ class Span{
|
||||||
|
|
||||||
void printfAttributes(int flags=GET_VALUE|GET_META|GET_PERMS|GET_TYPE|GET_DESC); // writes Attributes JSON database to hapOut stream
|
void printfAttributes(int flags=GET_VALUE|GET_META|GET_PERMS|GET_TYPE|GET_DESC); // writes Attributes JSON database to hapOut stream
|
||||||
|
|
||||||
SpanCharacteristic *find(uint32_t aid, int iid); // return Characteristic with matching aid and iid (else NULL if not found)
|
SpanCharacteristic *find(uint32_t aid, uint32_t iid); // return Characteristic with matching aid and iid (else NULL if not found)
|
||||||
int countCharacteristics(char *buf); // return number of characteristic objects referenced in PUT /characteristics JSON request
|
int countCharacteristics(char *buf); // return number of characteristic objects referenced in PUT /characteristics JSON request
|
||||||
int updateCharacteristics(char *buf, SpanBuf *pObj); // parses PUT /characteristics JSON request 'buf into 'pObj' and updates referenced characteristics; returns 1 on success, 0 on fail
|
int updateCharacteristics(char *buf, SpanBuf *pObj); // parses PUT /characteristics JSON request 'buf into 'pObj' and updates referenced characteristics; returns 1 on success, 0 on fail
|
||||||
void printfAttributes(SpanBuf *pObj, int nObj); // writes SpanBuf objects to hapOut stream
|
void printfAttributes(SpanBuf *pObj, int nObj); // writes SpanBuf objects to hapOut stream
|
||||||
|
|
@ -354,7 +354,7 @@ class Span{
|
||||||
const char* statusString(HS_STATUS s); // returns char string for HomeSpan status change messages
|
const char* statusString(HS_STATUS s); // returns char string for HomeSpan status change messages
|
||||||
Span& setPairingCode(const char *s, boolean progCall=true); // sets the Pairing Code - use is NOT recommended. Use 'S' from CLI instead
|
Span& setPairingCode(const char *s, boolean progCall=true); // sets the Pairing Code - use is NOT recommended. Use 'S' from CLI instead
|
||||||
void deleteStoredValues(){processSerialCommand("V");} // deletes stored Characteristic values from NVS
|
void deleteStoredValues(){processSerialCommand("V");} // deletes stored Characteristic values from NVS
|
||||||
Span& resetIID(int newIID); // resets the IID count for the current Accessory to start at newIID
|
Span& resetIID(uint32_t newIID); // resets the IID count for the current Accessory to start at newIID
|
||||||
|
|
||||||
int enableOTA(boolean auth=true, boolean safeLoad=true){return(spanOTA.init(auth, safeLoad, NULL));} // enables Over-the-Air updates, with (auth=true) or without (auth=false) authorization password
|
int enableOTA(boolean auth=true, boolean safeLoad=true){return(spanOTA.init(auth, safeLoad, NULL));} // enables Over-the-Air updates, with (auth=true) or without (auth=false) authorization password
|
||||||
int enableOTA(const char *pwd, boolean safeLoad=true){return(spanOTA.init(true, safeLoad, pwd));} // enables Over-the-Air updates, with custom authorization password (overrides any password stored with the 'O' command)
|
int enableOTA(const char *pwd, boolean safeLoad=true){return(spanOTA.init(true, safeLoad, pwd));} // enables Over-the-Air updates, with custom authorization password (overrides any password stored with the 'O' command)
|
||||||
|
|
@ -409,7 +409,7 @@ class SpanAccessory{
|
||||||
friend class SpanRange;
|
friend class SpanRange;
|
||||||
|
|
||||||
uint32_t aid=0; // Accessory Instance ID (HAP Table 6-1)
|
uint32_t aid=0; // Accessory Instance ID (HAP Table 6-1)
|
||||||
int iidCount=0; // running count of iid to use for Services and Characteristics associated with this Accessory
|
uint32_t iidCount=0; // running count of iid to use for Services and Characteristics associated with this Accessory
|
||||||
vector<SpanService *, Mallocator<SpanService*>> Services; // vector of pointers to all Services in this Accessory
|
vector<SpanService *, Mallocator<SpanService*>> Services; // vector of pointers to all Services in this Accessory
|
||||||
|
|
||||||
void printfAttributes(int flags); // writes Accessory JSON to hapOut stream
|
void printfAttributes(int flags); // writes Accessory JSON to hapOut stream
|
||||||
|
|
@ -433,7 +433,7 @@ class SpanService{
|
||||||
friend class SpanCharacteristic;
|
friend class SpanCharacteristic;
|
||||||
friend class SpanRange;
|
friend class SpanRange;
|
||||||
|
|
||||||
int iid=0; // Instance ID (HAP Table 6-2)
|
uint32_t iid=0; // Instance ID (HAP Table 6-2)
|
||||||
const char *type; // Service Type
|
const char *type; // Service Type
|
||||||
const char *hapName; // HAP Name
|
const char *hapName; // HAP Name
|
||||||
boolean hidden=false; // optional property indicating service is hidden
|
boolean hidden=false; // optional property indicating service is hidden
|
||||||
|
|
@ -460,7 +460,7 @@ class SpanService{
|
||||||
SpanService *addLink(SpanService *svc); // adds svc as a Linked Service and returns pointer to self
|
SpanService *addLink(SpanService *svc); // adds svc as a Linked Service and returns pointer to self
|
||||||
vector<SpanService *, Mallocator<SpanService *>> getLinks(){return(linkedServices);} // returns linkedServices vector for use as range in "for-each" loops
|
vector<SpanService *, Mallocator<SpanService *>> getLinks(){return(linkedServices);} // returns linkedServices vector for use as range in "for-each" loops
|
||||||
|
|
||||||
int getIID(){return(iid);}
|
uint32_t getIID(){return(iid);} // returns IID of Service
|
||||||
|
|
||||||
virtual boolean update() {return(true);} // placeholder for code that is called when a Service is updated via a Controller. Must return true/false depending on success of update
|
virtual boolean update() {return(true);} // placeholder for code that is called when a Service is updated via a Controller. Must return true/false depending on success of update
|
||||||
virtual void loop(){} // loops for each Service - called every cycle if over-ridden with user-defined code
|
virtual void loop(){} // loops for each Service - called every cycle if over-ridden with user-defined code
|
||||||
|
|
@ -485,7 +485,7 @@ class SpanCharacteristic{
|
||||||
STRING_t STRING = NULL;
|
STRING_t STRING = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
int iid=0; // Instance ID (HAP Table 6-3)
|
uint32_t iid=0; // Instance ID (HAP Table 6-3)
|
||||||
HapChar *hapChar; // pointer to HAP Characteristic structure
|
HapChar *hapChar; // pointer to HAP Characteristic structure
|
||||||
const char *type; // Characteristic Type
|
const char *type; // Characteristic Type
|
||||||
const char *hapName; // HAP Name
|
const char *hapName; // HAP Name
|
||||||
|
|
@ -656,7 +656,7 @@ class SpanCharacteristic{
|
||||||
void *operator new(size_t size){return(HS_MALLOC(size));} // override new operator to use PSRAM when available
|
void *operator new(size_t size){return(HS_MALLOC(size));} // override new operator to use PSRAM when available
|
||||||
SpanCharacteristic(HapChar *hapChar, boolean isCustom=false); // constructor
|
SpanCharacteristic(HapChar *hapChar, boolean isCustom=false); // constructor
|
||||||
|
|
||||||
int getIID(){return(iid);}
|
uint32_t getIID(){return(iid);} // returns IID of Characteristic
|
||||||
|
|
||||||
template <class T=int> T getVal(){
|
template <class T=int> T getVal(){
|
||||||
return(uvGet<T>(value));
|
return(uvGet<T>(value));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue