mirror of
https://github.com/esphome/esphome.git
synced 2026-10-11 22:04:16 +00:00
[socket] Add BSD socket support for nRF52 (#16699)
Co-authored-by: tomaszduda23 <tomaszduda23@gmail.com> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
co-authored by
tomaszduda23
pre-commit-ci-lite[bot]
Jonathan Swoboda
parent
f9f28a6a00
commit
75cdabee3d
@@ -22,11 +22,13 @@ BSDSocketImpl::BSDSocketImpl(int fd, bool monitor_loop) {
|
||||
if (flags >= 0)
|
||||
::fcntl(this->fd_, F_SETFD, flags | FD_CLOEXEC);
|
||||
#endif
|
||||
// Guard structure matches socket_ready_fd(): non-HOST platforms (nRF52/OpenThread)
|
||||
// do not register fds with the esphome select loop, so monitor_loop is a no-op there.
|
||||
if (!monitor_loop)
|
||||
return;
|
||||
#ifdef USE_LWIP_FAST_SELECT
|
||||
this->cached_sock_ = hook_fd_for_fast_select(this->fd_);
|
||||
#else
|
||||
#elif defined(USE_HOST)
|
||||
this->loop_monitored_ = wake_register_fd(this->fd_);
|
||||
#endif
|
||||
}
|
||||
@@ -45,7 +47,7 @@ int BSDSocketImpl::close() {
|
||||
// touch an unrelated socket's pcb. No per-socket callback unhook is needed —
|
||||
// all LwIP sockets share the same static event_callback.
|
||||
this->cached_sock_ = nullptr;
|
||||
#else
|
||||
#elif defined(USE_HOST)
|
||||
if (this->loop_monitored_) {
|
||||
wake_unregister_fd(this->fd_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user