1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/net/grnc: implement sock_aux_rssi

This commit is contained in:
Marian Buschsieweke 2021-01-12 21:59:09 +01:00
parent f0ba796e5d
commit c0765d9e07
No known key found for this signature in database
GPG Key ID: 61F64C6599B1539F
4 changed files with 30 additions and 0 deletions

View File

@ -174,6 +174,12 @@ ssize_t gnrc_sock_recv(gnrc_sock_reg_t *reg, gnrc_pktsnip_t **pkt_out,
}
}
#endif /* MODULE_SOCK_AUX_TIMESTAMP */
#if IS_USED(MODULE_SOCK_AUX_RSSI)
if ((aux->rssi) && (netif_hdr->rssi != GNRC_NETIF_HDR_NO_RSSI)) {
aux->flags |= GNRC_SOCK_RECV_AUX_FLAG_RSSI;
*aux->rssi = netif_hdr->rssi;
}
#endif /* MODULE_SOCK_AUX_RSSI */
}
*pkt_out = pkt; /* set out parameter */

View File

@ -72,6 +72,9 @@ typedef struct {
#endif
#if IS_USED(MODULE_SOCK_AUX_TIMESTAMP) || DOXYGEN
uint64_t *timestamp; /**< timestamp PDU was received at in nanoseconds */
#endif
#if IS_USED(MODULE_SOCK_AUX_RSSI) || DOXYGEN
int16_t *rssi; /**< RSSI value of received PDU */
#endif
/**
* @brief Flags
@ -80,6 +83,7 @@ typedef struct {
} gnrc_sock_recv_aux_t;
#define GNRC_SOCK_RECV_AUX_FLAG_TIMESTAMP 0x01 /**< Timestamp valid */
#define GNRC_SOCK_RECV_AUX_FLAG_RSSI 0x02 /**< RSSI valid */
/**
* @brief Internal helper functions for GNRC

View File

@ -139,6 +139,11 @@ ssize_t sock_ip_recv_buf_aux(sock_ip_t *sock, void **data, void **buf_ctx,
if ((aux != NULL) && (aux->flags & SOCK_AUX_GET_TIMESTAMP)) {
_aux.timestamp = &aux->timestamp;
}
#endif
#if IS_USED(MODULE_SOCK_AUX_RSSI)
if ((aux != NULL) && (aux->flags & SOCK_AUX_GET_RSSI)) {
_aux.rssi = &aux->rssi;
}
#endif
res = gnrc_sock_recv((gnrc_sock_reg_t *)sock, &pkt, timeout, &tmp, &_aux);
if (res < 0) {
@ -166,6 +171,11 @@ ssize_t sock_ip_recv_buf_aux(sock_ip_t *sock, void **data, void **buf_ctx,
if ((aux != NULL) && (_aux.flags & GNRC_SOCK_RECV_AUX_FLAG_TIMESTAMP)) {
aux->flags &= ~(SOCK_AUX_GET_TIMESTAMP);
}
#endif
#if IS_USED(MODULE_SOCK_AUX_RSSI)
if ((aux != NULL) && (_aux.flags & GNRC_SOCK_RECV_AUX_FLAG_RSSI)) {
aux->flags &= ~(SOCK_AUX_GET_RSSI);
}
#endif
*data = pkt->data;
*buf_ctx = pkt;

View File

@ -228,6 +228,11 @@ ssize_t sock_udp_recv_buf_aux(sock_udp_t *sock, void **data, void **buf_ctx,
if ((aux != NULL) && (aux->flags & SOCK_AUX_GET_TIMESTAMP)) {
_aux.timestamp = &aux->timestamp;
}
#endif
#if IS_USED(MODULE_SOCK_AUX_RSSI)
if ((aux != NULL) && (aux->flags & SOCK_AUX_GET_RSSI)) {
_aux.rssi = &aux->rssi;
}
#endif
res = gnrc_sock_recv((gnrc_sock_reg_t *)sock, &pkt, timeout, &tmp, &_aux);
if (res < 0) {
@ -261,6 +266,11 @@ ssize_t sock_udp_recv_buf_aux(sock_udp_t *sock, void **data, void **buf_ctx,
if ((aux != NULL) && (_aux.flags & GNRC_SOCK_RECV_AUX_FLAG_TIMESTAMP)) {
aux->flags &= ~SOCK_AUX_GET_TIMESTAMP;
}
#endif
#if IS_USED(MODULE_SOCK_AUX_RSSI)
if ((aux != NULL) && (_aux.flags & GNRC_SOCK_RECV_AUX_FLAG_RSSI)) {
aux->flags &= ~SOCK_AUX_GET_RSSI;
}
#endif
*data = pkt->data;
*buf_ctx = pkt;