update homekit

This commit is contained in:
gemu2015 2021-03-17 13:33:55 +01:00
parent dce555cf6b
commit 1d38a6465d
7 changed files with 61 additions and 21 deletions

2
lib/libesp32_div/ESP32-HomeKit/src/_esp_hap_config.h Normal file → Executable file
View File

@ -14,7 +14,7 @@
#define CONFIG_HAP_HTTP_STACK_SIZE 12288
#define CONFIG_HAP_HTTP_SERVER_PORT 5556 // 80 for normal webserver
#define CONFIG_HAP_HTTP_CONTROL_PORT 32859
#define CONFIG_HAP_HTTP_MAX_OPEN_SOCKETS 6
#define CONFIG_HAP_HTTP_MAX_OPEN_SOCKETS 5 // 6
#define CONFIG_HAP_HTTP_MAX_URI_HANDLERS 16
#endif /* ESP_HAP_CONFIG_H_ */

0
lib/libesp32_div/ESP32-HomeKit/src/hap.h Normal file → Executable file
View File

17
lib/libesp32_div/ESP32-HomeKit/src/hap_apple_chars.c Normal file → Executable file
View File

@ -39,6 +39,21 @@ hap_char_t *hap_char_brightness_create(int brightness)
return hc;
}
/* Char: Brightness */
hap_char_t *hap_char_wattage_create(float watts)
{
hap_char_t *hc = hap_char_float_create(HAP_CHAR_UUID_CURRENT_AMBIENT_LIGHT_LEVEL,
HAP_CHAR_PERM_PR | HAP_CHAR_PERM_PW | HAP_CHAR_PERM_EV, watts);
if (!hc) {
return NULL;
}
hap_char_float_set_constraints(hc, -10000.0, 10000.0, 1);
hap_char_add_unit(hc, HAP_CHAR_UNIT_LUX);
return hc;
}
/* Char: Cooling Threshold Temperature */
hap_char_t *hap_char_cooling_threshold_temperature_create(float cooling_threshold_temp)
{
@ -1284,7 +1299,7 @@ hap_char_t *hap_char_relative_humidity_humidifier_threshold_create(float rel_hum
}
hap_char_float_set_constraints(hc, 0.0, 100.0, 1.0);
hap_char_add_unit(hc, HAP_CHAR_UNIT_PERCENTAGE);
hap_char_add_unit(hc, HAP_CHAR_UNIT_LUX);
return hc;
}

3
lib/libesp32_div/ESP32-HomeKit/src/hap_apple_chars.h Normal file → Executable file
View File

@ -142,6 +142,7 @@ extern "C" {
#define HAP_CHAR_UUID_REMAINING_DURATION "D4"
#define HAP_CHAR_UUID_VALVE_TYPE "D5"
#define HAP_CHAR_UUID_IS_CONFIGURED "D6"
#define HAP_CHAR_UUID_WATTAGE "DC"
#define HAP_CHAR_UUID_PRODUCT_DATA "220"
/** Create Brightness Characteristic
@ -1415,6 +1416,8 @@ hap_char_t *hap_char_air_particulate_density_create(float air_particulate_densit
*/
hap_char_t *hap_char_air_particulate_size_create(uint8_t air_particulate_size);
hap_char_t *hap_char_wattage_create(float watts);
#ifdef __cplusplus
}
#endif

17
lib/libesp32_div/ESP32-HomeKit/src/hap_apple_servs.c Normal file → Executable file
View File

@ -419,6 +419,22 @@ err:
return NULL;
}
hap_serv_t *hap_serv_wattage_create(float curr_watts)
{
hap_serv_t *hs = hap_serv_create(HAP_SERV_UUID_LIGHT_SENSOR);
if (!hs) {
return NULL;
}
if (hap_serv_add_char(hs, hap_char_wattage_create(curr_watts)) != HAP_SUCCESS) {
goto err;
}
return hs;
err:
hap_serv_delete(hs);
return NULL;
}
hap_serv_t *hap_serv_temperature_sensor_create(float curr_temp)
{
hap_serv_t *hs = hap_serv_create(HAP_SERV_UUID_TEMPERATURE_SENSOR);
@ -703,4 +719,3 @@ err:
hap_serv_delete(hs);
return NULL;
}

4
lib/libesp32_div/ESP32-HomeKit/src/hap_apple_servs.h Normal file → Executable file
View File

@ -75,6 +75,7 @@ extern "C" {
#define HAP_SERV_UUID_VALVE "D0"
#define HAP_SERV_UUID_FAUCET "D7"
/** Create Accessory Information Service
*
* This API will create the Accessory Information Service with the mandatory
@ -553,6 +554,9 @@ hap_serv_t *hap_serv_valve_create(uint8_t active, uint8_t in_use, uint8_t valve_
*/
hap_serv_t *hap_serv_faucet_create(uint8_t active);
hap_serv_t *hap_serv_wattage_create(float curr_watts);
#ifdef __cplusplus
}
#endif

View File

@ -144,12 +144,10 @@ int hap_platform_keystore_delete_namespace(const char *part_name, const char *na
while (true) {
File entry = fp.openNextFile();
if (!entry) break;
char fp[48];
strcpy(fp,path);
strcat(fp, "/");
strcat(fp, entry.name());
ffsp->remove(fp);
char p[48];
strcpy(p,entry.name());
entry.close();
ffsp->remove(p);
}
}
return 0;
@ -157,7 +155,6 @@ int hap_platform_keystore_delete_namespace(const char *part_name, const char *na
// last resort only
int hap_platfrom_keystore_erase_partition(const char *part_name) {
// LITTLEFS.format();
char path[48];
strcpy(path, "/");
strcat(path, part_name);
@ -166,17 +163,23 @@ if (fp.isDirectory()) {
while (true) {
File entry = fp.openNextFile();
if (!entry) break;
char fp[48];
strcpy(fp,path);
strcat(fp, "/");
strcat(fp, entry.name());
if (entry.isDirectory()) {
hap_platform_keystore_delete_namespace(part_name, entry.name());
ffsp->rmdir(fp);
} else {
ffsp->remove(fp);
const char *ep = entry.name();
if (*ep=='/') ep++;
char *lcp = strrchr(ep,'/');
if (lcp) {
ep = lcp + 1;
}
char p[48];
strcpy(p,entry.name());
if (entry.isDirectory()) {
hap_platform_keystore_delete_namespace(part_name, ep);
entry.close();
ffsp->rmdir(p);
} else {
entry.close();
ffsp->remove(p);
}
}
}
return 0;