mickeyl commented on issue #1734: URL: https://github.com/apache/mynewt-nimble/issues/1734#issuecomment-2069476542
@rymanluk Before I create a pull request, let me run this through you. Does this look reasonable? ```diff diff --git a/nimble/host/include/host/ble_l2cap.h b/nimble/host/include/host/ble_l2cap.h index aef9682c..bcdd5c71 100644 --- a/nimble/host/include/host/ble_l2cap.h +++ b/nimble/host/include/host/ble_l2cap.h @@ -250,7 +250,7 @@ typedef int ble_l2cap_event_fn(struct ble_l2cap_event *event, void *arg); uint16_t ble_l2cap_get_conn_handle(struct ble_l2cap_chan *chan); int ble_l2cap_create_server(uint16_t psm, uint16_t mtu, ble_l2cap_event_fn *cb, void *cb_arg); - +int ble_l2cap_remove_server(uint16_t psm); int ble_l2cap_connect(uint16_t conn_handle, uint16_t psm, uint16_t mtu, struct os_mbuf *sdu_rx, ble_l2cap_event_fn *cb, void *cb_arg); diff --git a/nimble/host/src/ble_l2cap.c b/nimble/host/src/ble_l2cap.c index 810d07b3..1773e28a 100644 --- a/nimble/host/src/ble_l2cap.c +++ b/nimble/host/src/ble_l2cap.c @@ -150,6 +150,12 @@ ble_l2cap_create_server(uint16_t psm, uint16_t mtu, return ble_l2cap_coc_create_server(psm, mtu, cb, cb_arg); } +int +ble_l2cap_remove_server(uint16_t psm) +{ + return ble_l2cap_coc_remove_server(psm); +} + int ble_l2cap_connect(uint16_t conn_handle, uint16_t psm, uint16_t mtu, struct os_mbuf *sdu_rx, ble_l2cap_event_fn *cb, void *cb_arg) diff --git a/nimble/host/src/ble_l2cap_coc.c b/nimble/host/src/ble_l2cap_coc.c index dada8b0c..0ace7dda 100644 --- a/nimble/host/src/ble_l2cap_coc.c +++ b/nimble/host/src/ble_l2cap_coc.c @@ -96,6 +96,22 @@ ble_l2cap_coc_create_server(uint16_t psm, uint16_t mtu, return 0; } +int +ble_l2cap_coc_remove_server(uint16_t psm) +{ + struct ble_l2cap_coc_srv * srv; + + STAILQ_FOREACH(srv, &ble_l2cap_coc_srvs, next) { + if (srv->psm == psm) { + STAILQ_REMOVE(&ble_l2cap_coc_srvs, srv, ble_l2cap_coc_srv, next); + os_memblock_put(&ble_l2cap_coc_srv_pool, srv); + return 0; + } + } + + return 0; +} + static inline void ble_l2cap_set_used_cid(uint32_t *cid_mask, int bit) { diff --git a/nimble/host/src/ble_l2cap_coc_priv.h b/nimble/host/src/ble_l2cap_coc_priv.h index 5ebdaa05..21fa7b9d 100644 --- a/nimble/host/src/ble_l2cap_coc_priv.h +++ b/nimble/host/src/ble_l2cap_coc_priv.h @@ -57,6 +57,7 @@ struct ble_l2cap_coc_srv { int ble_l2cap_coc_init(void); int ble_l2cap_coc_create_server(uint16_t psm, uint16_t mtu, ble_l2cap_event_fn *cb, void *cb_arg); +int ble_l2cap_coc_remove_server(uint16_t psm); int ble_l2cap_coc_create_srv_chan(struct ble_hs_conn *conn, uint16_t psm, struct ble_l2cap_chan **chan); struct ble_l2cap_chan * ble_l2cap_coc_chan_alloc(struct ble_hs_conn *conn, ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org