Skip to content

Commit

Permalink
Fix build warnings for examples (#37)
Browse files Browse the repository at this point in the history
* address build warnings
* revise use of header in ncurses interrupt example
* send timestamp to sender
* fix renewAddress() usage
  • Loading branch information
2bndy5 authored Jun 21, 2024
1 parent 7a8ae5d commit 1dc0134
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 43 deletions.
5 changes: 3 additions & 2 deletions RF24Gateway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ struct in_addr ESBGateway<mesh_t, network_t, radio_t>::getLocalIP()
int family, s, n;
char host[NI_MAXHOST];
struct in_addr myNet;
memset(&myNet, 0, sizeof(myNet));

getifaddrs(&ifap);
for (ifa = ifap, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) {
Expand Down Expand Up @@ -682,14 +683,14 @@ template<class mesh_t, class network_t, class radio_t>
void ESBGateway<mesh_t, network_t, radio_t>::printPayload(std::string buffer, std::string debugMsg)
{
}
*/
/***************************************************************************************
template<class mesh_t, class network_t, class radio_t>
void ESBGateway<mesh_t, network_t, radio_t>::printPayload(char* buffer, int nread, std::string debugMsg)
{
}
*/
/***************************************************************************************/

template<class mesh_t, class network_t, class radio_t>
Expand Down
16 changes: 5 additions & 11 deletions examples/ncurses/RF24Gateway_ncurses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,7 @@ void drawTopology()

for (int j = 0; j < mesh.addrListTop; j++) {
if (mesh.addrList[j].address == i) {
int y = 0;
int x = 0;
getyx(connPad, y, x);
int x = getcurx(connPad);
if (x > connPadmaxX - 77) {
wprintw(connPad, "\n");
}
Expand All @@ -394,9 +392,7 @@ void drawTopology()

for (int j = 0; j < mesh.addrListTop; j++) {
if (mesh.addrList[j].address == i) {
int y = 0;
int x = 0;
getyx(connPad, y, x);
int x = getcurx(connPad);
if (x > connPadmaxX - 77) {
wprintw(connPad, "\n");
}
Expand All @@ -416,9 +412,7 @@ void drawTopology()

for (int j = 0; j < mesh.addrListTop; j++) {
if (mesh.addrList[j].address == i) {
int y = 0;
int x = 0;
getyx(connPad, y, x);
int x = getcurx(connPad);
if (x > connPadmaxX - 77) {
wprintw(connPad, "\n");
}
Expand Down Expand Up @@ -664,7 +658,7 @@ void drawRF24Pad()
wprintw(rf24Pad, "TX Packets: %u\n", ok);
wprintw(rf24Pad, "TX Drops: %u\n", fail);
#endif
wprintw(rf24Pad, "RX Packets(user): %u\n", networkPacketsRX);
wprintw(rf24Pad, "RX Packets(user): %lu\n", networkPacketsRX);

if (padSelection == 1)
{
Expand Down Expand Up @@ -711,7 +705,7 @@ void drawConnPad()
fnd = line.find_last_of(" ", fnd - 2);
unsigned findEnd = line.find(" mark=");
line = line.substr(fnd, findEnd - fnd);
mvwprintw(connPad, ctr++, 0, "%d %s\n", lCtr++, line.c_str());
mvwprintw(connPad, ctr++, 0, "%ld %s\n", lCtr++, line.c_str());

if (ctr > maxX - 15)
{
Expand Down
53 changes: 23 additions & 30 deletions examples/ncursesInt/RF24Gateway_ncursesInt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ int main()
wclear(renewPad);
mvwprintw(renewPad, 0, 0, "*Renewing Address*");
prefresh(renewPad, 0, 0, 3, 26, 4, 55);
if ((ok = mesh.renewAddress()))
ok = mesh.renewAddress() != MESH_DEFAULT_ADDRESS;
if (ok)
{
ok = true;
wclear(renewPad);
prefresh(renewPad, 0, 0, 3, 26, 4, 55);
}
Expand All @@ -182,29 +184,26 @@ int main()
{
++networkPacketsRX;
RF24NetworkHeader header;

// un-needed variables
// size_t size = network.peek(header);
// uint8_t buf[size];
network.read(header, /*buf*/ 0, /*size*/ 0); // pop the RX payload from network.queue

if (header.type == 1) // header.type is uninitialized
// send a timestamp to master
struct timeStruct
{
struct timeStruct
{
uint8_t hr;
uint8_t min;
} myTime;

time_t mTime;
time(&mTime);
struct tm* tm = localtime(&mTime);

myTime.hr = tm->tm_hour;
myTime.min = tm->tm_min;
RF24NetworkHeader hdr(header.from_node, 1);
network.write(hdr, &myTime, sizeof(myTime));
}
network.read(header, 0, 0);
uint8_t hr;
uint8_t min;
} myTime;

time_t mTime;
time(&mTime);
struct tm* tm = localtime(&mTime);

myTime.hr = tm->tm_hour;
myTime.min = tm->tm_min;
RF24NetworkHeader hdr(header.from_node, 1);
network.write(hdr, &myTime, sizeof(myTime));
}
}
else
Expand Down Expand Up @@ -400,9 +399,7 @@ void drawTopology()

for (int j = 0; j < mesh.addrListTop; j++) {
if (mesh.addrList[j].address == i) {
int y = 0;
int x = 0;
getyx(connPad, y, x);
int x = getcurx(connPad);
if (x > connPadmaxX - 77) {
wprintw(connPad, "\n");
}
Expand All @@ -422,9 +419,7 @@ void drawTopology()

for (int j = 0; j < mesh.addrListTop; j++) {
if (mesh.addrList[j].address == i) {
int y = 0;
int x = 0;
getyx(connPad, y, x);
int x = getcurx(connPad);
if (x > connPadmaxX - 77) {
wprintw(connPad, "\n");
}
Expand All @@ -444,9 +439,7 @@ void drawTopology()

for (int j = 0; j < mesh.addrListTop; j++) {
if (mesh.addrList[j].address == i) {
int y = 0;
int x = 0;
getyx(connPad, y, x);
int x = getcurx(connPad);
if (x > connPadmaxX - 77) {
wprintw(connPad, "\n");
}
Expand Down Expand Up @@ -694,7 +687,7 @@ void drawRF24Pad()
wprintw(rf24Pad, "TX Packets(sys): %u\n", ok);
wprintw(rf24Pad, "TX Drops: %u\n", fail);
#endif
wprintw(rf24Pad, "RX Packets(user): %u\n", networkPacketsRX);
wprintw(rf24Pad, "RX Packets(user): %lu\n", networkPacketsRX);
if (gw.fifoCleared)
{
++fifoClears;
Expand Down Expand Up @@ -747,7 +740,7 @@ void drawConnPad()
fnd = line.find_last_of(" ", fnd - 2);
unsigned findEnd = line.find(" mark=");
line = line.substr(fnd, findEnd - fnd);
mvwprintw(connPad, ctr++, 0, "%d %s\n", lCtr++, line.c_str());
mvwprintw(connPad, ctr++, 0, "%ld %s\n", lCtr++, line.c_str());

if (ctr > maxX - 15)
{
Expand Down

0 comments on commit 1dc0134

Please sign in to comment.