Cleaned up various compiler warnings when compiled with max warning level
Also added a missing check on hapServer existing before it is used (bug introduced in last update where hapServer became dynamically initialized).
This commit is contained in:
parent
750a658241
commit
d41b335aee
25
src/HAP.cpp
25
src/HAP.cpp
|
|
@ -647,6 +647,8 @@ int HAPClient::postPairSetupURL(){
|
|||
|
||||
} // switch
|
||||
|
||||
return(1);
|
||||
|
||||
} // postPairSetup
|
||||
|
||||
//////////////////////////////////////
|
||||
|
|
@ -701,7 +703,7 @@ int HAPClient::postPairVerifyURL(){
|
|||
|
||||
memcpy(iosCurveKey,tlv8.buf(kTLVType_PublicKey),32); // save iosCurveKey (will persist until end of verification process)
|
||||
|
||||
int rVal=crypto_scalarmult_curve25519(sharedCurveKey,secretCurveKey,iosCurveKey); // generate (and persist) Pair Verify SharedSecret CurveKey from Accessory's Curve25519 secret key and Controller's Curve25519 public key (32 bytes)
|
||||
crypto_scalarmult_curve25519(sharedCurveKey,secretCurveKey,iosCurveKey); // generate (and persist) Pair Verify SharedSecret CurveKey from Accessory's Curve25519 secret key and Controller's Curve25519 public key (32 bytes)
|
||||
|
||||
uint8_t *accessoryPairingID = accessory.ID; // set accessoryPairingID
|
||||
size_t accessoryPairingIDLen = 17;
|
||||
|
|
@ -843,6 +845,8 @@ int HAPClient::postPairVerifyURL(){
|
|||
|
||||
} // switch
|
||||
|
||||
return(1);
|
||||
|
||||
} // postPairVerify
|
||||
|
||||
//////////////////////////////////////
|
||||
|
|
@ -925,7 +929,7 @@ int HAPClient::postPairingsURL(){
|
|||
break;
|
||||
}
|
||||
|
||||
if(newCont=findController(tlv8.buf(kTLVType_Identifier))){
|
||||
if((newCont=findController(tlv8.buf(kTLVType_Identifier)))){
|
||||
tlv8.clear(); // clear TLV records
|
||||
tlv8.val(kTLVType_State,pairState_M2); // set State=<M2>
|
||||
if(!memcmp(cPair->LTPK,newCont->LTPK,32)){ // requested Controller already exists and LTPK matches
|
||||
|
|
@ -1187,10 +1191,10 @@ int HAPClient::putPrepareURL(char *json){
|
|||
uint32_t ttl;
|
||||
uint64_t pid;
|
||||
|
||||
if(cBuf=strstr(json,ttlToken))
|
||||
sscanf(cBuf+strlen(ttlToken),"%lu",&ttl);
|
||||
if((cBuf=strstr(json,ttlToken)))
|
||||
sscanf(cBuf+strlen(ttlToken),"%u",&ttl);
|
||||
|
||||
if(cBuf=strstr(json,pidToken))
|
||||
if((cBuf=strstr(json,pidToken)))
|
||||
sscanf(cBuf+strlen(ttlToken),"%llu",&pid);
|
||||
|
||||
char jsonBuf[32];
|
||||
|
|
@ -1202,7 +1206,7 @@ int HAPClient::putPrepareURL(char *json){
|
|||
status=StatusCode::InvalidValue;
|
||||
}
|
||||
|
||||
sprintf(jsonBuf,"{\"status\":%d}",status);
|
||||
sprintf(jsonBuf,"{\"status\":%d}",(int)status);
|
||||
int nBytes=strlen(jsonBuf);
|
||||
int nChars=snprintf(NULL,0,"HTTP/1.1 200 OK\r\nContent-Type: application/hap+json\r\nContent-Length: %d\r\n\r\n",nBytes); // create Body with Content Length = size of JSON Buf
|
||||
char body[nChars+1];
|
||||
|
|
@ -1264,7 +1268,7 @@ void HAPClient::checkTimedWrites(){
|
|||
|
||||
for(auto tw=homeSpan.TimedWrites.begin(); tw!=homeSpan.TimedWrites.end(); tw++){ // loop over all Timed Writes using an iterator
|
||||
if(cTime>tw->second){ // timer has expired
|
||||
sprintf(c,"Removing PID=%llu ALARM=%lu\n",tw->first,tw->second);
|
||||
sprintf(c,"Removing PID=%llu ALARM=%u\n",tw->first,tw->second);
|
||||
LOG2(c);
|
||||
homeSpan.TimedWrites.erase(tw);
|
||||
}
|
||||
|
|
@ -1338,7 +1342,6 @@ void HAPClient::tlvRespond(){
|
|||
int HAPClient::receiveEncrypted(){
|
||||
|
||||
uint8_t buf[1042]; // maximum size of encoded message = 2+1024+16 bytes (HAP Section 6.5.2)
|
||||
int nFrames=0;
|
||||
int nBytes=0;
|
||||
|
||||
while(client.read(buf,2)==2){ // read initial 2-byte AAD record
|
||||
|
|
@ -1498,7 +1501,7 @@ Controller *HAPClient::addController(uint8_t *id, uint8_t *ltpk, boolean admin){
|
|||
|
||||
Controller *slot;
|
||||
|
||||
if(slot=findController(id)){
|
||||
if((slot=findController(id))){
|
||||
memcpy(slot->LTPK,ltpk,32);
|
||||
slot->admin=admin;
|
||||
LOG2("\n*** Updated Controller: ");
|
||||
|
|
@ -1508,7 +1511,7 @@ Controller *HAPClient::addController(uint8_t *id, uint8_t *ltpk, boolean admin){
|
|||
return(slot);
|
||||
}
|
||||
|
||||
if(slot=getFreeController()){
|
||||
if((slot=getFreeController())){
|
||||
slot->allocated=true;
|
||||
memcpy(slot->ID,id,36);
|
||||
memcpy(slot->LTPK,ltpk,32);
|
||||
|
|
@ -1553,7 +1556,7 @@ void HAPClient::removeController(uint8_t *id){
|
|||
|
||||
Controller *slot;
|
||||
|
||||
if(slot=findController(id)){ // remove controller if found
|
||||
if((slot=findController(id))){ // remove controller if found
|
||||
LOG2("\n***Removed Controller: ");
|
||||
if(homeSpan.logLevel>1)
|
||||
charPrintRow(id,36);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ void Span::begin(Category catID, const char *displayName, const char *hostNameBa
|
|||
this->displayName=displayName;
|
||||
this->hostNameBase=hostNameBase;
|
||||
this->modelName=modelName;
|
||||
sprintf(this->category,"%d",catID);
|
||||
sprintf(this->category,"%d",(int)catID);
|
||||
|
||||
controlButton.init(controlPin);
|
||||
statusLED.init(statusPin);
|
||||
|
|
@ -149,7 +149,7 @@ void Span::poll() {
|
|||
|
||||
WiFiClient newClient;
|
||||
|
||||
if(newClient=hapServer->available()){ // found a new HTTP client
|
||||
if(hapServer && (newClient=hapServer->available())){ // found a new HTTP client
|
||||
int freeSlot=getFreeSlot(); // get next free slot
|
||||
|
||||
if(freeSlot==-1){ // no available free slots
|
||||
|
|
@ -817,7 +817,7 @@ int Span::countCharacteristics(char *buf){
|
|||
int nObj=0;
|
||||
|
||||
const char tag[]="\"aid\"";
|
||||
while(buf=strstr(buf,tag)){ // count number of characteristic objects in PUT JSON request
|
||||
while((buf=strstr(buf,tag))){ // count number of characteristic objects in PUT JSON request
|
||||
nObj++;
|
||||
buf+=strlen(tag);
|
||||
}
|
||||
|
|
@ -999,7 +999,7 @@ int Span::sprintfAttributes(SpanBuf *pObj, int nObj, char *cBuf){
|
|||
nChars+=snprintf(cBuf,cBuf?64:0,"{\"characteristics\":[");
|
||||
|
||||
for(int i=0;i<nObj;i++){
|
||||
nChars+=snprintf(cBuf?(cBuf+nChars):NULL,cBuf?128:0,"{\"aid\":%u,\"iid\":%d,\"status\":%d}",pObj[i].aid,pObj[i].iid,pObj[i].status);
|
||||
nChars+=snprintf(cBuf?(cBuf+nChars):NULL,cBuf?128:0,"{\"aid\":%u,\"iid\":%d,\"status\":%d}",pObj[i].aid,pObj[i].iid,(int)pObj[i].status);
|
||||
if(i+1<nObj)
|
||||
nChars+=snprintf(cBuf?(cBuf+nChars):NULL,cBuf?64:0,",");
|
||||
}
|
||||
|
|
@ -1052,7 +1052,7 @@ int Span::sprintfAttributes(char **ids, int numIDs, int flags, char *cBuf){
|
|||
|
||||
if(sFlag){ // status flag is needed - overlay at end
|
||||
nChars--;
|
||||
nChars+=snprintf(cBuf?(cBuf+nChars):NULL,cBuf?64:0,",\"status\":%d}",status[i]);
|
||||
nChars+=snprintf(cBuf?(cBuf+nChars):NULL,cBuf?64:0,",\"status\":%d}",(int)status[i]);
|
||||
}
|
||||
|
||||
if(i+1<numIDs)
|
||||
|
|
@ -1401,7 +1401,7 @@ int SpanCharacteristic::sprintfAttributes(char *cBuf, int flags){
|
|||
break;
|
||||
|
||||
case UINT32:
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,",\"value\":%lu",value.UINT32);
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,",\"value\":%u",value.UINT32);
|
||||
break;
|
||||
|
||||
case UINT64:
|
||||
|
|
@ -1504,17 +1504,17 @@ StatusCode SpanCharacteristic::loadUpdate(char *val, char *ev){
|
|||
break;
|
||||
|
||||
case UINT8:
|
||||
if(!sscanf(val,"%u",&newValue.UINT8))
|
||||
if(!sscanf(val,"%hhu",&newValue.UINT8))
|
||||
return(StatusCode::InvalidValue);
|
||||
break;
|
||||
|
||||
case UINT16:
|
||||
if(!sscanf(val,"%u",&newValue.UINT16))
|
||||
if(!sscanf(val,"%hu",&newValue.UINT16))
|
||||
return(StatusCode::InvalidValue);
|
||||
break;
|
||||
|
||||
case UINT32:
|
||||
if(!sscanf(val,"%llu",&newValue.UINT32))
|
||||
if(!sscanf(val,"%u",&newValue.UINT32))
|
||||
return(StatusCode::InvalidValue);
|
||||
break;
|
||||
|
||||
|
|
@ -1528,6 +1528,9 @@ StatusCode SpanCharacteristic::loadUpdate(char *val, char *ev){
|
|||
return(StatusCode::InvalidValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
} // switch
|
||||
|
||||
isUpdated=true;
|
||||
|
|
@ -1570,6 +1573,9 @@ void SpanCharacteristic::setVal(int val){
|
|||
value.UINT64=(uint64_t)val;
|
||||
newValue.UINT64=(uint64_t)val;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
updateTime=homeSpan.snapTime;
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ void Network::scan(){
|
|||
|
||||
void Network::serialConfigure(){
|
||||
|
||||
sprintf(wifiData.ssid,"");
|
||||
sprintf(wifiData.pwd,"");
|
||||
wifiData.ssid[0]='\0';
|
||||
wifiData.pwd[0]='\0';
|
||||
|
||||
Serial.print("*** WiFi Setup - Scanning for Networks...\n\n");
|
||||
|
||||
|
|
@ -400,7 +400,7 @@ int Network::getFormValue(char *formData, const char *tag, char *value, int maxS
|
|||
while(*v!='\0' && *v!='&' && len<maxSize){ // copy the value until null, '&', or maxSize is reached
|
||||
if(*v=='%'){ // this is an escaped character of form %XX
|
||||
v++;
|
||||
sscanf(v,"%2x",value++);
|
||||
sscanf(v,"%2x",(unsigned int *)value++);
|
||||
v+=2;
|
||||
} else {
|
||||
*value++=*v++;
|
||||
|
|
|
|||
Loading…
Reference in New Issue