Code Monkey home page Code Monkey logo

Comments (6)

Brawrdon avatar Brawrdon commented on July 20, 2024 2

@Mixiaoxiao thanks for looking into this! After rebooting my router 700 times, I managed to solve the issue by assigning a static IP address to my ESP32. I've removed the static assignment to test this fix and it seems to be working. I'll report if I notice a crash!

Off topic but I just wanted to add that I'm also working on an Arduino version of this SDK and it's currently available via PlatformIO. 😄

from esp-homekit-sdk.

Mixiaoxiao avatar Mixiaoxiao commented on July 20, 2024 1

Thanks for your quick replay.
It is ok to modify by yourself, following the sdk's code style.
I consider it will be nice to make a comment in your modification with a link of this issuse analysis, if it is possible.

Also, I sugest the function names:

  1. change hap_close_ctrl_sessions (ctrl) to hap_close_sessions_of_ctrl (ctrl)
  2. create a new hap_close_session (session) to close a certain session (irrelevant with ctrl)
  3. the name of hap_decrypt_error may be not suitable here, since it is caused by a connection lost in most cases

from esp-homekit-sdk.

drewandre avatar drewandre commented on July 20, 2024 1

Hopefully this helps someone in the future, but I was receiving this error after assigning a value that was out of range for a characteristic that can only accept values of 0-100. I was using the provided hap_char_hue_create fxn to set the lightbulb hue but didn't see that within that fxn there's a hap_char_float_set_constraints fxn that shows that this specific characteristic has a lower bound of 0 and an upper of 360. It would be nice to be warned when passing a value that falls outside of characteristic ranges but it was pretty obvious after a minute of following the function calls.

from esp-homekit-sdk.

shahpiyushv avatar shahpiyushv commented on July 20, 2024

@Mixiaoxiao thanks for the detailed analysis. Rightly said, the below snippet indeed seems wrong and a root cause for the issues reported.

	for (i = 0; i < HAP_MAX_SESSIONS; i++) {
        	if (!hap_priv.sessions[i])
              		continue;
		if (hap_priv.sessions[i]->ctrl == ctrl) {
			httpd_sess_trigger_close(hap_priv.server, hap_priv.sessions[i]->conn_identifier);
		}
	}

I have verified with your fix and it works as intended.

The changes in the check for return value of read_fn() may not be required though, since the code is normally supposed to reach here, only when the select call in http_server returns and the particular socket descriptor is ready to be read. Even if we return 0 from here, the http server code will close the session assuming that the peer has closed the connection.

Do you plan to raise a PR for these fixes, or should I add them myself? In my code, I have renamed hap_close_ctrl_sessions to hap_ctrl_close_all_sessions and added a new hap_ctrl_close_single_session as per the code you shared. I will also add a config option for keepalive, which will be enabled automatically for non MFi HomeKit applications.

Meanwhile, thanks for your efforts for the Arduino support :)

from esp-homekit-sdk.

shahpiyushv avatar shahpiyushv commented on July 20, 2024

@Mixiaoxiao , the specific fix and the keep alive config option have now been added. Thanks for debugging and the finding root cause of the issue.

from esp-homekit-sdk.

shahpiyushv avatar shahpiyushv commented on July 20, 2024

Off topic but I just wanted to add that I'm also working on an Arduino version of this SDK and it's currently available via PlatformIO. 😄

@Brawrdon that's good to know. Thanks for your efforts :)

from esp-homekit-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.