Coder Social home page Coder Social logo

Comments (10)

sergey-gra avatar sergey-gra commented on May 28, 2024 1

Expressing gratitude for your valuable suggestion @COM8 , I will endeavor to incorporate it and subsequently provide you with an update on its implementation.

from protocol-bt-cpp.

COM8 avatar COM8 commented on May 28, 2024 1

OK here is how I would do it:

  1. Remove all existing occurrences (calls) of show_nfc_card_detection(); inside MainWindow.cpp
  2. Create a new event inside CoffeeSelectionWidget.{cpp, hpp} that forwards call to on_coffee_button_clicked();
  3. Remove the call coffeeMaker->request_coffee(product); inside on_coffee_button_clicked(); since we first want to authenticate.
  4. Inside MainWindow.cpp subscribe to the newly created event inside for example prep_widget();
  5. Cache the requested product for example as a member inside MainWindow.cpp.
  6. From inside the event handler call show_nfc_card_detection();
  7. Inside on_nfc_card_detected(...); (MainWindow.cpp) call coffeeMaker->request_coffee(product); with the before cached product.
  8. 🎉

Hope this rough sketch helps you.

from protocol-bt-cpp.

COM8 avatar COM8 commented on May 28, 2024

You need to call MainWindow::show_nfc_card_detection();.
https://github.com/Jutta-Proto/gtk-ui/blob/d53f559c85e3346bf5d3142ff988deb408027772/src/ui/windows/MainWindow.hpp#L55

I would go into CoffeeSelectionWidget.{cpp, hpp}. There look at how edit_custom_coffee_clicked is implemented via signals. I would create a new signal that triggers once a beverage has been made.

Then go into MainWindow.{cpp, hpp} and subscribe to it, like it's done with the edit_custom_coffee_clicked signal. There than trigger MainWindow::show_nfc_card_detection();.

from protocol-bt-cpp.

sergey-gra avatar sergey-gra commented on May 28, 2024

You need to call MainWindow::show_nfc_card_detection();. https://github.com/Jutta-Proto/gtk-ui/blob/d53f559c85e3346bf5d3142ff988deb408027772/src/ui/windows/MainWindow.hpp#L55

I would go into CoffeeSelectionWidget.{cpp, hpp}. There look at how edit_custom_coffee_clicked is implemented via signals. I would create a new signal that triggers once a beverage has been made.

Then go into MainWindow.{cpp, hpp} and subscribe to it, like it's done with the edit_custom_coffee_clicked signal. There than trigger MainWindow::show_nfc_card_detection();.

Is it possible in this way to retrieve the status of an NFC reader to determine if a user has attached their card, prior to initiating a product request on a coffee machine? Specifically, the desired behavior is to restrict product requests until the user's card has been detected by the NFC reader. Although modifications were made to enable the NFC reader window to appear when a product is selected, the system is still initiating the UUID call for the product request without waiting for the card to be detected. Upon attaching an NFC card, the system is displaying the NFC card window again. This issue may be due to a my lack of familiarity with GTK 😃

from protocol-bt-cpp.

COM8 avatar COM8 commented on May 28, 2024

The NFC card reader flow is as follows:

  1. User places its card on the reader.
  2. The reader reads the card and sends the number as simple keyboard input to the application.
  3. The application catches any keyboard input.
  4. If there are more than 8 chars as input in less than one second, the backend registers it as a NFC-card input. Code: https://github.com/Jutta-Proto/gtk-ui/blob/bt/src/backend/NfcCardReader.cpp#L83

What you probably want is to lock the coffee maker in between, so the user can not make beverages either via the screen, or by pressing a button on the coffee maker it self.

Take a look at CoffeeMaker::lock() and CoffeeMaker::unlock() defined here:

/**
* Locks the coffee maker screen and disables all button input until unlock() is called.
**/
void lock();
/**
* Unlocks the coffee maker screen again after you have locked it with lock().
**/
void unlock();

I hope this helps since I did not totally understand what your issue is.

from protocol-bt-cpp.

sergey-gra avatar sergey-gra commented on May 28, 2024

I appreciate your time and prompt response. Please accept my apologies if the description of my problem or issue was difficult to understand.
The desired functionality includes the following steps:

  1. User selects a drink.
  2. A NFC card window is displayed.
  3. The user either attaches an NFC card or clicks on a "continue" button.
  4. The product making process is initiated only after the NFC card is attached or the "continue" button is clicked.

I hope that I have provided a clear and comprehensive understanding of the matter at hand.

from protocol-bt-cpp.

COM8 avatar COM8 commented on May 28, 2024

Aha! Now it makes sense. I will try to reply tomorrow once I'm back from work again.

from protocol-bt-cpp.

sergey-gra avatar sergey-gra commented on May 28, 2024

Great, I look forward to hearing back from you tomorrow. Have a productive day!

from protocol-bt-cpp.

sergey-gra avatar sergey-gra commented on May 28, 2024

I sincerely appreciate your explanation and your time. I now have a clear understanding. Thank you very much for your assistance. I'll try to implement it.

from protocol-bt-cpp.

sergey-gra avatar sergey-gra commented on May 28, 2024

I have successfully implemented the steps you specified. However, I have encountered a minor issue whereby the NFC detection window is hiden when I attach the card to the NFC reader, and subsequently reappears. It appears that the on_coffee_button_clicked() function is being invoked again as a result.

from protocol-bt-cpp.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.