diff --git a/pkg/nimble/statconn/include/nimble_statconn.h b/pkg/nimble/statconn/include/nimble_statconn.h index 8a579113e9..da39800701 100644 --- a/pkg/nimble/statconn/include/nimble_statconn.h +++ b/pkg/nimble/statconn/include/nimble_statconn.h @@ -50,6 +50,7 @@ #ifndef NIMBLE_STATCONN_H #define NIMBLE_STATCONN_H +#include #include #include "nimble_netif.h" @@ -112,16 +113,6 @@ extern "C" { #define NIMBLE_STATCONN_CONN_SUPERTO_MS (2500U) #endif -/** - * @brief Return codes used by the statconn module - */ -enum { - NIMBLE_STATCONN_OK = 0, /**< all groovy */ - NIMBLE_STATCONN_NOSLOT = -1, /**< no more connection slot available */ - NIMBLE_STATCONN_NOTCONN = -2, /**< given address is not managed */ - NIMBLE_STATCONN_INUSE = -3, /**< given peer is already managed */ -}; - /** * @brief Initialize the statconn module * @@ -148,9 +139,9 @@ void nimble_statconn_eventcb(nimble_netif_eventcb_t cb); * * @param[in] addr BLE address of the peer * - * @return NIMBLE_STATCONN_OK if peer was successfully added - * @return NIMBLE_STATCONN_INUSE if the peer address is already in use - * @return NIMBLE_STATCONN_NOSLOT if no empty connection slot is available + * @return 0 if peer was successfully added + * @return -EALREADY if the peer address is already in use + * @return -ENOMEM if no empty connection slot is available */ int nimble_statconn_add_master(const uint8_t *addr); @@ -159,9 +150,9 @@ int nimble_statconn_add_master(const uint8_t *addr); * * @param[in] addr BLE address of the peer * - * @return NIMBLE_STATCONN_OK if peer was successfully added - * @return NIMBLE_STATCONN_INUSE if the peer address is already in use - * @return NIMBLE_STATCONN_NOSLOT if no empty connection slot is available + * @return 0 if peer was successfully added + * @return -EALREADY if the peer address is already in use + * @return -ENOMEM if no empty connection slot is available */ int nimble_statconn_add_slave(const uint8_t *addr); @@ -170,8 +161,8 @@ int nimble_statconn_add_slave(const uint8_t *addr); * * @param[in] addr BLE address of the peer * - * @return NIMBLE_STATCONN_OK if peer was successfully removed - * @return NIMBLE_STATCONN_NOTCONN if given address is not managed + * @return 0 if peer was successfully removed + * @return -ENOTCONN if given address is not managed */ int nimble_statconn_rm(const uint8_t *addr); diff --git a/pkg/nimble/statconn/nimble_statconn.c b/pkg/nimble/statconn/nimble_statconn.c index 1826e0a2f3..bd99309572 100644 --- a/pkg/nimble/statconn/nimble_statconn.c +++ b/pkg/nimble/statconn/nimble_statconn.c @@ -159,19 +159,19 @@ static int _be(uint8_t role, const uint8_t *addr) slot_t *s = _get_addr(addr); if (s != NULL) { mutex_unlock(&_lock); - return NIMBLE_STATCONN_INUSE; + return -EALREADY; } s = _get_state(UNUSED); if (s == NULL) { mutex_unlock(&_lock); - return NIMBLE_STATCONN_NOSLOT; + return -ENOMEM; } s->state = (role | PENDING); memcpy(s->addr, addr, BLE_ADDR_LEN); mutex_unlock(&_lock); _activate(role); - return NIMBLE_STATCONN_OK; + return 0; } void nimble_statconn_init(void) @@ -226,7 +226,7 @@ int nimble_statconn_rm(const uint8_t *addr) slot_t *s = _get_addr(addr); if (s == NULL) { mutex_unlock(&_lock); - return NIMBLE_STATCONN_NOTCONN; + return -ENOTCONN; } uint8_t role = (s->state & ROLE_M) ? ROLE_M : ROLE_S; @@ -242,5 +242,5 @@ int nimble_statconn_rm(const uint8_t *addr) _activate(ROLE_S); } - return NIMBLE_STATCONN_OK; + return 0; }