Paparazzi UAS
v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
rssi.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) Kirk Scheper
3
*
4
* This file is part of paparazzi
5
*
6
* paparazzi is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
9
* any later version.
10
*
11
* paparazzi is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with paparazzi; see the file COPYING. If not, see
18
* <http://www.gnu.org/licenses/>.
19
*/
26
#include "
modules/multi/rssi.h
"
27
28
#include "
subsystems/datalink/datalink.h
"
29
#include "pprzlink/messages.h"
30
31
#include "
subsystems/abi.h
"
// rssi messages subscription
32
#include "generated/airframe.h"
// AC_ID
33
34
#ifndef NB_ACS_ID
35
#define NB_ACS_ID 256
36
#endif
37
#ifndef NB_ACS
38
#define NB_ACS 24
39
#endif
40
41
uint8_t
rssi_acs_idx
;
42
struct
rssi_info_
rssi_acs
[
NB_ACS
];
43
uint8_t
rssi_acs_id
[
NB_ACS_ID
];
44
45
abi_event
ev
;
46
47
static
void
rssi_cb
(
uint8_t
sender_id __attribute__((unused)),
uint8_t
_ac_id,
int8_t
_tx_strength,
int8_t
_rssi)
48
{
49
set_rssi
(_ac_id, _tx_strength, _rssi);
50
}
51
52
void
rssi_init
()
53
{
54
memset(
rssi_acs_id
, 0,
NB_ACS_ID
);
55
56
rssi_acs_id
[0] = 0;
// ground station
57
rssi_acs_id
[AC_ID] = 1;
58
rssi_acs
[
rssi_acs_id
[AC_ID]].
ac_id
= AC_ID;
59
rssi_acs_idx
= 2;
60
61
/* register for rssi messages */
62
AbiBindMsgRSSI(
ABI_BROADCAST
, &ev,
rssi_cb
);
63
}
64
65
void
parse_rssi_dl
(
void
)
66
{
67
uint8_t
sender_id =
SenderIdOfPprzMsg
(
dl_buffer
);
68
uint8_t
msg_id =
IdOfPprzMsg
(
dl_buffer
);
69
70
if
(sender_id > 0 && msg_id == DL_RSSI) {
71
set_rssi
(sender_id,
72
DL_RSSI_tx_power(
dl_buffer
),
73
DL_RSSI_rssi(
dl_buffer
));
74
}
75
}
76
77
void
set_rssi
(
uint8_t
_ac_id,
int8_t
_tx_strength,
int8_t
_rssi)
78
{
79
if
(
rssi_acs_idx
<
NB_ACS
) {
80
if
(_ac_id > 0 &&
rssi_acs_id
[_ac_id] == 0) {
81
rssi_acs_id
[_ac_id] =
rssi_acs_idx
++;
82
rssi_acs
[
rssi_acs_id
[_ac_id]].
ac_id
= _ac_id;
83
}
84
85
rssi_acs
[
rssi_acs_id
[_ac_id]].
rssi
= _rssi;
86
rssi_acs
[
rssi_acs_id
[_ac_id]].
tx_strength
= _tx_strength;
87
}
88
}
89
90
struct
rssi_info_
get_rssi
(
uint8_t
_ac_id)
91
{
92
return
rssi_acs
[
rssi_acs_id
[_ac_id]];
93
}
abi_struct
Event structure to store callbacks in a linked list.
Definition:
abi_common.h:65
datalink.h
Handling of messages coming from ground and other A/Cs.
abi.h
Main include for ABI (AirBorneInterface).
parse_rssi_dl
void parse_rssi_dl(void)
Definition:
rssi.c:65
NB_ACS_ID
#define NB_ACS_ID
Definition:
rssi.c:35
rssi_acs_idx
uint8_t rssi_acs_idx
Definition:
rssi.c:41
NB_ACS
#define NB_ACS
Definition:
rssi.c:38
rssi_acs_id
uint8_t rssi_acs_id[NB_ACS_ID]
Definition:
rssi.c:43
rssi_info_::rssi
int8_t rssi
Definition:
rssi.h:33
SenderIdOfPprzMsg
#define SenderIdOfPprzMsg(x)
Definition:
datalink.h:40
rssi.h
uint8_t
unsigned char uint8_t
Definition:
types.h:14
get_rssi
struct rssi_info_ get_rssi(uint8_t _ac_id)
Definition:
rssi.c:90
rssi_info_
Definition:
rssi.h:31
dl_buffer
uint8_t dl_buffer[MSG_SIZE]
Definition:
main_demo5.c:64
rssi_info_::ac_id
uint8_t ac_id
Definition:
rssi.h:32
ABI_BROADCAST
#define ABI_BROADCAST
Broadcast address.
Definition:
abi_common.h:56
rssi_cb
static void rssi_cb(uint8_t sender_id, uint8_t _ac_id, int8_t _tx_strength, int8_t _rssi)
Definition:
rssi.c:47
int8_t
signed char int8_t
Definition:
types.h:15
set_rssi
void set_rssi(uint8_t _ac_id, int8_t _tx_strength, int8_t _rssi)
Definition:
rssi.c:77
rssi_init
void rssi_init()
Definition:
rssi.c:52
rssi_acs
struct rssi_info_ rssi_acs[NB_ACS]
Definition:
rssi.c:42
IdOfPprzMsg
#define IdOfPprzMsg(x)
Definition:
datalink.h:41
rssi_info_::tx_strength
int8_t tx_strength
Definition:
rssi.h:34
ev
abi_event ev
Definition:
rssi.c:45
sw
airborne
modules
multi
rssi.c
Generated on Wed Aug 28 2019 16:29:06 for Paparazzi UAS by
1.8.8