Added homeSpan.resetIID()...
...as well as SpanService.getIID() and SpanCharacteristic.getIID(). This provides control of IIDs used for each Service and Characteristic. By using this with adaptive lighting test, was able to verify that HomeKit can interpret TLV values of 1 byte, 2 bytes, and 4 bytes, but not 3 bytes. Suggests that TLV values need to be multiples of 2 (i.e. uint8, uint16, uint32). Will change TLV value-writing methodology so that padding zeros are used to round to 1, 2, 4, or 8 bytes.
This commit is contained in:
		
							parent
							
								
									e4df56293a
								
							
						
					
					
						commit
						a7d57699a0
					
				|  | @ -1586,6 +1586,26 @@ boolean Span::printfAttributes(char **ids, int numIDs, int flags){ | |||
| 
 | ||||
| ///////////////////////////////
 | ||||
| 
 | ||||
| Span& Span::resetIID(int newIID){ | ||||
| 
 | ||||
|   if(Accessories.empty()){ | ||||
|     LOG0("\nFATAL ERROR!  Can't reset the Accessory IID count without a defined Accessory ***\n"); | ||||
|     LOG0("\n=== PROGRAM HALTED ==="); | ||||
|     while(1); | ||||
|   } | ||||
| 
 | ||||
|   if(newIID<1){ | ||||
|     LOG0("\nFATAL ERROR!  Can't reset the Accessory IID count to a value less than 1 ***\n"); | ||||
|     LOG0("\n=== PROGRAM HALTED ==="); | ||||
|     while(1);     | ||||
|   } | ||||
|    | ||||
|   Accessories.back()->iidCount=newIID-1; | ||||
|   return(*this); | ||||
| } | ||||
| 
 | ||||
| ///////////////////////////////
 | ||||
| 
 | ||||
| boolean Span::updateDatabase(boolean updateMDNS){ | ||||
| 
 | ||||
|   printfAttributes(GET_META|GET_PERMS|GET_TYPE|GET_DESC);   // stream attributes database, which automtically produces a SHA-384 hash
 | ||||
|  |  | |||
|  | @ -354,6 +354,7 @@ class Span{ | |||
|   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
 | ||||
|   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
 | ||||
| 
 | ||||
|   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)
 | ||||
|  | @ -459,6 +460,8 @@ class SpanService{ | |||
|   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
 | ||||
| 
 | ||||
|   int getIID(){return(iid);} | ||||
| 
 | ||||
|   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 button(int pin, int pressType){}           // method called for a Service when a button attached to "pin" has a Single, Double, or Long Press, according to pressType
 | ||||
|  | @ -653,6 +656,8 @@ class SpanCharacteristic{ | |||
|   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
 | ||||
| 
 | ||||
|   int getIID(){return(iid);} | ||||
| 
 | ||||
|   template <class T=int> T getVal(){ | ||||
|     return(uvGet<T>(value)); | ||||
|   } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Gregg
						Gregg