Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Characteristic Notifcations #29

Closed
shaurya0406 opened this issue Mar 10, 2021 · 7 comments
Closed

Characteristic Notifcations #29

shaurya0406 opened this issue Mar 10, 2021 · 7 comments

Comments

@shaurya0406
Copy link

How to update the temperature sensor value in the Home app at a particular interval in a function other than the read callback.
I have tried hap_char_update_val() and my characteristic has the HAP_CHAR_PERM_PR and HAP_CHAR_PERM_EV permissions. But this doesn't automatically update in Home iOS app.
I have to refresh the app or ask Siri, which means that only the read callback is being triggered.
What am I doing wrong?

@shahpiyushv
Copy link
Collaborator

@shaurya0406 , hap_char_update_val() indeed is sufficient to invoke event notification. However, the controller first needs to subscribe to it. Can you call the function hap_http_debug_enable() before hap_start() and see if the controller is subscribing to the events? Even without these additional debug messages, you should atleast see text like this if the controller is subscribing to the event notifications

Events Enabled for aid=1 iid=12

@shaurya0406
Copy link
Author

Thank you for the quick reply.
I am getting these logs:
Events Enabled for aid=3 iid=9
Events Enabled for aid=4 iid=9
Events Enabled for aid=4 iid=11
Events Enabled for aid=2 iid=11
Events Enabled for aid=2 iid=14

This is for bridge accessory

@shaurya0406
Copy link
Author

It was an error on my side.
I forgot to call hap_serv_get_char_by_uuid() in the bridge thread so I was updating to unknown characteristic.
Thank you
and I am closing this issue

@skylli
Copy link

skylli commented Mar 18, 2021

@shahpiyushv

HomeKit App still can't get the notification from outlet when run examples/smart_outlet.

I just idf.py build the examples/smart_outlet project, and burn to my esp32 board, but my homekit app still can receive any notification on my iphone.
My esp32 board can receive the http request from homekit app when i tap the button.
Here is my log:

Socket fd: 51; HTTP Request GET /characteristics?id=1.12
Generating HTTP Response
{"characteristics":[{"aid":1,"iid":12,"value":true}]}
Socket fd: 51; HTTP Request PUT /characteristics
Data Received: {"characteristics":[{"aid":1,"iid":12,"value":0}]}
I (521178) HAP outlet: Received Write. Outlet Off
_hc->format 1  val 0 old val 1
Value Changed 1
E (524548) Button:  press
Value Changed 1
Notification Sent
Socket fd: 51; Event message: {"characteristics":[{"aid":1,"iid":13,"value":false}]}
D (524558) [system, 51]: handle tap event
I (524558) HAP outlet: Outlet-In-Use triggered [0]

What am I going to do to get device notification?

@shahpiyushv
Copy link
Collaborator

@skylli , how exactly are you checking this? You have to tap and hold the Outlet tile n the Home app, then go to Settings (gear icon on bottom right) and there you can see the outlet in use status changing. Once you press the button, it will show the value as No, and on releasing it will show Yes. Check this screen recording.

RPReplay_Final1616078167.MP4

P.S. There could be other ways of checking Outlet-In-Use, but this is where I check it.

@skylli
Copy link

skylli commented Mar 19, 2021

@shahpiyushv
Thank you for your quick reply
I didn't notice that there were no hap_serv_get_char_by_uuid(service, HAP_CHAR_UUID_ON) in this example.

@leotordo
Copy link

hap_serv_get_char_by_uuid()

Hello,
I've a similar problem with my board. I driver a led from Home app and works fine.
I've a mechanical switch to switch on/off the led that I read on a input pin of my ESP32.
Can you give me help to update the status on the iPhone?
The led turns off, but on the Home app it remains on
Thanks
Andrea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants