Message Syntax for File, Smart Card, and Bluetooth Devices
Introduction
To enable Mendix Workstation Client to communicate with your devices, you must ensure that the messages you send have the correct syntax. This syntax varies depending on the type of device. The following sections show the required syntax for file system, smart card, and Bluetooth devices.
Bluetooth
This device type requires the following message and response:
Message
0#ServiceUUID#CharacteristicUUID- Subscribe to characteristicCharacteristicUUIDfrom serviceServiceUUID.1#ServiceUUID#CharacteristicUUID- Unsubscribe from characteristicCharacteristicUUIDfrom serviceServiceUUID.2#ServiceUUID#CharacteristicUUID- Read characteristicCharacteristicUUIDfrom serviceServiceUUID.3#ServiceUUID#CharacteristicUUID- Write to characteristicCharacteristicUUIDfrom serviceServiceUUID.
Response
CharacteristicUUID#Response
File Device
This device type requires the following message and response:
Important Considerations
Before sending messages to the File Device, review the following points:
- Path handling - You can provide the paths either as absolute (for example,
/var/log/app.logorC:\Data\report.txt), or as relative paths. Relative paths are always interpreted relative to the allowed folder configured in Workstation Management. - Delimiter - The
#character is used as a delimiter within messages. Paths and data may not contain the#character. - Case sensitivity - File and directory paths may be case-sensitive depending on the underlying operating system. For example, Linux paths are typically case-sensitive, while Windows paths are not.
Message
0#Path- Initiate watching for changes in the specifiedPath. IfPathis a directory, the device will watch for changes within that directory (creation, deletion, renaming, or modification of files/subdirectories). IfPathis a file, the device will watch for changes to that specific file (modification, deletion, or renaming).1#Path- Stop watching for changes in the specifiedPath.2#File path- Read the content of the file at the specifiedFile Path.3#File path#Data#flag- WriteDatato the file at the specifiedFile Path. Theflagcan bewfor overwrite,afor append If left blank, the value defaults tow.
Response
R#Path- File or directory at the specifiedPathwas renamed, created, or deleted.C#Path- File or directory at the specifiedPathwas changed. This is triggered both when a file is modified and when the contents of a directory changes.D#Data-Datafrom file read.E#Error-Errormessage from operating system.S#{0,1,2,3}#directory- The command{0,1,2,3}ondirectorywas successful.
Example Test
The section below shows a sample test that you can run to verify the configuration.
-
Create a new Workspace in the Workstation Management.
-
Create a new Station.
-
Add a
File Devicewith the following configuration to this Station:- Device Name - Write files to test folder
- Allowed Folder - For example, on a Windows computer you can use a path like
C:\MyTestFolder - Allow writing files - Yes
- Use the default values for everything else
-
Register the Station to your computer (assuming the Workstation Client is installed there).
-
In your Workspace, navigate to Test Your Station and click on the configured file device.
-
Enter
3#test.txt#Hello from Mendixin the Send Message field, and then press Send Message.The test should show a response like
S#3#C:\MyTestFolder\test.txtto indicate that the text file test.txt was successfully written to MyTestFolder. -
Go to C:\MyTestFolder and verify that it contains the text file.
-
Open the test file and verify that it contains the text Hello from Mendix.
Card Readers
This device type requires the following message and response:
Message
Send instruction in hexadecimal as a string, for example, FFCA000000 to read the smart card ID. The messages exchanged with the smart card are APDU messages. For more information, refer to the documentation of the APDU command for your smart card reader.
Response
0#- Card connected1#- Card disconnected2# Response- Response from device as raw hexadecimal.3# Error- Error message from device.