Skip to content

Commit

Permalink
savept before refactor basewindow
Browse files Browse the repository at this point in the history
  • Loading branch information
risha700 committed Oct 7, 2023
1 parent 9f3b1b2 commit 1c0bbd2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
Binary file modified rfidAdmin.dmg
Binary file not shown.
4 changes: 2 additions & 2 deletions src/App.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Gtk::Application("rfid.admin.app.opaic.nz", Gio::Application::Flags::HANDLES_OPE

// Set the UTF-8 locale
setlocale(LC_ALL, "C.UTF-8");

logger->info("App in {} mode",environment);

// connect signals
Expand Down Expand Up @@ -75,7 +75,7 @@ Glib::RefPtr<App> App::create()

void App::on_data_received(const std::string &data) const {
// update UI
logger->debug("App.cc => Data received fired... {}", data.c_str());
// logger->debug("App.cc => Data received fired... {}", data.c_str());
}

auto* App::create_login_window()
Expand Down
11 changes: 7 additions & 4 deletions src/BaseWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ BaseWindow::BaseWindow():
controls_btn.set_halign(Gtk::Align::START);
container.append(controls_btn);
container.append(send_command_btn);
reader_message.set_text("place RFID tag");
// reader_message.set_text("place RFID tag");
container.append(m_entry);
container.append(reader_message);
// signals
Expand Down Expand Up @@ -122,12 +122,12 @@ void BaseWindow::on_controls_show_click(){
}

void BaseWindow::on_send_command(){
reader_message.set_text("...sending...\n\nPresent a tag! ");
// reader_message.set_text("...sending...\n\nPresent a tag! ");
auto content = m_entry.get_text();
if(!content.empty()){
app->network_client.socket_send(content);
}else{
reader_message.set_text("Check your input!");
// reader_message.set_text("Check your input!");
}
}

Expand All @@ -153,7 +153,10 @@ void BaseWindow::on_check_network_click()
void BaseWindow::on_data_received(const std::string &data) {
// update UI
app->logger->debug("BaseWindow=> Data received {}", data.c_str());
reader_message.set_text(data.c_str());
auto buff = Gtk::TextBuffer::create();
buff->set_text(data.c_str());
// reader_message.set_text(data.c_str());
reader_message.set_buffer(buff);

}

Expand Down
4 changes: 2 additions & 2 deletions src/BaseWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class BaseWindow: public Gtk::ApplicationWindow
Glib::RefPtr<Gio::SimpleAction> m_refChoice;
Gtk::Box container, status_box;
Gtk::Button m_btn,controls_btn, send_command_btn;
Gtk::Label connection_status, reader_message;
Gtk::Label connection_status;
Gtk::Entry m_entry;
Gtk::Separator m_Separator;
Gtk::Image hero_image, status_img;
Gtk::TextView m_text;
Gtk::TextView m_text, reader_message;
Gtk::Stack m_stack;
ControlsWindow control_win;
InputDialog modal;
Expand Down
4 changes: 3 additions & 1 deletion src/NetworkClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NetworkClient::~NetworkClient(){

}
void NetworkClient::recv_bg_listener(){
char buffer[2048]; // Buffer to hold received data
char buffer[5500]; // Buffer to hold received data
ssize_t bytesRead = recv(clientSocket, buffer, sizeof(buffer), 0);
if (bytesRead == -1) {
logger->error("Error receiving data: {}",strerror(errno));
Expand Down Expand Up @@ -66,6 +66,7 @@ int NetworkClient::init_socket() {
struct timeval timeout;
timeout.tv_sec = 10; // 10 seconds
timeout.tv_usec = 0;

if (setsockopt(clientSocket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) == -1) {
logger->error("Error setting receiving timeout: {}",strerror(errno));
close(clientSocket);
Expand All @@ -79,6 +80,7 @@ int NetworkClient::init_socket() {
return -1;
}


serverAddress.sin_family = AF_INET;
serverAddress.sin_port = htons(iot_server_port);
serverAddress.sin_addr.s_addr = inet_addr(iot_server_ip); // Server's IP address
Expand Down

0 comments on commit 1c0bbd2

Please sign in to comment.