Skip to content

Commit

Permalink
Cleanup and finishing touches (#39)
Browse files Browse the repository at this point in the history
* Changed target name to beaglecfg
* CI for build and release
* Include CPack for Debian pkg
* Modified README with asciinema2cast generated gif
* Fixed target install path in CMake

* Cleanup: 
     Temporary removal of non-implemented stuff
     Removal of errors on stderr

Following stuff has not been implemented yet
* Error handling gracefully
* Debug statements for user
* Display options

Hence instead of keeping strays, I have cleaned up a bit.

* TODO:
      Handle using logging libs available
  • Loading branch information
SAtacker authored Aug 22, 2021
1 parent 3db59a3 commit a6d6809
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 65 deletions.
1 change: 0 additions & 1 deletion .github/workflows/armhf-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
armhf__filename__=$(echo $(ls ${{steps.armhf-artifact-download.outputs.download-path}} | grep ..armhf.deb) | tr -d '\n')
version__name__=${armhf__filename__#*-}
name__=$(echo ${armhf__filename__%-*} | tr -d '\n')
trailing_=$(git rev-list --count HEAD | tr -d '\n')
version__=$(cat ../VERSION)
echo "name__=$name__" >> $GITHUB_ENV
echo "version__=$version__" >> $GITHUB_ENV
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ add_executable(${PROJECT_NAME}
src/ui/panel/pru/pru_impl.cpp
src/ui/panel/wifi/wifi_impl.cpp
src/ui/panel/passwd/passwd.cpp
src/ui/panel/display/display.cpp
src/ui/panel/ssh/ssh.cpp
src/ui/ui.cpp
src/ui/ui.hpp
Expand Down Expand Up @@ -89,6 +88,8 @@ configure_file(
${CMAKE_CURRENT_BINARY_DIR}/src/environment.hpp
)

install(TARGETS ${PROJECT_NAME} DESTINATION /usr/sbin)

if(VERSION_FILE)
execute_process(
COMMAND bash -c "echo -n ${CMAKE_PROJECT_VERSION}-${git_version} > VERSION"
Expand Down
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
# beagle-config
<br />
<p align="center">
<a href="https://github.com/SAtacker/beagle-config">
<img src="assets/images/beaglecfg.png" alt="Logo" width="481" height="75">
</a>
<p align="center">
Configure your beagle devices easily.
<br/>
<br/>
<a href="https://github.com/SAtacker/beagle-config/wiki"><strong>Explore the docs »</strong></a>
<br />
<a href="https://github.com/SAtacker/beagle-config/issues">Report Bug</a>
·
<a href="https://github.com/SAtacker/beagle-config/wiki/Examples">Examples</a>
.
<a href="https://github.com/SAtacker/beagle-config/issues">Request Feature</a>
·
<a href="https://github.com/SAtacker/beagle-config/pulls">Send a Pull Request</a>
</p>
</p>

<p align="center">
<img src="https://github.com/SAtacker/beagle-config/actions/workflows/armhf-build.yml/badge.svg">
<img src="https://img.shields.io/github/stars/SAtacker/beagle-config">
<img src="https://img.shields.io/github/forks/SAtacker/beagle-config">
<img src="https://img.shields.io/github/issues/SAtacker/beagle-config">
<img src="https://img.shields.io/github/repo-size/SAtacker/beagle-config">
<img src="https://img.shields.io/github/license/SAtacker/beagle-config">
</p>

## Build

Expand All @@ -7,7 +35,7 @@ mkdir -p build && cd build
cmake ..
make -j$(nproc)
```
### Current Status
[![asciicast](https://asciinema.org/a/429873.svg)](https://asciinema.org/a/429873)
### Looks like
![gif](assets/beaglecfg.gif)

* Note: For Cross Compiling a script `cross_compile.sh` should work fine on debian based distros.
Binary file added assets/beaglecfg.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/beaglecfg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/cast.gif
Binary file not shown.
29 changes: 0 additions & 29 deletions src/ui/panel/display/display.cpp

This file was deleted.

16 changes: 0 additions & 16 deletions src/ui/panel/ics/ics_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class ICSImpl : public PanelBase {
// Create a socket.
int socket_file_descriptor = socket(AF_INET, SOCK_DGRAM, 0);
if (socket_file_descriptor < 0) {
std::cerr << "Error opening socket " << std::endl;
return -1;
}

Expand Down Expand Up @@ -113,8 +112,6 @@ class ICSImpl : public PanelBase {
if (!route_add_) {
int error = ioctl(socket_file_descriptor, SIOCDELRT, &route);
if (error != 0) {
std::cerr << "Error ioctl del rt_gateway: " << gateway_str << "\n"
<< strerror(errno) << std::endl;
}
shutdown(socket_file_descriptor, SHUT_RDWR);
return -1;
Expand All @@ -123,15 +120,10 @@ class ICSImpl : public PanelBase {
/* Add it */
int error = ioctl(socket_file_descriptor, SIOCADDRT, &route);
if (error != 0) {
std::cerr << "Error ioctl add rt_gateway: " << gateway_str << "\n"
<< strerror(errno) << std::endl;
}

int nameserver_count = CountNameserver();
if (nameserver_count >= 2) {
std::cerr << "Servers already exist: nameserver_count = "
<< nameserver_count << std::endl;

shutdown(socket_file_descriptor, SHUT_RDWR);
return -1;
}
Expand All @@ -140,7 +132,6 @@ class ICSImpl : public PanelBase {
std::ofstream file("/etc/resolv.conf", std::ofstream::app);

if (!file.good()) {
std::cerr << "Permission denied" << std::endl;
shutdown(socket_file_descriptor, SHUT_RDWR);
return -1;
}
Expand All @@ -154,8 +145,6 @@ class ICSImpl : public PanelBase {
file << "nameserver " << dns_1_str << std::endl;
file << "nameserver " << dns_2_str << std::endl;

std::cerr << "Successful " << dns_1_str << " " << dns_2_str << std::endl;

/* Close the socket */
shutdown(socket_file_descriptor, SHUT_RDWR);
return 0;
Expand All @@ -166,7 +155,6 @@ class ICSImpl : public PanelBase {
// Create the config directory if it doesn't exist yet.
if (!std::filesystem::is_directory(UserShareConfigPath())) {
if (!std::filesystem::create_directories(UserShareConfigPath())) {
std::cerr << "Error Creating Directory" << std::endl;
return;
}
}
Expand All @@ -177,8 +165,6 @@ class ICSImpl : public PanelBase {
config_file.close();
config_file.open(BeagleConfigPath(), std::ios::app);
if (!config_file) {
std::cerr << "load:: Error opening config file" << BeagleConfigPath()
<< std::endl;
return;
}
config_file.close();
Expand Down Expand Up @@ -223,10 +209,8 @@ class ICSImpl : public PanelBase {
}

void StoreConfig() {
std::cerr << "Storing:: " << BeagleConfigPath() << std::endl;
std::ofstream config_file(BeagleConfigPath());
if (!config_file) {
std::cerr << "Store :: Error opening config file" << std::endl;
return;
}

Expand Down
1 change: 0 additions & 1 deletion src/ui/panel/panel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Panel WiFi(ScreenInteractive*);
Panel BackgroundWorker(ScreenInteractive*);
Panel About();
Panel passwd();
Panel display();
Panel ssh();
} // namespace panel
} // namespace ui
Expand Down
10 changes: 0 additions & 10 deletions src/ui/panel/wifi/wifi_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,8 @@ class WiFiImpl : public PanelBase {
}
}
if (file_path.empty()) {
std::cerr << "Network Not found :- " << data.name << std::endl;
return;
}
std::cout << "Calling store: " << file_path << std::endl;
StoreConnmanFile(file_path.c_str());
activity = ActivityMain;
}
Expand All @@ -196,7 +194,6 @@ class WiFiImpl : public PanelBase {
break;
}
}
std::cout << "Calling empty: " << file_path << std::endl;
EmptyConnmanConfig(file_path.c_str());
activity = ActivityMain;
}
Expand All @@ -219,11 +216,9 @@ class WiFiImpl : public PanelBase {
}

int StoreConnmanFile(const char* path) {
std::cout << "Storing in " << path << std::endl;
std::fstream connman_config(
path, std::fstream::in | std::fstream::out | std::fstream::trunc);
if (!connman_config.is_open()) {
std::cerr << "Error opening connman config " << path << std::endl;
return -1;
} else {
std::time_t time_ = std::chrono::system_clock::to_time_t(
Expand All @@ -246,12 +241,9 @@ class WiFiImpl : public PanelBase {
}

void EmptyConnmanConfig(const char* path) {
std::cout << "Emptying " << path << std::endl;
std::fstream connman_config(
path, std::fstream::in | std::fstream::out | std::fstream::trunc);
if (!connman_config.is_open()) {
std::cerr << "Emptying: Error opening connman config " << path
<< std::endl;
} else {
std::time_t time_ = std::chrono::system_clock::to_time_t(
std::chrono::system_clock::now());
Expand Down Expand Up @@ -335,7 +327,6 @@ class WiFiImpl : public PanelBase {
current_line;
}
} else {
std::cerr << "Not finding unique_name" << std::endl;
}
}
result.erase(0, newline_pos + 1);
Expand Down Expand Up @@ -371,7 +362,6 @@ class WiFiImpl : public PanelBase {
int skfd = socket(AF_INET, SOCK_DGRAM, 0);

if (skfd < 0) {
std::cerr << "cannot open socket" << std::endl;
return 0;
}

Expand Down
4 changes: 0 additions & 4 deletions src/ui/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@ void Loop() {
panel::WiFi(&screen),
panel::ICS(),
}},
{"Display",
{
panel::display(),
}},
{"Info",
{
// TODO: panel::PlaceHolder("Update"),
Expand Down

0 comments on commit a6d6809

Please sign in to comment.