Skip to content

Commit

Permalink
fix getrssi bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
clovett committed Jun 2, 2017
1 parent c290780 commit 424c4e2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion MavLinkCom/include/MavLinkMessageBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ namespace mavlinkcom
class MavLinkTelemetry : public MavLinkMessageBase {
public:
const static uint8_t kMessageId = 204; // in the user range 180-229.
MavLinkTelemetry() { msgid = kMessageId; }
MavLinkTelemetry() : wifiInterfaceName(nullptr) { msgid = kMessageId; }
uint32_t messagesSent; // number of messages sent since the last telemetry message
uint32_t messagesReceived; // number of messages received since the last telemetry message
uint32_t messagesHandled; // number of messages handled since the last telemetry message
Expand Down
42 changes: 22 additions & 20 deletions MavLinkCom/src/serial_com/wifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,28 @@

int getWifiRssi(int socket, const char* ifaceName)
{
struct iw_statistics stats;
struct iwreq req;
memset(&stats, 0, sizeof(stats));
memset(&req, 0, sizeof(iwreq));

strncpy(req.ifr_name, ifaceName, 16);
req.u.data.pointer = &stats;
req.u.data.length = sizeof(iw_statistics);

#ifdef CLEAR_UPDATED
req.u.data.flags = 1;
#endif

/* Perform the ioctl */
if (ioctl(socket, SIOCGIWSTATS, &req) == -1) {
//printf("Error performing SIOCGIWSTATS on %s\n", ifaceName);
return -127;
}

return stats.qual.level;
return 0;
// This has not been properly tested
// struct iw_statistics stats;
// struct iwreq req;
// memset(&stats, 0, sizeof(stats));
// memset(&req, 0, sizeof(iwreq));
//
// strncpy(req.ifr_name, ifaceName, 16);
// req.u.data.pointer = &stats;
// req.u.data.length = sizeof(iw_statistics);
//
//#ifdef CLEAR_UPDATED
// req.u.data.flags = 1;
//#endif
//
// /* Perform the ioctl */
// if (ioctl(socket, SIOCGIWSTATS, &req) == -1) {
// //printf("Error performing SIOCGIWSTATS on %s\n", ifaceName);
// return -127;
// }
//
// return stats.qual.level;
}

#else
Expand Down

0 comments on commit 424c4e2

Please sign in to comment.