diff --git a/components/homekit/esp_hap_apple_profiles/include/hap_apple_chars.h b/components/homekit/esp_hap_apple_profiles/include/hap_apple_chars.h index e734a6e..92dd16a 100644 --- a/components/homekit/esp_hap_apple_profiles/include/hap_apple_chars.h +++ b/components/homekit/esp_hap_apple_profiles/include/hap_apple_chars.h @@ -142,6 +142,13 @@ 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_SUPPORTED_VIDEO_STREAM_CONFIGURATION "114" +#define HAP_CHAR_UUID_SUPPORTED_AUDIO_CONFIGURATION "115" +#define HAP_CHAR_UUID_SUPPORTED_RTP_CONFIGURATION "116" +#define HAP_CHAR_UUID_SELECTED_RTP_STREAM_CONFIGURATION "117" +#define HAP_CHAR_UUID_SETUP_ENDPOINTS "118" +#define HAP_CHAR_UUID_STREAMING_STATUS "120" +#define HAP_CHAR_UUID_MUTE "11A" #define HAP_CHAR_UUID_PRODUCT_DATA "220" /** Create Brightness Characteristic @@ -1415,6 +1422,14 @@ 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_supported_video_stream_configuration_create(hap_tlv8_val_t *config); +hap_char_t *hap_char_supported_audio_configuration_create(hap_tlv8_val_t *config); +hap_char_t *hap_char_supported_rtp_configuration_create(hap_tlv8_val_t *config); +hap_char_t *hap_char_selected_rtp_stream_configuration_create(hap_tlv8_val_t *config); +hap_char_t *hap_char_setup_endpoints_create(hap_tlv8_val_t *config); +hap_char_t *hap_char_streaming_status_create(hap_tlv8_val_t *status); +hap_char_t *hap_char_mute_create(bool on); + #ifdef __cplusplus } #endif diff --git a/components/homekit/esp_hap_apple_profiles/include/hap_apple_servs.h b/components/homekit/esp_hap_apple_profiles/include/hap_apple_servs.h index e3f6101..334d520 100644 --- a/components/homekit/esp_hap_apple_profiles/include/hap_apple_servs.h +++ b/components/homekit/esp_hap_apple_profiles/include/hap_apple_servs.h @@ -74,6 +74,10 @@ extern "C" { #define HAP_SERV_UUID_IRRIGATION_SYSTEM "CF" #define HAP_SERV_UUID_VALVE "D0" #define HAP_SERV_UUID_FAUCET "D7" +#define HAP_SERV_UUID_CAMERA_RTP_STREAM_MANAGEMENT "110" +#define HAP_SERV_UUID_MICROPHONE "112" +#define HAP_SERV_UUID_SPEAKER "113" +#define HAP_SERV_UUID_DOORBELL "121" /** Create Accessory Information Service * @@ -553,6 +557,35 @@ 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_camera_rtp_stream_management_create(hap_tlv8_val_t *config); +hap_serv_t *hap_serv_microphone_create(uint8_t mute_on); +hap_serv_t *hap_serv_speaker_create(uint8_t mute_on); + +/** Create Doorbell Service + * + * This API will create the Doorbell Service with the mandatory + * characteristics as per the HAP Specs. + * + * @param[in] programmable_switch_event Initial value of Programmable Switch Event characteristic + * + * @return Pointer to the service object on success + * @return NULL on failure + */ +hap_serv_t *hap_serv_doorbell_create(uint8_t programmable_switch_event); + +/** Create Video Doorbell Service + * + * This API will create the Video Doorbell Service with the mandatory + * characteristics as per the HAP Specs. + * + * @param[in] programmable_switch_event Initial value of Programmable Switch Event characteristic + * @param[in] config Accepts config from TLV8 commands + * + * @return Pointer to the service object on success + * @return NULL on failure + */ +hap_serv_t *hap_serv_video_doorbell_create(uint8_t programmable_switch_event, hap_tlv8_val_t *config); + #ifdef __cplusplus } #endif diff --git a/components/homekit/esp_hap_apple_profiles/src/hap_apple_chars.c b/components/homekit/esp_hap_apple_profiles/src/hap_apple_chars.c index 773cf31..5931ec9 100644 --- a/components/homekit/esp_hap_apple_profiles/src/hap_apple_chars.c +++ b/components/homekit/esp_hap_apple_profiles/src/hap_apple_chars.c @@ -1480,3 +1480,86 @@ hap_char_t *hap_char_air_particulate_size_create(uint8_t air_particulate_size) return hc; } + +/* Char: Supported Video Stream Configuration */ +hap_char_t *hap_char_supported_video_stream_configuration_create(hap_tlv8_val_t *config) +{ + hap_char_t *hc = hap_char_tlv8_create(HAP_CHAR_UUID_SUPPORTED_VIDEO_STREAM_CONFIGURATION, + HAP_CHAR_PERM_PR, config); + if (!hc) { + return NULL; + } + + return hc; +} + +/* Char: Supported Audio Configuration */ +hap_char_t *hap_char_supported_audio_configuration_create(hap_tlv8_val_t *config) +{ + hap_char_t *hc = hap_char_tlv8_create(HAP_CHAR_UUID_SUPPORTED_AUDIO_CONFIGURATION, + HAP_CHAR_PERM_PR, config); + if (!hc) { + return NULL; + } + + return hc; +} + +/* Char: Supported RTP Configuration */ +hap_char_t *hap_char_supported_rtp_configuration_create(hap_tlv8_val_t *config) +{ + hap_char_t *hc = hap_char_tlv8_create(HAP_CHAR_UUID_SUPPORTED_RTP_CONFIGURATION, + HAP_CHAR_PERM_PR, config); + if (!hc) { + return NULL; + } + + return hc; +} + +/* Char: Selected RTP Stream Configuration */ +hap_char_t *hap_char_selected_rtp_stream_configuration_create(hap_tlv8_val_t *config) +{ + hap_char_t *hc = hap_char_tlv8_create(HAP_CHAR_UUID_SELECTED_RTP_STREAM_CONFIGURATION, + HAP_CHAR_PERM_PR | HAP_CHAR_PERM_PW, config); + if (!hc) { + return NULL; + } + + return hc; +} + +/* Char: Setup Endpoints Configuration */ +hap_char_t *hap_char_setup_endpoints_create(hap_tlv8_val_t *config) +{ + hap_char_t *hc = hap_char_tlv8_create(HAP_CHAR_UUID_SETUP_ENDPOINTS, + HAP_CHAR_PERM_PR | HAP_CHAR_PERM_PW, config); + if (!hc) { + return NULL; + } + + return hc; +} + +/* Char: Streaming Status */ +hap_char_t *hap_char_streaming_status_create(hap_tlv8_val_t *status) +{ + hap_char_t *hc = hap_char_tlv8_create(HAP_CHAR_UUID_STREAMING_STATUS, + HAP_CHAR_PERM_PR | HAP_CHAR_PERM_EV, status); + if (!hc) { + return NULL; + } + + return hc; +} + +/* Char: Mute */ +hap_char_t *hap_char_mute_create(bool on) +{ + hap_char_t *hc = hap_char_bool_create(HAP_CHAR_UUID_MUTE, + HAP_CHAR_PERM_PR | HAP_CHAR_PERM_PW | HAP_CHAR_PERM_EV, on); + if (!hc) { + return NULL; + } + return hc; +} diff --git a/components/homekit/esp_hap_apple_profiles/src/hap_apple_servs.c b/components/homekit/esp_hap_apple_profiles/src/hap_apple_servs.c index b878369..12361ae 100644 --- a/components/homekit/esp_hap_apple_profiles/src/hap_apple_servs.c +++ b/components/homekit/esp_hap_apple_profiles/src/hap_apple_servs.c @@ -704,3 +704,98 @@ hap_serv_t *hap_serv_faucet_create(uint8_t active) return NULL; } +hap_serv_t *hap_serv_camera_rtp_stream_management_create(hap_tlv8_val_t *config) +{ + hap_serv_t *hs = hap_serv_create(HAP_SERV_UUID_CAMERA_RTP_STREAM_MANAGEMENT); + if (!hs) { + return NULL; + } + if (hap_serv_add_char(hs, hap_char_supported_video_stream_configuration_create(config)) != HAP_SUCCESS) { + goto err; + } + if (hap_serv_add_char(hs, hap_char_supported_audio_configuration_create(config)) != HAP_SUCCESS) { + goto err; + } + if (hap_serv_add_char(hs, hap_char_supported_rtp_configuration_create(config)) != HAP_SUCCESS) { + goto err; + } + if (hap_serv_add_char(hs, hap_char_selected_rtp_stream_configuration_create(config)) != HAP_SUCCESS) { + goto err; + } + if (hap_serv_add_char(hs, hap_char_setup_endpoints_create(config)) != HAP_SUCCESS) { + goto err; + } + if (hap_serv_add_char(hs, hap_char_streaming_status_create(config)) != HAP_SUCCESS) { + goto err; + } + return hs; +err: + hap_serv_delete(hs); + return NULL; +} + +hap_serv_t *hap_serv_microphone_create(uint8_t mute_on) +{ + hap_serv_t *hs = hap_serv_create(HAP_SERV_UUID_MICROPHONE); + if (!hs) { + return NULL; + } + if (hap_serv_add_char(hs, hap_char_mute_create(mute_on)) != HAP_SUCCESS) { + goto err; + } + return hs; +err: + hap_serv_delete(hs); + return NULL; +} + +hap_serv_t *hap_serv_speaker_create(uint8_t mute_on) +{ + hap_serv_t *hs = hap_serv_create(HAP_SERV_UUID_SPEAKER); + if (!hs) { + return NULL; + } + if (hap_serv_add_char(hs, hap_char_mute_create(mute_on)) != HAP_SUCCESS) { + goto err; + } + return hs; +err: + hap_serv_delete(hs); + return NULL; +} + +hap_serv_t *hap_serv_doorbell_create(uint8_t programmable_switch_event) +{ + hap_serv_t *hs = hap_serv_create(HAP_SERV_UUID_DOORBELL); + if (!hs) { + return NULL; + } + if (hap_serv_add_char(hs, hap_char_programmable_switch_event_create(programmable_switch_event)) != HAP_SUCCESS) { + goto err; + } + return hs; +err: + hap_serv_delete(hs); + return NULL; +} + +hap_serv_t *hap_serv_video_doorbell_create(uint8_t programmable_switch_event, hap_tlv8_val_t *config) +{ + hap_serv_t *hs = hap_serv_doorbell_create(programmable_switch_event); + if (!hs) { + return NULL; + } + if (hap_serv_add_char(hs, hap_serv_camera_rtp_stream_management_create(config)) != HAP_SUCCESS) { + goto err; + } + if (hap_serv_add_char(hs, hap_serv_microphone_create(true)) != HAP_SUCCESS) { + goto err; + } + if (hap_serv_add_char(hs, hap_serv_speaker_create(true)) != HAP_SUCCESS) { + goto err; + } + return hs; +err: + hap_serv_delete(hs); + return NULL; +}