// Example of a member function to handle UPnP requests : this can access stuff in the class void LEDService::SetStateHandler() { int l2 = strlen(gsh_template) + strlen(myServiceType) + MSS_STATE_LENGTH, l1 = strlen(UPnPClass::envelopeHeader) + l2 + strlen(UPnPClass::envelopeTrailer) + 5; char *tmp2 = (char *)malloc(l2), *tmp1 = (char *)malloc(l1); #ifdef DEBUG DEBUG.println("LEDService::SetStateHandler"); #endif strcpy(tmp1, UPnPClass::envelopeHeader); sprintf(tmp2, gsh_template, myServiceType, LEDService::state); strcat(tmp1, tmp2); free(tmp2); strcat(tmp1, UPnPClass::envelopeTrailer); HTTP.send(200, UPnPClass::mimeTypeXML, tmp1); free(tmp1); }
// Example of a static function to handle UPnP requests : only access to global variables here. static void GetVersion() { char msg[128]; sprintf(msg, versionTemplate, versionFileInfo, versionDateInfo, versionTimeInfo); HTTP.send(200, UPnPClass::mimeTypeXML, msg); }