Applies to: DynaFlex II PED, DynaFlex Pro/SCR (Gen I)
This section provides information about developing software for a host to communicate via a TCP/IP network with MMS products connected to a wireless LAN access point. In this arrangement, the host and device exchange messages as peers using the bidirectional WebSocket protocol. For details about the WebSocket Protocol, formally IETF RFC 6455, see https://tools.ietf.org/html/rfc6455 and http://websocket.org.
For information about SDKs and sample code that can wrap the protocol and speed up development, see SDKs and Tools.
Before the device and host can communicate using the wireless LAN (WLAN) connection, the device must first be configured to connect to a WLAN access point. For details about configuring the device, see the deviceβs Installation and Operation Manual or supporting documentation included with the device.
After the device has been successfully configured for WLAN communication, whenever the device powers on or resets, it attempts to connect to the configured access point. If it is configured to use DHCP, it contacts a DHCP server to acquire a dynamic IP address and register its Hostname to the DNS server, otherwise it uses its configured static IP address. It then opens a WebSocket server listener port, and waits for a host to establish a connection using a WebSocket handshake. If any notification events occur before the host completes the handshake and establishes a connection, the device does not send the corresponding notifications, and it does not buffer while it waits for a host to establish a connection.
If you wish to test the deviceβs network connection before writing any code, you may choose to use the echo tool at , which allows a WebSocket capable browser to connect directly to a local IP address and port to perform a simple echo operation.
To connect to the device, the host software must follow these steps:
Know the WebSocket connection / handshake parameters:
/host/ is the deviceβs IP address or IP name (if DNS is in use). By default, when using DHCP, the device registers its Hostname as its IP name. Suggest using the Hostname df-device serial number to keep each server unique. See the serial number label on the back of the device.
/port/ is the port the deviceβs WebSocket server is listening on. Per the WebSocket standard, if the host does not specify a port, the connection assumes the default (port 80 for non-secure WebSocket, port 443 for secure WebSocket). For these devices, use the default port.
To send a command to the device using the WLAN connection:
Make sure there is an open WebSocket connection. See How to Connect to a Device Using the Wireless LAN (WLAN) Connection for details.
Choose the command to invoke from .
Construct the command request message using the Request table in the command documentation. For a deeper explanation of the contents of request tables, see
MMS devices use the same mechanism to send Response messages to host commands and to send unsolicited Notifications to the host when events occur, such as device state changes or user interactions.
The host software should always be listening for notification messages and should listen for command response messages after sending a command. Receiving the incoming message is the same in both cases, but notification messages, which are generally unpredictable, need to be routed to different handlers than responses, which are generally anticipated after sending a command.
The host should follow this general sequence to process notification messages incoming via WebSocket protocol:
Make sure there is an open WebSocket connection. See How to Connect to a Device Using the Wireless LAN (WLAN) Connection for details.
After a WebSocket message arrives, determine the message type and message ID and route / parse it according to the corresponding Response table or Notification table in section 2.7.
/resource name/, /protocols/, and /extensions/ are not required because the device only communicates with a single host and uses binary WebSocket frames.
/origin/ is not required per the WebSocket standard, because the host software is not a web browser.
/secure/ is recommended.
The device will automatically disconnect from the client at the end of a session. See Command 0x1F03 - Extend Session (Session Management Only) for more details.
Spawn a process to send a WebSocket ping across the connection on a reasonable interval (such as 5 seconds) to make sure the connection is still alive. Note that WebSocket protocol keeps ping / pong and binary message traffic separate, so there is not a risk of collision between MMS messages and a ping. Upon detecting the connection is no longer functioning (such as during power interruptions, wireless interference or out-of-range, network outage, etc.), take appropriate action such as:
Resetting the state of all host-side operations in process
Reporting the connection state and recommended troubleshooting procedures to the operator
Attempting to re-establish the connection
Need Help?
For additional support, please contact MagTek Support:
Technical Support:
π§ Email: support@magtek.com
π Phone: 1-562-546-6800 (US)
π Hours: Monday-Friday, 5:30 AM - 5:00 PM PST
Online Resources:
π Support Portal: developer.magtek.com
Documentation Feedback:
Help us improve this documentation!