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:
parent
f0ba796e5d
commit
c0765d9e07
@ -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 */
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user