-1

It's a winform application and it has a database. When a phone scans a QR code, c# needs to get that data via wifi (if their wifi is not the same program won't work) and QR code's information is a text which that text (only includes numbers) is also in the database, it needs to open a new form. For example, it's a cargo shipment project and the QR code's meaning is the shipment ID, when you scan it, it needs to open a new form and show who send it, who will receive it etc. I need to scan QR code with phone and send it through to wifi. My problem is here that I don't know how to make that communication and send data. How can I do it?

Celestyn
  • 1
  • 1
  • "Via Wifi" doesn't mean anything. There's a lot of communication protocols you can use. Raw TCP/UDP packets, HTTP, Message Broker, database connections, file upload, etc. Please research yourself what is most appropriate for your situation, then come back when you've attempted something. – gunr2171 Oct 30 '22 at 16:10
  • Can you provide some code that describes the end point or an example of the data you want to send. This is a very ambiguous post, we need more information around the user scenario and their intent – Chris Schaller Oct 30 '22 at 23:18
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 31 '22 at 04:43
  • @ChrisSchaller It's a winform application and it has a database. QR code's information is a text (not an URL sadly) which that text (only includes numbers) is also in the database. It needs to open a new form and show that information's details. For example, it's a cargo shipment project and the QR code's meaning is the shipment ID, when you scan it, it needs to open a new form and show who send it, who will receive it etc. I need to scan QR code with phone and send it through to wifi. – Celestyn Oct 31 '22 at 14:33
  • You will need a purpose built application that scans and knows how to handle your QR codes, or you will need to modify your QR code to be in the form or a URL that can activate the application, or goes to a public endpoint that can serve the page to render the information and send to a local endpoint. These are common implementations, the user doesn't know that all this goes on of course, but it takes a bit of setup. – Chris Schaller Oct 31 '22 at 16:59

1 Answers1

-1

Wifi is a network protocol, so the standard way to interact with data providers in a network is via the HTTP Protocol. So if your data provider has an HTTP enabled endpoint or API, you would just access that point the same way you would access data over the internet.

  • There are other forms of communication and telephony you can use, but OP specifically mentions wifi.

QRCodes are passive. When the phone scans a QR code it should extract information or a URL from the image, then when you go to this URL the magic can happen, but it happens because the URL was navigated, not because the QR code was scanned.

The default action for generic QR Code scanning apps is to navigate to the url, if the data contained within the code is a url, but it sounds like you will need an app on the phone to provide additional information to your data endpoint, you can use a url to trigger an app on your phone that can handle this logic or the URLs could be a public endpoint that has the specific logic you need to send information to the local endpoint.

If the QR code has a fully qualified domain name, or fixed IP address, then the data provider will be easy to communicate with. However local Wifi networks are problematic for custom devices that are assigned automatic IP addresses, especially if these addresses might change over time.

In this case you can use UDP broadcast to locate and communicate with the backend, have a read over this post for more information:

C# UDP Broadcast and receive example

We need a lot more information to provide a specific example, but it is certainly simpler if your QR code is able to contain the specific address of the endpoint that will be providing the data.

Chris Schaller
  • 13,704
  • 3
  • 43
  • 81