Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings if unable to config interface #39

Merged
merged 3 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion RF24Gateway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ int ESBGateway<mesh_t, network_t, radio_t>::allocateTunDevice(char* dev, int fla
// close(fd);
//#if (RF24GATEWAY_DEBUG_LEVEL >= 1)
std::cerr << "RF24Gw: Error: enabling TUNSETIFF" << std::endl;
std::cerr << "RF24Gw: If changing from TAP/TUN, run 'sudo ip link delete tun_nrf24' to remove the interface" << std::endl;
uint32_t UID = getuid();
if (UID) {
2bndy5 marked this conversation as resolved.
Show resolved Hide resolved
std::cout << "Not running as root, preconfigure the interface as follows" << std::endl;
std::cout << "sudo ip tuntap add dev tun_nrf24 mode tun user " << getlogin() << " multi_queue" << std::endl;
std::cout << "sudo ifconfig tun_nrf24 10.10.2.2/24" << std::endl;
}
return -1;
//#endif
}
Expand Down
15 changes: 13 additions & 2 deletions examples/ncurses/RF24Gateway_ncurses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ void drawCfg(bool isConf)

sleep(1);
wattron(win, COLOR_PAIR(1));
mvwprintw(win, 5, 1, isConf ? "IP Configuration\n" : "**Interface Not Configured:**\n");
mvwprintw(win, 4, 1, isConf ? "IP Configuration\n" : "**Interface Not Configured:**\n");
mvwprintw(win, 5, 1, "IP 10.10.2.2 and Subnet Mask 255.255.255.0 is default\n");
wattroff(win, COLOR_PAIR(1));
mvwprintw(win, 6, 1, "Enter IP Address: \n");
refresh();
Expand All @@ -546,7 +547,17 @@ void drawCfg(bool isConf)

if (strlen(ip) >= 6 && strlen(mask) >= 7)
{
gw.setIP(ip, mask);
if (gw.setIP(ip, mask) < 0) {
mvwprintw(win, 8, 1, "Unable to set IP/Subnet \n");
uint32_t UID = getuid();
if (UID) {
mvwprintw(win, 9, 1, "Not running as root, configure as follows:\n");
mvwprintw(win, 10, 1, "sudo ip tuntap add dev tun_nrf24 mode tun user %s multi_queue\n", getlogin());
mvwprintw(win, 11, 1, "sudo ifconfig tun_nrf24 10.10.2.2/24\n");
}
refresh();
sleep(10);
}
}
else
{
Expand Down
15 changes: 13 additions & 2 deletions examples/ncursesInt/RF24Gateway_ncursesInt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,8 @@ void drawCfg(bool isConf)

sleep(1);
wattron(win, COLOR_PAIR(1));
mvwprintw(win, 5, 1, isConf ? "IP Configuration\n" : "**Interface Not Configured:**\n");
mvwprintw(win, 4, 1, isConf ? "IP Configuration\n" : "**Interface Not Configured:**\n");
mvwprintw(win, 5, 1, "IP 10.10.2.2 and Subnet Mask 255.255.255.0 is default\n");
wattroff(win, COLOR_PAIR(1));
mvwprintw(win, 6, 1, "Enter IP Address: \n");
refresh();
Expand All @@ -574,7 +575,17 @@ void drawCfg(bool isConf)

if (strlen(ip) >= 6 && strlen(mask) >= 7)
{
gw.setIP(ip, mask);
if (gw.setIP(ip, mask) < 0) {
mvwprintw(win, 8, 1, "Unable to set IP/Subnet \n");
uint32_t UID = getuid();
if (UID) {
mvwprintw(win, 9, 1, "Not running as root, configure as follows:\n");
mvwprintw(win, 10, 1, "sudo ip tuntap add dev tun_nrf24 mode tun user %s multi_queue\n", getlogin());
mvwprintw(win, 11, 1, "sudo ifconfig tun_nrf24 10.10.2.2/24\n");
}
refresh();
sleep(10);
}
}
else
{
Expand Down