2/15/2024 0 Comments Bonjour browser androidWe use signal.signal() to handle keyboard input for interrupting the infinite loop of the server. serve ( server, ip_address, 4000 ) while not isShutdown : await asyncio. remove ( websocket ) def ctrl_c ( signum, frame ): global isShutdown isShutdown = True async def main ( ip_address ): global isShutdown # Start the server add ( websocket ) try : await handle_message ( websocket, path ) except : connected. ![]() Import asyncio import websockets import socket import pyautogui import signal connected = set () isShutdown = False async def handle_message ( websocket, path ): async for message in websocket : if isinstance ( message, str ): pass elif isinstance ( message, bytes ): pass async def server ( websocket, path ): connected. Implement the Web Socket ServerĪfter obtaining the local IP address, the web socket server can be implemented with asyncio and websockets. Note: You may need to modify the regular expression used in the above code to match the network interface name on your computer. search ( r 'en0:', line ) if match : foundEthernet = True if foundEthernet : match = re. search ( r 'eth0:', line ) else : match = re. search ( r 'Ethernet adapter Ethernet:', line ) if match : foundEthernet = True if foundEthernet : match = re. run (, capture_output = True, text = True ) foundEthernet = False for line in result. run (, capture_output = True, text = True ) else : result = subprocess. platform = 'win32' : result = subprocess. Import subprocess import re import sys def get_ip_address (): ip_address = '' if sys. The server-side implementation is written in Python. Let’s get started with the server-side implementation. In this solution, Dynamsoft Barcode Reader SDK is used to recognize barcodes in images captured by the smartphone camera.īuilding a Discoverable Web Socket Server with Bonjour in Python Dynamsoft Barcode Reader SDK: Dynamsoft Barcode Reader SDK is a cross-platform barcode recognition SDK that can be used to recognize 1D and 2D barcodes in images.In this solution, PyAutoGUI is used to simulate keyboard input. PyAutoGUI: PyAutoGUI is a Python module that can be used to automate mouse movements and keyboard presses.In this solution, web sockets are used to communicate between mobile devices and PCs. WebSocket: Web sockets are a computer communications protocol that allows for bidirectional communication between a client and a server.In this solution, Bonjour is used to discover the web socket server on the same network. It allows devices on the same network to discover each other. Bonjour: Bonjour is a zero-configuration networking (zeroconf) protocol developed by Apple.Python: With Python, it only takes a few lines of code to implement network services and simulate keyboard input on operating systems.Using Flutter can save a lot of time and effort for building the client user interface. It enables developers build native applications for Windows, Linux, macOS, Android, iOS and web from a single codebase. Flutter: Flutter is a cross-platform UI framework.Overview of the Utilized Technologies and Why They Are Usedīefore diving into the details of the solution, let’s first take a look at the technologies used in this solution. The demo shows how to input text from an Android phone to Windows notepad and macOS notes simultaneously. This article presents a solution that combines technologies like Flutter, Python, Bonjour, web sockets, PyAutoGUI, and Dynamsoft Barcode Reader SDK to help enterprises save costs by using smartphones instead of barcode scanners.ĭemo Video: Smartphone as a Peripheral Keyboard and Barcode Scanner If smartphone can do the same job as a handheld barcode scanner, no additional hardware is needed. Everyone has at least one smartphone in their pocket. Nowadays, smartphones have become ubiquitous. Smartphones with built-in cameras can detect both one-dimensional and two-dimensional codes. However, traditional handheld laser barcode scanners can only detect one-dimensional codes, while more expensive scanners with an embedded camera are needed to detect two-dimensional codes like QR codes. Handheld barcode scanners are widely used as peripheral devices in these industries. The data obtained from scanning barcodes is used to track inventory, manage orders, and process payments. Barcode scanning technology is crucial for many enterprises, such as those in the supermarket, logistics, and warehousing industries.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |