6

I saw in China's bus system, that there are devices inside the bus which can handle e-payments. The process is something like this:

  1. Passengers come in the bus.
  2. Passengers use a QR-code in their smartphone app to wipe on the device's screen (the QR code scanner)
  3. If passengers charge successfully, they are allowed a seat on the bus. If not, the device sounds some alerts.

I'm trying to implement this system for my project in my university. At first, I used a Raspberry Pi and a QR code scanner module to recognize the QR-code and push the data via Wi-Fi to the API on the remote server. My way of doing is that every time the device receives a QR code, it immediately sends that data to the API. Then the API handles all things and sends a response back to the device.

Everything works well. However, a problem occurs is that it seems taking a lot of time between each sendings and I'm not really handling some unexpected cases such as a lost connection in sending data to API.

For example, when the first passenger comes and put the QR-code of his phone's app on the device but it takes around 4-6 seconds for completing the whole process (included sending the passenger's data to server's API, API handling charging, balance processing, then sending a response back to the device for checking whether that passenger is allowed to come or not). Sometimes, the device loses connection, so the passengers can't use the device.

So, I came up with the idea that:

  1. I will synchronize the passenger's key data (Id, name, balance) on the database with the device's storage.
  2. Now, processing payments will be directly implemented on the device. For instance, the device will check the passenger's QR code and then compare with the data in its storage to handle whether that passenger can come in or not.
  3. After all passengers finished their check-in (it means when the bus moving), the device's storage will again synchronize with the server's database.

I think if the system runs in this way, it will be smooth as all things will be done locally until they synchronize.

So that is the brief summary of my system as well as my idea. However, I'm not in China and my country also has not implemented a similar system so far so I do not have any references sources.

I would very appreciate it if you guys can suggest me some directions or any related references about this new idea.

  • Is it possible or not?
  • Are there some hidden dangerous logics inside?
  • If yes, can you help me with some hints? For example, what is the most suitable time for synchronizing data between server's database and device's database?
  • On server side, I use ASP.net to write APIs, and working with passenger data is not hard (find, edit, update) by using the Entity Framework. But how can I do the similar thing in Raspberry Pi for local processing?
Helmar
  • 8,450
  • 6
  • 36
  • 84
juggernaut156
  • 421
  • 2
  • 6

1 Answers1

5

I have a similar idea for you still with local processing. I won’t deal with the security breaches of this idea as it is a school project.

Make your QR code also have the data of the balance of the user. You RPi reads the code, deducts the fee from the balance it sees on the QR code. If it can, perfect, if not, you are declined to use the bus. If you want , you can encrypt this balance data with some secret so that people can’t generate QR codes with infinite amount of balance. When the bus comes to a station, you just upload your local storage to the server.

Some drawbacks:

  • For every ride, your users have to open their mobile data to update their balances. You can put a time limit on the QR to make sure that it is only for one ride.

  • Generating illegal but valid QR codes.


For the technical part independent from the idea above:

You are using .Net for the backend. If you want to bring the same stack to RPi , you can install windows 10 IoT edition to your RPi. It is free and only requires a Windows 10 computer to do the installation. Nevertheless I would prefer using python and Linux on RPi.

For the payment idea above, it is perfectly fine if you just ignore it, it is there just to give you a perspective and was a nice brainstorming for me.

atakanyenel
  • 477
  • 2
  • 5