Skip to content

Commit

Permalink
Added video doorbell services and characteristics
Browse files Browse the repository at this point in the history
The video doorbell service depends on a doorbell service which in turn depends on more services and characteristics. I've implemented that whole tree of dependencies.

The video services with the respective tlv8 configs are only stubbed out and a WIP.
  • Loading branch information
lukehoersten committed Mar 7, 2021
1 parent 389189a commit d2f9e57
Show file tree
Hide file tree
Showing 4 changed files with 226 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
Expand Down
83 changes: 83 additions & 0 deletions components/homekit/esp_hap_apple_profiles/src/hap_apple_chars.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
95 changes: 95 additions & 0 deletions components/homekit/esp_hap_apple_profiles/src/hap_apple_servs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit d2f9e57

Please sign in to comment.