Connect an RFID device
This chapter is for developers connecting an RFID device to their own server. The server must authenticate each device and provide a Socket.IO endpoint that handles its events.
- Store each device's
serial_numberand password securely on your server. - Expose
GET /socket/token. The device calls it with HTTP Basic authentication, using its serial number as the username and its password as the password. Verify the credentials and return a short-lived token in a JSONtokenfield. - Expose a Socket.IO server at
/socket.io/. Accept the token in the connection query, validate it, and associate the connection with the authenticated device serial number. Use TLS in production. - Handle
device:metadatawithapp_versionafter connection, and support reconnection with a fresh token when authentication expires. - Implement listeners and responses for the device events described in Socket.IO events, including scan requests, stock reports, scan completion, and selection updates.
The SmartTrackerCloud backend uses a signed JWT for the token and checks the registered device identity again during the Socket.IO handshake. An ordinary WebSocket server is insufficient: the device expects the Socket.IO/Engine.IO protocol and the event contract above.
For model-specific setup and legacy JavaRFID details, consult source-archive/rfid_device_setup.md in this repository.