Converted SpanUserCommand to class from struct
Also cleaned up some code by moving a few HAPClient routines into Span polling function.
This commit is contained in:
parent
86a0c1cf75
commit
2b25acf2e1
10
src/HAP.cpp
10
src/HAP.cpp
|
|
@ -1313,16 +1313,6 @@ int HAPClient::getStatusURL(){
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
|
|
||||||
void HAPClient::callServiceLoops(){
|
|
||||||
|
|
||||||
homeSpan.snapTime=millis(); // snap the current time for use in ALL loop routines
|
|
||||||
|
|
||||||
for(int i=0;i<homeSpan.Loops.size();i++) // loop over all services with over-ridden loop() methods
|
|
||||||
homeSpan.Loops[i]->loop(); // call the loop() method
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////
|
|
||||||
|
|
||||||
void HAPClient::checkNotifications(){
|
void HAPClient::checkNotifications(){
|
||||||
|
|
||||||
if(!homeSpan.Notifications.empty()){ // if there are Notifications to process
|
if(!homeSpan.Notifications.empty()){ // if there are Notifications to process
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,6 @@ struct HAPClient {
|
||||||
static void removeControllers(); // removes all Controllers (sets allocated flags to false for all slots)
|
static void removeControllers(); // removes all Controllers (sets allocated flags to false for all slots)
|
||||||
static void removeController(uint8_t *id); // removes specific Controller. If no remaining admin Controllers, remove all others (if any) as per HAP requirements.
|
static void removeController(uint8_t *id); // removes specific Controller. If no remaining admin Controllers, remove all others (if any) as per HAP requirements.
|
||||||
static void printControllers(); // prints IDs of all allocated (paired) Controller
|
static void printControllers(); // prints IDs of all allocated (paired) Controller
|
||||||
static void callServiceLoops(); // call the loop() method for any Service with that over-rode the default method
|
|
||||||
static void checkNotifications(); // checks for Event Notifications and reports to controllers as needed (HAP Section 6.8)
|
static void checkNotifications(); // checks for Event Notifications and reports to controllers as needed (HAP Section 6.8)
|
||||||
static void checkTimedWrites(); // checks for expired Timed Write PIDs, and clears any found (HAP Section 6.7.2.4)
|
static void checkTimedWrites(); // checks for expired Timed Write PIDs, and clears any found (HAP Section 6.7.2.4)
|
||||||
static void eventNotify(SpanBuf *pObj, int nObj, int ignoreClient=-1); // transmits EVENT Notifications for nObj SpanBuf objects, pObj, with optional flag to ignore a specific client
|
static void eventNotify(SpanBuf *pObj, int nObj, int ignoreClient=-1); // transmits EVENT Notifications for nObj SpanBuf objects, pObj, with optional flag to ignore a specific client
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,10 @@ void Span::pollTask() {
|
||||||
} // process HAP Client
|
} // process HAP Client
|
||||||
} // for-loop over connection slots
|
} // for-loop over connection slots
|
||||||
|
|
||||||
HAPClient::callServiceLoops();
|
snapTime=millis(); // snap the current time for use in ALL loop routines
|
||||||
|
|
||||||
|
for(auto it=Loops.begin();it!=Loops.end();it++) // call loop() for all Services with over-ridden loop() methods
|
||||||
|
(*it)->loop();
|
||||||
|
|
||||||
for(auto it=PushButtons.begin();it!=PushButtons.end();it++) // check for SpanButton presses
|
for(auto it=PushButtons.begin();it!=PushButtons.end();it++) // check for SpanButton presses
|
||||||
(*it)->check();
|
(*it)->check();
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,9 @@ struct SpanUserCommand;
|
||||||
|
|
||||||
extern Span homeSpan;
|
extern Span homeSpan;
|
||||||
|
|
||||||
///////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
|
// INTERNAL HOMESPAN STRUCTURES - NOT FOR USER ACCESS //
|
||||||
|
////////////////////////////////////////////////////////
|
||||||
|
|
||||||
struct SpanPartition{
|
struct SpanPartition{
|
||||||
char magicCookie[32];
|
char magicCookie[32];
|
||||||
|
|
@ -145,7 +147,9 @@ struct SpanOTA{ // manages OTA process
|
||||||
static void error(ota_error_t err);
|
static void error(ota_error_t err);
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////
|
//////////////////////////////////////
|
||||||
|
// USER API CLASSES BEGINS HERE //
|
||||||
|
//////////////////////////////////////
|
||||||
|
|
||||||
struct Span{
|
struct Span{
|
||||||
|
|
||||||
|
|
@ -693,12 +697,17 @@ class SpanButton{
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
struct SpanUserCommand {
|
class SpanUserCommand {
|
||||||
|
|
||||||
|
friend class Span;
|
||||||
|
|
||||||
const char *s; // description of command
|
const char *s; // description of command
|
||||||
void (*userFunction1)(const char *v)=NULL; // user-defined function to call
|
void (*userFunction1)(const char *v)=NULL; // user-defined function to call
|
||||||
void (*userFunction2)(const char *v, void *arg)=NULL; // user-defined function to call with user-defined arg
|
void (*userFunction2)(const char *v, void *arg)=NULL; // user-defined function to call with user-defined arg
|
||||||
void *userArg;
|
void *userArg;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
SpanUserCommand(char c, const char *s, void (*f)(const char *));
|
SpanUserCommand(char c, const char *s, void (*f)(const char *));
|
||||||
SpanUserCommand(char c, const char *s, void (*f)(const char *, void *), void *arg);
|
SpanUserCommand(char c, const char *s, void (*f)(const char *, void *), void *arg);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue