Initial Test under Arduino-ESP32 version 3.0.2

In order to compile, commented out all Pixel, PWM, and RFControl Code.  Also needed to comment out ArduinoOTA and make change to SpanPoint.
This commit is contained in:
Gregg 2024-07-04 22:46:23 -05:00
parent d6fcc50a0b
commit 0e04051ab7
25 changed files with 234 additions and 461 deletions

View File

@ -40,13 +40,13 @@ void HAPClient::init(){
size_t len; // not used but required to read blobs from NVS size_t len; // not used but required to read blobs from NVS
if(strlen(homeSpan.spanOTA.otaPwd)==0){ // OTA password has not been specified in sketch // if(strlen(homeSpan.spanOTA.otaPwd)==0){ // OTA password has not been specified in sketch
if(!nvs_get_str(homeSpan.otaNVS,"OTADATA",NULL,&len)){ // if found OTA data in NVS... // if(!nvs_get_str(homeSpan.otaNVS,"OTADATA",NULL,&len)){ // if found OTA data in NVS...
nvs_get_str(homeSpan.otaNVS,"OTADATA",homeSpan.spanOTA.otaPwd,&len); // ...retrieve data. // nvs_get_str(homeSpan.otaNVS,"OTADATA",homeSpan.spanOTA.otaPwd,&len); // ...retrieve data.
} else { // otherwise... // } else { // otherwise...
homeSpan.spanOTA.setPassword(DEFAULT_OTA_PASSWORD); // ...use default password // homeSpan.spanOTA.setPassword(DEFAULT_OTA_PASSWORD); // ...use default password
} // }
} // }
if(!strlen(homeSpan.qrID)){ // if Setup ID has not been specified in sketch if(!strlen(homeSpan.qrID)){ // if Setup ID has not been specified in sketch
if(!nvs_get_str(homeSpan.hapNVS,"SETUPID",NULL,&len)){ // check for saved value if(!nvs_get_str(homeSpan.hapNVS,"SETUPID",NULL,&len)){ // check for saved value
@ -1555,7 +1555,7 @@ HapOut::HapStreamBuffer::HapStreamBuffer(){
ctx = (mbedtls_sha512_context *)heap_caps_malloc(sizeof(mbedtls_sha512_context),caps); // space for hash context ctx = (mbedtls_sha512_context *)heap_caps_malloc(sizeof(mbedtls_sha512_context),caps); // space for hash context
mbedtls_sha512_init(ctx); // initialize context mbedtls_sha512_init(ctx); // initialize context
mbedtls_sha512_starts_ret(ctx,1); // start SHA-384 hash (note second argument=1) mbedtls_sha512_starts(ctx,1); // start SHA-384 hash (note second argument=1)
setp(buffer, buffer+bufSize-1); // assign buffer pointers setp(buffer, buffer+bufSize-1); // assign buffer pointers
} }
@ -1607,7 +1607,7 @@ void HapOut::HapStreamBuffer::flushBuffer(){
delay(1); delay(1);
} }
mbedtls_sha512_update_ret(ctx,(uint8_t *)buffer,num); // update hash mbedtls_sha512_update(ctx,(uint8_t *)buffer,num); // update hash
pbump(-num); // reset buffer pointers pbump(-num); // reset buffer pointers
} }
@ -1643,8 +1643,8 @@ int HapOut::HapStreamBuffer::sync(){
callBackUserData=NULL; callBackUserData=NULL;
} }
mbedtls_sha512_finish_ret(ctx,hash); // finish SHA-384 and store hash mbedtls_sha512_finish(ctx,hash); // finish SHA-384 and store hash
mbedtls_sha512_starts_ret(ctx,1); // re-start hash for next time mbedtls_sha512_starts(ctx,1); // re-start hash for next time
return(0); return(0);
} }

View File

@ -118,7 +118,7 @@ struct HAPClient {
// individual structures and data defined for each Hap Client connection // individual structures and data defined for each Hap Client connection
WiFiClient client; // handle to client NetworkClient client; // handle to client
int clientNumber; // client number int clientNumber; // client number
Controller *cPair=NULL; // pointer to info on current, session-verified Paired Controller (NULL=un-verified, and therefore un-encrypted, connection) Controller *cPair=NULL; // pointer to info on current, session-verified Paired Controller (NULL=un-verified, and therefore un-encrypted, connection)

View File

@ -87,7 +87,7 @@ void Span::begin(Category catID, const char *_displayName, const char *_hostName
statusLED=new Blinker(statusDevice,autoOffLED); // create Status LED, even is statusDevice is NULL statusLED=new Blinker(statusDevice,autoOffLED); // create Status LED, even is statusDevice is NULL
esp_task_wdt_delete(xTaskGetIdleTaskHandleForCPU(0)); // required to avoid watchdog timeout messages from ESP32-C3 //D esp_task_wdt_delete(xTaskGetIdleTaskHandleForCPU(0)); // required to avoid watchdog timeout messages from ESP32-C3
hapServer=new WiFiServer(tcpPortNum); // create HAP WIFI SERVER hapServer=new WiFiServer(tcpPortNum); // create HAP WIFI SERVER
@ -147,7 +147,7 @@ void Span::begin(Category catID, const char *_displayName, const char *_hostName
LOG0("\nSketch Compiled: %s %s",__DATE__,__TIME__); LOG0("\nSketch Compiled: %s %s",__DATE__,__TIME__);
LOG0("\nPartition: %s",esp_ota_get_running_partition()->label); LOG0("\nPartition: %s",esp_ota_get_running_partition()->label);
LOG0("\nMAC Address: %s",WiFi.macAddress().c_str()); LOG0("\nMAC Address: %s",Network.macAddress().c_str());
LOG0("\n\nDevice Name: %s\n\n",displayName); LOG0("\n\nDevice Name: %s\n\n",displayName);
@ -155,11 +155,11 @@ void Span::begin(Category catID, const char *_displayName, const char *_hostName
nvs_get_u8(otaNVS,"OTA_REQUIRED",&otaRequired); nvs_get_u8(otaNVS,"OTA_REQUIRED",&otaRequired);
nvs_set_u8(otaNVS,"OTA_REQUIRED",0); nvs_set_u8(otaNVS,"OTA_REQUIRED",0);
nvs_commit(otaNVS); nvs_commit(otaNVS);
if(otaRequired && !spanOTA.enabled){ // if(otaRequired && !spanOTA.enabled){
LOG0("\n\n*** OTA SAFE MODE ALERT: OTA REQUIRED BUT NOT ENABLED. ROLLING BACK TO PREVIOUS APPLICATION ***\n\n"); // LOG0("\n\n*** OTA SAFE MODE ALERT: OTA REQUIRED BUT NOT ENABLED. ROLLING BACK TO PREVIOUS APPLICATION ***\n\n");
delay(100); // delay(100);
esp_ota_mark_app_invalid_rollback_and_reboot(); // esp_ota_mark_app_invalid_rollback_and_reboot();
} // }
} // begin } // begin
@ -268,8 +268,8 @@ void Span::pollTask() {
HAPClient::checkNotifications(); HAPClient::checkNotifications();
HAPClient::checkTimedWrites(); HAPClient::checkTimedWrites();
if(spanOTA.enabled) //D if(spanOTA.enabled)
ArduinoOTA.handle(); //D ArduinoOTA.handle();
if(controlButton && controlButton->primed()) if(controlButton && controlButton->primed())
STATUS_UPDATE(start(LED_ALERT),HS_ENTERING_CONFIG_MODE) STATUS_UPDATE(start(LED_ALERT),HS_ENTERING_CONFIG_MODE)
@ -472,24 +472,24 @@ void Span::checkConnect(){
memcpy(hashInput,qrID,4); // Create the Setup ID for use with optional QR Codes. This is an undocumented feature of HAP R2! memcpy(hashInput,qrID,4); // Create the Setup ID for use with optional QR Codes. This is an undocumented feature of HAP R2!
memcpy(hashInput+4,id,17); // Step 1: Concatenate 4-character Setup ID and 17-character Accessory ID into hashInput memcpy(hashInput+4,id,17); // Step 1: Concatenate 4-character Setup ID and 17-character Accessory ID into hashInput
mbedtls_sha512_ret(hashInput,21,hashOutput,0); // Step 2: Perform SHA-512 hash on combined 21-byte hashInput to create 64-byte hashOutput mbedtls_sha512(hashInput,21,hashOutput,0); // Step 2: Perform SHA-512 hash on combined 21-byte hashInput to create 64-byte hashOutput
mbedtls_base64_encode((uint8_t *)setupHash,9,&len,hashOutput,4); // Step 3: Encode the first 4 bytes of hashOutput in base64, which results in an 8-character, null-terminated, setupHash mbedtls_base64_encode((uint8_t *)setupHash,9,&len,hashOutput,4); // Step 3: Encode the first 4 bytes of hashOutput in base64, which results in an 8-character, null-terminated, setupHash
mdns_service_txt_item_set("_hap","_tcp","sh",setupHash); // Step 4: broadcast the resulting Setup Hash mdns_service_txt_item_set("_hap","_tcp","sh",setupHash); // Step 4: broadcast the resulting Setup Hash
if(spanOTA.enabled){ // if(spanOTA.enabled){
ArduinoOTA.setHostname(hostName); // ArduinoOTA.setHostname(hostName);
//
// if(spanOTA.auth)
// ArduinoOTA.setPasswordHash(spanOTA.otaPwd);
//
// ArduinoOTA.onStart(spanOTA.start).onEnd(spanOTA.end).onProgress(spanOTA.progress).onError(spanOTA.error);
//
// ArduinoOTA.begin();
// LOG0("Starting OTA Server: %s at %s\n",displayName,WiFi.localIP().toString().c_str());
// LOG0("Authorization Password: %s",spanOTA.auth?"Enabled\n\n":"DISABLED!\n\n");
// }
if(spanOTA.auth) //D mdns_service_txt_item_set("_hap","_tcp","ota",spanOTA.enabled?"yes":"no"); // OTA status (info only - NOT used by HAP)
ArduinoOTA.setPasswordHash(spanOTA.otaPwd);
ArduinoOTA.onStart(spanOTA.start).onEnd(spanOTA.end).onProgress(spanOTA.progress).onError(spanOTA.error);
ArduinoOTA.begin();
LOG0("Starting OTA Server: %s at %s\n",displayName,WiFi.localIP().toString().c_str());
LOG0("Authorization Password: %s",spanOTA.auth?"Enabled\n\n":"DISABLED!\n\n");
}
mdns_service_txt_item_set("_hap","_tcp","ota",spanOTA.enabled?"yes":"no"); // OTA status (info only - NOT used by HAP)
if(webLog.isEnabled){ if(webLog.isEnabled){
mdns_service_txt_item_set("_hap","_tcp","logURL",webLog.statusURL.c_str()+4); // Web Log status (info only - NOT used by HAP) mdns_service_txt_item_set("_hap","_tcp","logURL",webLog.statusURL.c_str()+4); // Web Log status (info only - NOT used by HAP)
@ -608,34 +608,34 @@ void Span::processSerialCommand(const char *c){
} }
break; break;
case 'O': { // case 'O': {
//
char textPwd[34]="\0"; // char textPwd[34]="\0";
//
LOG0("\n>>> New OTA Password, or <return> to cancel request: "); // LOG0("\n>>> New OTA Password, or <return> to cancel request: ");
readSerial(textPwd,33); // readSerial(textPwd,33);
//
if(strlen(textPwd)==0){ // if(strlen(textPwd)==0){
LOG0("(cancelled)\n\n"); // LOG0("(cancelled)\n\n");
return; // return;
} // }
//
if(strlen(textPwd)==33){ // if(strlen(textPwd)==33){
LOG0("\n*** Sorry, 32 character limit - request cancelled\n\n"); // LOG0("\n*** Sorry, 32 character limit - request cancelled\n\n");
return; // return;
} // }
//
LOG0("%s\n",mask(textPwd,2).c_str()); // LOG0("%s\n",mask(textPwd,2).c_str());
spanOTA.setPassword(textPwd); // spanOTA.setPassword(textPwd);
nvs_set_str(otaNVS,"OTADATA",spanOTA.otaPwd); // update data // nvs_set_str(otaNVS,"OTADATA",spanOTA.otaPwd); // update data
nvs_commit(otaNVS); // nvs_commit(otaNVS);
//
LOG0("... Accepted! Password change will take effect after next restart.\n"); // LOG0("... Accepted! Password change will take effect after next restart.\n");
if(!spanOTA.enabled) // if(!spanOTA.enabled)
LOG0("... Note: OTA has not been enabled in this sketch.\n"); // LOG0("... Note: OTA has not been enabled in this sketch.\n");
LOG0("\n"); // LOG0("\n");
} // }
break; // break;
case 'S': { case 'S': {
@ -2457,89 +2457,89 @@ void SpanWebLog::vLog(boolean sysMsg, const char *fmt, va_list ap){
// SpanOTA // // SpanOTA //
/////////////////////////////// ///////////////////////////////
int SpanOTA::init(boolean _auth, boolean _safeLoad, const char *pwd){ //int SpanOTA::init(boolean _auth, boolean _safeLoad, const char *pwd){
if(esp_ota_get_running_partition()==esp_ota_get_next_update_partition(NULL)){ // if(esp_ota_get_running_partition()==esp_ota_get_next_update_partition(NULL)){
LOG0("\n*** WARNING: Can't start OTA Server - Partition table used to compile this sketch is not configured for OTA.\n\n"); // LOG0("\n*** WARNING: Can't start OTA Server - Partition table used to compile this sketch is not configured for OTA.\n\n");
return(-1); // return(-1);
} // }
//
enabled=true; // enabled=true;
safeLoad=_safeLoad; // safeLoad=_safeLoad;
auth=_auth; // auth=_auth;
if(pwd==NULL) // if(pwd==NULL)
return(0); // return(0);
return(setPassword(pwd)); // return(setPassword(pwd));
} //}
//
/////////////////////////////// /////////////////////////////////
//
int SpanOTA::setPassword(const char *pwd){ //int SpanOTA::setPassword(const char *pwd){
if(strlen(pwd)<1 || strlen(pwd)>32){ // if(strlen(pwd)<1 || strlen(pwd)>32){
LOG0("\n*** WARNING: Cannot change OTA password to '%s'. Password length must be between 1 and 32 characters.\n\n",pwd); // LOG0("\n*** WARNING: Cannot change OTA password to '%s'. Password length must be between 1 and 32 characters.\n\n",pwd);
return(-1); // return(-1);
} // }
//
MD5Builder otaPwdHash; // MD5Builder otaPwdHash;
otaPwdHash.begin(); // otaPwdHash.begin();
otaPwdHash.add(pwd); // otaPwdHash.add(pwd);
otaPwdHash.calculate(); // otaPwdHash.calculate();
otaPwdHash.getChars(homeSpan.spanOTA.otaPwd); // otaPwdHash.getChars(homeSpan.spanOTA.otaPwd);
return(0); // return(0);
} //}
//
/////////////////////////////// /////////////////////////////////
//
void SpanOTA::start(){ //void SpanOTA::start(){
LOG0("\n*** Current Partition: %s\n*** New Partition: %s\n*** OTA Starting..", // LOG0("\n*** Current Partition: %s\n*** New Partition: %s\n*** OTA Starting..",
esp_ota_get_running_partition()->label,esp_ota_get_next_update_partition(NULL)->label); // esp_ota_get_running_partition()->label,esp_ota_get_next_update_partition(NULL)->label);
otaPercent=0; // otaPercent=0;
STATUS_UPDATE(start(LED_OTA_STARTED),HS_OTA_STARTED) // STATUS_UPDATE(start(LED_OTA_STARTED),HS_OTA_STARTED)
} //}
//
/////////////////////////////// /////////////////////////////////
//
void SpanOTA::end(){ //void SpanOTA::end(){
nvs_set_u8(homeSpan.otaNVS,"OTA_REQUIRED",safeLoad); // nvs_set_u8(homeSpan.otaNVS,"OTA_REQUIRED",safeLoad);
nvs_commit(homeSpan.otaNVS); // nvs_commit(homeSpan.otaNVS);
LOG0(" DONE! Rebooting...\n"); // LOG0(" DONE! Rebooting...\n");
homeSpan.reboot(); // homeSpan.reboot();
} //}
//
/////////////////////////////// /////////////////////////////////
//
void SpanOTA::progress(uint32_t progress, uint32_t total){ //void SpanOTA::progress(uint32_t progress, uint32_t total){
int percent=progress*100/total; // int percent=progress*100/total;
if(percent/10 != otaPercent/10){ // if(percent/10 != otaPercent/10){
otaPercent=percent; // otaPercent=percent;
LOG0("%d%%..",progress*100/total); // LOG0("%d%%..",progress*100/total);
} // }
//
if(safeLoad && progress==total){ // if(safeLoad && progress==total){
SpanPartition newSpanPartition; // SpanPartition newSpanPartition;
esp_partition_read(esp_ota_get_next_update_partition(NULL), sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t) + sizeof(esp_app_desc_t), &newSpanPartition, sizeof(newSpanPartition)); // esp_partition_read(esp_ota_get_next_update_partition(NULL), sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t) + sizeof(esp_app_desc_t), &newSpanPartition, sizeof(newSpanPartition));
LOG0("Checking for HomeSpan Magic Cookie: %s..",newSpanPartition.magicCookie); // LOG0("Checking for HomeSpan Magic Cookie: %s..",newSpanPartition.magicCookie);
if(strcmp(newSpanPartition.magicCookie,spanPartition.magicCookie)) // if(strcmp(newSpanPartition.magicCookie,spanPartition.magicCookie))
Update.abort(); // Update.abort();
} // }
} //}
//
/////////////////////////////// /////////////////////////////////
//
void SpanOTA::error(ota_error_t err){ //void SpanOTA::error(ota_error_t err){
LOG0("*** OTA Error[%u]: ", err); // LOG0("*** OTA Error[%u]: ", err);
if (err == OTA_AUTH_ERROR) LOG0("Auth Failed\n\n"); // if (err == OTA_AUTH_ERROR) LOG0("Auth Failed\n\n");
else if (err == OTA_BEGIN_ERROR) LOG0("Begin Failed\n\n"); // else if (err == OTA_BEGIN_ERROR) LOG0("Begin Failed\n\n");
else if (err == OTA_CONNECT_ERROR) LOG0("Connect Failed\n\n"); // else if (err == OTA_CONNECT_ERROR) LOG0("Connect Failed\n\n");
else if (err == OTA_RECEIVE_ERROR) LOG0("Receive Failed\n\n"); // else if (err == OTA_RECEIVE_ERROR) LOG0("Receive Failed\n\n");
else if (err == OTA_END_ERROR) LOG0("End Failed\n\n"); // else if (err == OTA_END_ERROR) LOG0("End Failed\n\n");
} //}
//
/////////////////////////////// /////////////////////////////////
//
int SpanOTA::otaPercent; //int SpanOTA::otaPercent;
boolean SpanOTA::safeLoad; //boolean SpanOTA::safeLoad;
boolean SpanOTA::enabled=false; //boolean SpanOTA::enabled=false;
boolean SpanOTA::auth; //boolean SpanOTA::auth;
/////////////////////////////// ///////////////////////////////
// SpanPoint // // SpanPoint //
@ -2598,7 +2598,7 @@ void SpanPoint::init(const char *password){
esp_wifi_set_config(WIFI_IF_AP,&conf); esp_wifi_set_config(WIFI_IF_AP,&conf);
uint8_t hash[32]; uint8_t hash[32];
mbedtls_sha256_ret((const unsigned char *)password,strlen(password),hash,0); // produce 256-bit bit hash from password mbedtls_sha256((const unsigned char *)password,strlen(password),hash,0); // produce 256-bit bit hash from password
esp_now_init(); // initialize ESP-NOW esp_now_init(); // initialize ESP-NOW
memcpy(lmk, hash, 16); // store first 16 bytes of hash for later use as local key memcpy(lmk, hash, 16); // store first 16 bytes of hash for later use as local key
@ -2711,7 +2711,8 @@ boolean SpanPoint::send(const void *data){
/////////////////////////////// ///////////////////////////////
void SpanPoint::dataReceived(const uint8_t *mac, const uint8_t *incomingData, int len){ //void SpanPoint::dataReceived(const uint8_t *mac, const uint8_t *incomingData, int len){
void SpanPoint::dataReceived(const esp_now_recv_info *mac, const uint8_t *incomingData, int len){
auto it=SpanPoints.begin(); auto it=SpanPoints.begin();
for(;it!=SpanPoints.end() && memcmp((*it)->peerInfo.peer_addr,mac,6)!=0; it++); for(;it!=SpanPoints.end() && memcmp((*it)->peerInfo.peer_addr,mac,6)!=0; it++);

View File

@ -37,19 +37,19 @@
#include <vector> #include <vector>
#include <list> #include <list>
#include <nvs.h> #include <nvs.h>
#include <ArduinoOTA.h> //D#include <ArduinoOTA.h>
#include <esp_now.h> #include <esp_now.h>
#include <mbedtls/base64.h> #include <mbedtls/base64.h>
#include "src/extras/Blinker.h" #include "src/extras/Blinker.h"
#include "src/extras/Pixel.h" //D #include "src/extras/Pixel.h"
#include "src/extras/RFControl.h" //D #include "src/extras/RFControl.h"
#include "src/extras/PwmPin.h" //D #include "src/extras/PwmPin.h"
#include "src/extras/StepperControl.h" //D #include "src/extras/StepperControl.h"
#include "Settings.h" #include "Settings.h"
#include "Utils.h" #include "Utils.h"
#include "Network.h" #include "Network_HS.h"
#include "HAPConstants.h" #include "HAPConstants.h"
#include "HapQR.h" #include "HapQR.h"
#include "Characteristics.h" #include "Characteristics.h"
@ -186,22 +186,22 @@ struct SpanWebLog{ // optional web status/log data
/////////////////////////////// ///////////////////////////////
struct SpanOTA{ // manages OTA process //struct SpanOTA{ // manages OTA process
//
char otaPwd[33]=""; // MD5 Hash of OTA password, represented as a string of hexidecimal characters // char otaPwd[33]=""; // MD5 Hash of OTA password, represented as a string of hexidecimal characters
//
static boolean enabled; // enables OTA - default if not enabled // static boolean enabled; // enables OTA - default if not enabled
static boolean auth; // indicates whether OTA password is required // static boolean auth; // indicates whether OTA password is required
static int otaPercent; // static int otaPercent;
static boolean safeLoad; // indicates whether OTA update should reject any application update that is not another HomeSpan sketch // static boolean safeLoad; // indicates whether OTA update should reject any application update that is not another HomeSpan sketch
//
int init(boolean auth, boolean safeLoad, const char *pwd); // int init(boolean auth, boolean safeLoad, const char *pwd);
int setPassword(const char *pwd); // int setPassword(const char *pwd);
static void start(); // static void start();
static void end(); // static void end();
static void progress(uint32_t progress, uint32_t total); // static void progress(uint32_t progress, uint32_t total);
static void error(ota_error_t err); // static void error(ota_error_t err);
}; //};
////////////////////////////////////// //////////////////////////////////////
// USER API CLASSES BEGINS HERE // // USER API CLASSES BEGINS HERE //
@ -216,7 +216,7 @@ class Span{
friend class SpanButton; friend class SpanButton;
friend class SpanWebLog; friend class SpanWebLog;
friend class SpanOTA; friend class SpanOTA;
friend class Network; friend class Network_HS;
friend class HAPClient; friend class HAPClient;
char *displayName; // display name for this device - broadcast as part of Bonjour MDNS char *displayName; // display name for this device - broadcast as part of Bonjour MDNS
@ -267,13 +267,13 @@ class Span{
Blinker *statusLED; // indicates HomeSpan status Blinker *statusLED; // indicates HomeSpan status
Blinkable *statusDevice = NULL; // the device used for the Blinker Blinkable *statusDevice = NULL; // the device used for the Blinker
PushButton *controlButton = NULL; // controls HomeSpan configuration and resets PushButton *controlButton = NULL; // controls HomeSpan configuration and resets
Network network; // configures WiFi and Setup Code via either serial monitor or temporary Access Point Network_HS network; // configures WiFi and Setup Code via either serial monitor or temporary Access Point
SpanWebLog webLog; // optional web status/log SpanWebLog webLog; // optional web status/log
TaskHandle_t pollTaskHandle = NULL; // optional task handle to use for poll() function TaskHandle_t pollTaskHandle = NULL; // optional task handle to use for poll() function
TaskHandle_t loopTaskHandle; // Arduino Loop Task handle TaskHandle_t loopTaskHandle; // Arduino Loop Task handle
boolean verboseWifiReconnect = true; // set to false to not print WiFi reconnect attempts messages boolean verboseWifiReconnect = true; // set to false to not print WiFi reconnect attempts messages
SpanOTA spanOTA; // manages OTA process //D SpanOTA spanOTA; // manages OTA process
SpanConfig hapConfig; // track configuration changes to the HAP Accessory database; used to increment the configuration number (c#) when changes found SpanConfig hapConfig; // track configuration changes to the HAP Accessory database; used to increment the configuration number (c#) when changes found
list<HAPClient, Mallocator<HAPClient>> hapList; // linked-list of HAPClient structures containing HTTP client connections, parsing routines, and state variables list<HAPClient, Mallocator<HAPClient>> hapList; // linked-list of HAPClient structures containing HTTP client connections, parsing routines, and state variables
@ -333,10 +333,10 @@ class Span{
int getControlPin(){return(controlButton?controlButton->getPin():-1);} // get Control Pin (returns -1 if undefined) int getControlPin(){return(controlButton?controlButton->getPin():-1);} // get Control Pin (returns -1 if undefined)
Span& setStatusPin(uint8_t pin){statusDevice=new GenericLED(pin);return(*this);} // sets Status Device to a simple LED on specified pin Span& setStatusPin(uint8_t pin){statusDevice=new GenericLED(pin);return(*this);} // sets Status Device to a simple LED on specified pin
Span& setStatusPixel(uint8_t pin,float h=0,float s=100,float v=100){ // sets Status Device to an RGB Pixel on specified pin //D Span& setStatusPixel(uint8_t pin,float h=0,float s=100,float v=100){ // sets Status Device to an RGB Pixel on specified pin
statusDevice=((new Pixel(pin))->setOnColor(Pixel::HSV(h,s,v))); //D statusDevice=((new Pixel(pin))->setOnColor(Pixel::HSV(h,s,v)));
return(*this); //D return(*this);
} //D }
Span& setStatusDevice(Blinkable *sDev){statusDevice=sDev;return(*this);} // sets Status Device to a generic Blinkable object Span& setStatusDevice(Blinkable *sDev){statusDevice=sDev;return(*this);} // sets Status Device to a generic Blinkable object
Span& setStatusAutoOff(uint16_t duration){autoOffLED=duration;return(*this);} // sets Status LED auto off (seconds) Span& setStatusAutoOff(uint16_t duration){autoOffLED=duration;return(*this);} // sets Status LED auto off (seconds)
@ -370,8 +370,8 @@ class Span{
Span& setHostNameSuffix(const char *suffix){asprintf(&hostNameSuffix,"%s",suffix);return(*this);} // sets the hostName suffix to be used instead of the 6-byte AccessoryID Span& setHostNameSuffix(const char *suffix){asprintf(&hostNameSuffix,"%s",suffix);return(*this);} // sets the hostName suffix to be used instead of the 6-byte AccessoryID
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 //D 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) //D 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)
Span& enableWebLog(uint16_t maxEntries=0, const char *serv=NULL, const char *tz="UTC", const char *url=DEFAULT_WEBLOG_URL){ // enable Web Logging Span& enableWebLog(uint16_t maxEntries=0, const char *serv=NULL, const char *tz="UTC", const char *url=DEFAULT_WEBLOG_URL){ // enable Web Logging
webLog.init(maxEntries, serv, tz, url); webLog.init(maxEntries, serv, tz, url);
@ -807,7 +807,7 @@ class SpanPoint {
static QueueHandle_t statusQueue; // queue for communication between SpanPoint::dataSend and SpanPoint::send static QueueHandle_t statusQueue; // queue for communication between SpanPoint::dataSend and SpanPoint::send
static nvs_handle pointNVS; // NVS storage for channel number (only used for remote devices) static nvs_handle pointNVS; // NVS storage for channel number (only used for remote devices)
static void dataReceived(const uint8_t *mac, const uint8_t *incomingData, int len); static void dataReceived(const esp_now_recv_info *mac, const uint8_t *incomingData, int len);
static void init(const char *password="HomeSpan"); static void init(const char *password="HomeSpan");
static void setAsHub(){isHub=true;} static void setAsHub(){isHub=true;}
static uint8_t nextChannel(); static uint8_t nextChannel();

View File

@ -29,7 +29,7 @@
#include <DNSServer.h> #include <DNSServer.h>
#include "Network.h" #include "Network_HS.h"
#include "HomeSpan.h" #include "HomeSpan.h"
#include "Utils.h" #include "Utils.h"
@ -37,7 +37,7 @@ using namespace Utils;
/////////////////////////////// ///////////////////////////////
void Network::scan(){ void Network_HS::scan(){
int n=WiFi.scanNetworks(); int n=WiFi.scanNetworks();
@ -62,7 +62,7 @@ void Network::scan(){
/////////////////////////////// ///////////////////////////////
void Network::serialConfigure(){ void Network_HS::serialConfigure(){
wifiData.ssid[0]='\0'; wifiData.ssid[0]='\0';
wifiData.pwd[0]='\0'; wifiData.pwd[0]='\0';
@ -94,7 +94,7 @@ void Network::serialConfigure(){
/////////////////////////////// ///////////////////////////////
boolean Network::allowedCode(char *s){ boolean Network_HS::allowedCode(char *s){
return( return(
strcmp(s,"00000000") && strcmp(s,"11111111") && strcmp(s,"22222222") && strcmp(s,"33333333") && strcmp(s,"00000000") && strcmp(s,"11111111") && strcmp(s,"22222222") && strcmp(s,"33333333") &&
strcmp(s,"44444444") && strcmp(s,"55555555") && strcmp(s,"66666666") && strcmp(s,"77777777") && strcmp(s,"44444444") && strcmp(s,"55555555") && strcmp(s,"66666666") && strcmp(s,"77777777") &&
@ -103,7 +103,7 @@ boolean Network::allowedCode(char *s){
/////////////////////////////// ///////////////////////////////
void Network::apConfigure(){ void Network_HS::apConfigure(){
LOG0("*** Starting Access Point: %s / %s\n",apSSID,apPassword); LOG0("*** Starting Access Point: %s / %s\n",apSSID,apPassword);
@ -235,7 +235,7 @@ void Network::apConfigure(){
/////////////////////////////// ///////////////////////////////
void Network::processRequest(char *body, char *formData){ void Network_HS::processRequest(char *body, char *formData){
String responseHead="HTTP/1.1 200 OK\r\nContent-type: text/html\r\n"; String responseHead="HTTP/1.1 200 OK\r\nContent-type: text/html\r\n";
@ -368,7 +368,7 @@ void Network::processRequest(char *body, char *formData){
////////////////////////////////////// //////////////////////////////////////
int Network::getFormValue(char *formData, const char *tag, char *value, int maxSize){ int Network_HS::getFormValue(char *formData, const char *tag, char *value, int maxSize){
char *s=strstr(formData,tag); // find start of tag char *s=strstr(formData,tag); // find start of tag
@ -402,7 +402,7 @@ int Network::getFormValue(char *formData, const char *tag, char *value, int maxS
////////////////////////////////////// //////////////////////////////////////
int Network::badRequestError(){ int Network_HS::badRequestError(){
char s[]="HTTP/1.1 400 Bad Request\r\n\r\n"; char s[]="HTTP/1.1 400 Bad Request\r\n\r\n";
LOG2("\n>>>>>>>>>> "); LOG2("\n>>>>>>>>>> ");

View File

@ -27,6 +27,7 @@
#pragma once #pragma once
#include <Arduino.h>
#include <WiFi.h> #include <WiFi.h>
#include "Settings.h" #include "Settings.h"
@ -35,7 +36,7 @@ const int MAX_PWD=64; // max number of characters
/////////////////////////////// ///////////////////////////////
struct Network { struct Network_HS {
const int MAX_HTTP=4095; // max number of bytes in HTTP message const int MAX_HTTP=4095; // max number of bytes in HTTP message
@ -46,7 +47,7 @@ struct Network {
char **ssidList=NULL; char **ssidList=NULL;
int numSSID; int numSSID;
WiFiClient client; // client used for HTTP calls NetworkClient client; // client used for HTTP calls
int waitTime; // time to wait between HTTP refreshed when checking for WiFi connection int waitTime; // time to wait between HTTP refreshed when checking for WiFi connection
unsigned long alarmTimeOut; // alarm time after which access point is shut down and HomeSpan is re-started unsigned long alarmTimeOut; // alarm time after which access point is shut down and HomeSpan is re-started
int apStatus; // tracks access point status (0=timed-out, -1=cancel, 1=save) int apStatus; // tracks access point status (0=timed-out, -1=cancel, 1=save)

View File

@ -100,10 +100,10 @@ void SRP6A::createVerifyCode(const char *setupCode, Verification *vData){
// compute x = SHA512( s | SHA512( I | ":" | P ) ) // compute x = SHA512( s | SHA512( I | ":" | P ) )
memcpy(tBuf,vData->salt,16); // write salt into first 16 bytes of staging buffer memcpy(tBuf,vData->salt,16); // write salt into first 16 bytes of staging buffer
mbedtls_sha512_ret((uint8_t *)icp,strlen(icp),tBuf+16,0); // create hash of username:password and write into last 64 bytes of staging buffer mbedtls_sha512((uint8_t *)icp,strlen(icp),tBuf+16,0); // create hash of username:password and write into last 64 bytes of staging buffer
mbedtls_sha512_ret(tBuf,80,tHash,0); // create second hash of salted, hashed username:password mbedtls_sha512(tBuf,80,tHash,0); // create second hash of salted, hashed username:password
mbedtls_mpi_read_binary(&x,tHash,64); // load hash result into x mbedtls_mpi_read_binary(&x,tHash,64); // load hash result into x
// compute v = g^x %N // compute v = g^x %N
@ -136,7 +136,7 @@ void SRP6A::createPublicKey(const Verification *vData, uint8_t *publicKey){
mbedtls_mpi_write_binary(&N,tBuf,384); // write N into first half of staging buffer mbedtls_mpi_write_binary(&N,tBuf,384); // write N into first half of staging buffer
mbedtls_mpi_write_binary(&g,tBuf+384,384); // write g into second half of staging buffer (fully padded with leading zeros) mbedtls_mpi_write_binary(&g,tBuf+384,384); // write g into second half of staging buffer (fully padded with leading zeros)
mbedtls_sha512_ret(tBuf,768,tHash,0); // create hash of data mbedtls_sha512(tBuf,768,tHash,0); // create hash of data
mbedtls_mpi_read_binary(&k,tHash,64); // load hash result into k mbedtls_mpi_read_binary(&k,tHash,64); // load hash result into k
// compute B = (k*v + g^b) %N // compute B = (k*v + g^b) %N
@ -163,7 +163,7 @@ void SRP6A::createSessionKey(const uint8_t *publicKey, size_t len){
mbedtls_mpi_write_binary(&A,tBuf,384); // write A into first half of staging buffer (padding with initial zeros is less than 384 bytes) mbedtls_mpi_write_binary(&A,tBuf,384); // write A into first half of staging buffer (padding with initial zeros is less than 384 bytes)
mbedtls_mpi_write_binary(&B,tBuf+384,384); // write B into second half of staging buffer (padding with initial zeros is less than 384 bytes) mbedtls_mpi_write_binary(&B,tBuf+384,384); // write B into second half of staging buffer (padding with initial zeros is less than 384 bytes)
mbedtls_sha512_ret(tBuf,768,tHash,0); // create hash of data mbedtls_sha512(tBuf,768,tHash,0); // create hash of data
mbedtls_mpi_read_binary(&u,tHash,64); // load hash result into mpi structure u mbedtls_mpi_read_binary(&u,tHash,64); // load hash result into mpi structure u
// compute S = (A * v^u)^b %N // compute S = (A * v^u)^b %N
@ -176,7 +176,7 @@ void SRP6A::createSessionKey(const uint8_t *publicKey, size_t len){
// compute K = SHA512( PAD(S) ) // compute K = SHA512( PAD(S) )
mbedtls_mpi_write_binary(&S,tBuf,384); // write S into staging buffer (only first half of buffer will be used) mbedtls_mpi_write_binary(&S,tBuf,384); // write S into staging buffer (only first half of buffer will be used)
mbedtls_sha512_ret(tBuf,384,K,0); // create hash of data - this is the SRP SHARED SESSION KEY, K mbedtls_sha512(tBuf,384,K,0); // create hash of data - this is the SRP SHARED SESSION KEY, K
} }
@ -196,13 +196,13 @@ int SRP6A::verifyClientProof(const uint8_t *proof){
// compute M1V = SHA512( SHA512(N) xor SHA512(g) | SHA512(I) | s | A | B | K ) // compute M1V = SHA512( SHA512(N) xor SHA512(g) | SHA512(I) | s | A | B | K )
mbedtls_mpi_write_binary(&N,tBuf,384); // write N into staging buffer mbedtls_mpi_write_binary(&N,tBuf,384); // write N into staging buffer
mbedtls_sha512_ret(tBuf,384,tHash,0); // create hash of data mbedtls_sha512(tBuf,384,tHash,0); // create hash of data
mbedtls_sha512_ret(&g3072,1,tBuf,0); // create hash of g, but place output directly into staging buffer mbedtls_sha512(&g3072,1,tBuf,0); // create hash of g, but place output directly into staging buffer
for(int i=0;i<64;i++) // H(g) -> H(g) XOR H(N), with results in first 64 bytes of staging buffer for(int i=0;i<64;i++) // H(g) -> H(g) XOR H(N), with results in first 64 bytes of staging buffer
tBuf[i]^=tHash[i]; tBuf[i]^=tHash[i];
mbedtls_sha512_ret((uint8_t *)I,strlen(I),tBuf+64,0); // create hash of userName and concatenate result to end of staging buffer mbedtls_sha512((uint8_t *)I,strlen(I),tBuf+64,0); // create hash of userName and concatenate result to end of staging buffer
mbedtls_mpi_write_binary(&s,tBuf+128,16); // concatenate s to staging buffer mbedtls_mpi_write_binary(&s,tBuf+128,16); // concatenate s to staging buffer
@ -217,7 +217,7 @@ int SRP6A::verifyClientProof(const uint8_t *proof){
memcpy(tBuf+count,K,64); // concatenate K to staging buffer (should always be 64 bytes since it is a hashed value) memcpy(tBuf+count,K,64); // concatenate K to staging buffer (should always be 64 bytes since it is a hashed value)
count+=64; // final total of bytes written to staging buffer count+=64; // final total of bytes written to staging buffer
mbedtls_sha512_ret(tBuf,count,tHash,0); // create hash of data - this is M1V mbedtls_sha512(tBuf,count,tHash,0); // create hash of data - this is M1V
if(!memcmp(M1,tHash,64)) // check that client Proof M1 matches M1V if(!memcmp(M1,tHash,64)) // check that client Proof M1 matches M1V
return(1); // success - proof from HAP Client is verified return(1); // success - proof from HAP Client is verified
@ -236,7 +236,7 @@ void SRP6A::createAccProof(uint8_t *proof){
mbedtls_mpi_write_binary(&A,tBuf,384); // write A into staging buffer mbedtls_mpi_write_binary(&A,tBuf,384); // write A into staging buffer
memcpy(tBuf+384,M1,64); // concatenate M1 (now verified) to staging buffer memcpy(tBuf+384,M1,64); // concatenate M1 (now verified) to staging buffer
memcpy(tBuf+448,K,64); // concatenate K to staging buffer memcpy(tBuf+448,K,64); // concatenate K to staging buffer
mbedtls_sha512_ret(tBuf,512,proof,0); // create hash of data writing directly to proof - this is M2 mbedtls_sha512(tBuf,512,proof,0); // create hash of data writing directly to proof - this is M2
} }

View File

@ -1,30 +0,0 @@
/*********************************************************************************
* MIT License
*
* Copyright (c) 2020-2022 Gregg E. Berman
*
* https://github.com/HomeSpan/HomeSpan
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
********************************************************************************/
#pragma once
#include "../src/extras/Blinker.h"

View File

@ -1,30 +0,0 @@
/*********************************************************************************
* MIT License
*
* Copyright (c) 2020-2022 Gregg E. Berman
*
* https://github.com/HomeSpan/HomeSpan
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
********************************************************************************/
#pragma once
#include "../src/extras/Pixel.h"

View File

@ -1,30 +0,0 @@
/*********************************************************************************
* MIT License
*
* Copyright (c) 2020-2022 Gregg E. Berman
*
* https://github.com/HomeSpan/HomeSpan
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
********************************************************************************/
#pragma once
#include "../src/extras/PwmPin.h"

View File

@ -1,30 +0,0 @@
/*********************************************************************************
* MIT License
*
* Copyright (c) 2020-2022 Gregg E. Berman
*
* https://github.com/HomeSpan/HomeSpan
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
********************************************************************************/
#pragma once
#include "../src/extras/RFControl.h"

View File

@ -1,30 +0,0 @@
/*********************************************************************************
* MIT License
*
* Copyright (c) 2020-2023 Gregg E. Berman
*
* https://github.com/HomeSpan/HomeSpan
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
********************************************************************************/
#pragma once
#include "../src/extras/StepperControl.h"

View File

@ -1,30 +0,0 @@
/*********************************************************************************
* MIT License
*
* Copyright (c) 2020-2022 Gregg E. Berman
*
* https://github.com/HomeSpan/HomeSpan
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
********************************************************************************/
#pragma once
#include "../src/extras/Stepper_A3967.h"

View File

@ -1,30 +0,0 @@
/*********************************************************************************
* MIT License
*
* Copyright (c) 2020-2022 Gregg E. Berman
*
* https://github.com/HomeSpan/HomeSpan
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
********************************************************************************/
#pragma once
#include "../src/extras/Stepper_TB6612.h"

View File

@ -1 +0,0 @@
// This is a placeholder .ino file that allows for editing of top-level "extras" header files.

View File

@ -27,61 +27,23 @@
#include "HomeSpan.h" #include "HomeSpan.h"
CUSTOM_CHAR(TestChar,3F4F,PR+PW,UINT8,20,0,100,false)
CUSTOM_CHAR_STRING(TestString,3F45,PR+EV,"Hello");
CUSTOM_CHAR_TLV8(TestTLV,45674F457,PW+PR);
CUSTOM_CHAR_DATA(TestData,303,PW+PW);
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
homeSpan.setLogLevel(2);
homeSpan.enableWebLog();
homeSpan.begin(Category::Lighting,"HomeSpan LightBulb"); homeSpan.begin(Category::Lighting,"HomeSpan LightBulb");
new SpanUserCommand('D', " - disconnect WiFi", [](const char *buf){WiFi.disconnect();});
new SpanAccessory(); new SpanAccessory();
new Service::AccessoryInformation(); new Service::AccessoryInformation();
new Characteristic::Identify(); new Characteristic::Identify();
new Service::LightBulb(); new Service::LightBulb();
new Characteristic::On(); new Characteristic::On();
new Characteristic::TestChar(30);
new Characteristic::TestString();
new Characteristic::TestString("MyName");
new Characteristic::TestTLV();
Characteristic::TestData *testData = new Characteristic::TestData();
TLV8 myTLV;
myTLV.add(5,0x20);
myTLV.add(5,0x30);
myTLV.add(1);
myTLV.add(5,255);
Characteristic::TestTLV *testTLV = new Characteristic::TestTLV(myTLV);
size_t n=testTLV->getData(NULL,0);
uint8_t buf[n];
testTLV->getData(buf,n);
Serial.printf("\n");
for(int i=0;i<n;i++)
Serial.printf("%d %0X\n",i,buf[i]);
Serial.printf("\n");
testData->setData(buf,8);
} }
////////////////////////////////////// //////////////////////////////////////
void loop(){ void loop(){
homeSpan.poll(); homeSpan.poll();
} }
//////////////////////////////////////

View File

@ -25,12 +25,16 @@
* *
********************************************************************************/ ********************************************************************************/
#ifdef HS_PIXEL
//////////////////////////////////////////// ////////////////////////////////////////////
// Addressable LEDs // // Addressable LEDs //
//////////////////////////////////////////// ////////////////////////////////////////////
#include "Pixel.h" #include "Pixel.h"
#warning "Pixel.cpp Compiling"
//////////////////////////////////////////// ////////////////////////////////////////////
// Single-Wire RGB/RGBW NeoPixels // // Single-Wire RGB/RGBW NeoPixels //
//////////////////////////////////////////// ////////////////////////////////////////////
@ -203,3 +207,5 @@ void Dot::set(Color *c, int nPixels, boolean multiColor){
} }
//////////////////////////////////////////// ////////////////////////////////////////////
#endif

View File

@ -31,6 +31,8 @@
#pragma once #pragma once
#warning "Pixel.h Included"
#include "RFControl.h" #include "RFControl.h"
#include "PwmPin.h" #include "PwmPin.h"
#include "Blinker.h" #include "Blinker.h"

View File

@ -27,6 +27,8 @@
#include "PwmPin.h" #include "PwmPin.h"
#warning "PwmPin.cpp Compiling"
/////////////////// ///////////////////
LedC::LedC(uint8_t pin, uint16_t freq, boolean invert){ LedC::LedC(uint8_t pin, uint16_t freq, boolean invert){

View File

@ -42,6 +42,8 @@
#pragma once #pragma once
#warning "PwmPin.h Included"
#include <Arduino.h> #include <Arduino.h>
#include <driver/ledc.h> #include <driver/ledc.h>
#include "Blinker.h" #include "Blinker.h"

View File

@ -27,6 +27,8 @@
#include "RFControl.h" #include "RFControl.h"
#warning "RFControl.cpp Compiling"
/////////////////// ///////////////////
RFControl::RFControl(uint8_t pin, boolean refClock, boolean installDriver){ RFControl::RFControl(uint8_t pin, boolean refClock, boolean installDriver){

View File

@ -31,6 +31,8 @@
#pragma once #pragma once
#warning "RFControl.h Included"
#include <Arduino.h> #include <Arduino.h>
#include <soc/rmt_reg.h> #include <soc/rmt_reg.h>
#include "driver/rmt.h" #include "driver/rmt.h"

View File

@ -27,6 +27,8 @@
#include "StepperControl.h" #include "StepperControl.h"
#warning "StepperControl.cpp Compiling"
////////////////////////// //////////////////////////
StepperControl::StepperControl(uint32_t priority, uint32_t cpu){ StepperControl::StepperControl(uint32_t priority, uint32_t cpu){

View File

@ -27,6 +27,8 @@
#pragma once #pragma once
#warning "StepperControl.h Included"
#include <Arduino.h> #include <Arduino.h>
#include "PwmPin.h" #include "PwmPin.h"

View File

@ -43,8 +43,8 @@
#include <esp_arduino_version.h> #include <esp_arduino_version.h>
#if ESP_ARDUINO_VERSION_MAJOR!=2 #if ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3, 0, 2)
#error ERROR: HOMESPAN REQUIRES VERSION 2 OF THE ARDUINO ESP32 LIBRARY. HOMESPAN IS NOT COMPATIBLE WITH VERSION 1 OR VERSION 3 #error ERROR: THIS VERSION OF HOMESPAN REQUIRES VERSION 3.0.2 OR GREATER OF THE ARDUINO-ESP32 BOARD MANAGER
#include <FATAL_ERROR> #include <FATAL_ERROR>
#endif #endif