How to work with Websockets using Java in EHS5T and ELS61T Terminals | Telit Cinterion IoT Developer Community
November 27, 2018 - 11:56am, 2356 views
Greetings to you good People of Gemalto Support Forums.
I need to implement OCPP1.6-JSON Protocol which requires the use of Websocket Protocol on EHS5T as well as ELS61T Terminals.
When checking the documentation i noticed that the term "websocket" isn't mentioned at all, neither in the Java User Guide, nor in the AT Command Set. This realization brought me to these forums looking for guidance.
I found the following Thread:
Problem is that this thread doesn't help at all!
One thing is that we don't need websockets for work with an FTP server like this script supposedly shows, but for transmitting and receiving JSON-encrypted messages. The other thing is that according to the AT Command Set the AT-comands as used in the script don't have anythng to do with websockets, but normal sockets instead.
Please point me in the right direction regarding:
Any hints on how to implement websockets and whether i somehow interepreted the documentation wrong.
Are there any libraries for websockets that are compatible with the J2ME-Environment on these devices that you know of or can recommend?
I searched the internet for hours looking for compatible libraries, but as you can imagine it's very difficult, if not impossible finding a library implementing technology that was still very new in 2011 (websockets) for an environment that **** in (circa.) 2000 (JavaME).
Please dear people of Gemalto Support - help me out here!
Thanks and Best Regards!
The module supports only bare socket, secure socket and a basic http/https client. These functionalities are available with AT commands and Java API. Please see here for more documentation: https://iot-developer.thalesgroup.com/documentation/download-documentati...
You may find javadoc in Java_SDK folder - please download install-cd package, unzip and search in program files\Cinterion\CMTK\. There is no JSON API provided. There's XML API.
Gemalto does not provide WebSocket API. Unfortunately for now we also don't have any example application and I cannot recommend you any particular library.
For a not complicated scenario the easiest way could be to hardcode some JSON messages if possible for your scenario.
You can also use the module as a modem and implement the application logic in some other device.
In case of terminals there is also LAN terminal version which is intended to provide internet connection to device connected to LAN port. This terminal has an additional processor with OpenWrt Linux to control LAN functionality and the Gemalto module is used as a modem connected to OpenWrt with USB.
Unfortunately using bare sockets isn't possible with OCPP1.6-JSON, the use of Websocket Protocol is strictly required and in our case they also need to be TLS-encrypted.
Please tell me if i understood you wrong here (using bare sockets instead of websockets).
I already have the JavaDoc, as well as the whole install-cd, and of course already checked all the documentation even before coming to these forums.
Hardcoding some JSON messages wouldn't be possible in our case because there are a lot of dynamic values that need to be sent in those messages - so we'd need at least a function that takes these values as parameters and generates the JSON messages .
I also looked into the possibility of implementing websockets on the terminal myself using sockets, but unfortunately the amount oif work required to do that seems absolutely astronomical - typical implementations have tens of thousands of lines of code from what i've seen and that's just using regular, modern java (1.7 and above).
In summary this doesnt seem practical at all.
My point about bare sockets and web sockets was that standard API does not provide any upper layer protocol that you need and you'd have to add your own implementation of web sockets on top of sockets. Implementing it from scratch might require a big effort as you noted.
The standard Java API supports TLS. There is also a simple http implementation and in new modules there is also CoAP.
You may also consider introducing additional microcontroller for your logic and using the module as a modem or adding some kind of proxy between the module and your remote system.
Bogdan, did you succeed on running OCPP with websockets on EHS ?
Exactly as you, I have to implement OCPP1.6-JSON with websockets on EHS. And I'm stucked at websockets. I have a j2me websocket library, but I can't connect to the server yet (Connector.open(url) problems : ws vs socket).
Link to the discussion about the mentioned WebSocket issue: https://iot-developer.thalesgroup.com/threads/ehs5-websocket-link-server