System structure - Midlets and / or threads? | Telit Cinterion IoT Developer Community
March 17, 2015 - 12:59am, 3001 views
I amd looking at the feasibility of designing a system which is required to have the following functionality:
· Listen for HTTP activity.
If user request from Web browser, request data from RS232 port, create web page with data.
· Listen for SMS – ie for OTAP updates.
· Listen for input from the RS232 port. Inspect data to determine if HTTP, FTP, SMS or SMTP request(s) and action that request.
With the above requirements how can the system be best divided into threads and / or Midlets ?
Midlet 1: Creates a socket connection for HTTP transfers - use threads to handle multiple user request – typically up to five on an EHS6T modem.
Midlet 2: Handler OTAP updates via SMS requests.– a separate Midlet with pipe connection number of threads
Midlet 3: Handler communications from the RS232 port which may be to / from the port.
I would like to support both FTP and HTTP – would separate sockets be required for FTP and HTTP, and thus limit number of users to a maximum of four? If a separate socket would it be best to use a separate midlets for HTTP and FTP.
Unsure of the implications of trying to support both FTP and HTTP since although Midlets can be run in parallel, they can’t share the same hardware resource.
Any help would be appreciated in determining how the above system should be structured – and fill in the large gaps of my knowledge of the capabilities / limitations for designing the above system for running on an EHS6T modem.
High-lighting any limitations of any recommended structure would also be appreciated to allow the final system to be optimised if requirements change.
somebody from Gemalto will be able to respond to your questions with more precise information. I can just tell you that from my experience of trying to set up BGS5T as HTTP server, this will probably won't be easy task and server won't be fast. Also you should check with your cell phone provider, because in my case provider is blocking incoming traffic on HTTP port 80. So we had to have special SIM card which, had a tunnel inside company’s local network, so I could connect just from computers inside our company. Another limitation could be number of sockets opened at the same time. You should test this, but as far as I know you can have at least 3 opened sockets at the same time.
Listening on RS232 is not so hard to do. You just have to set up some simple protocol to know when there is end of msg.
I hope that I answered at least some of your questions.
OTAP (remote application update) is a feature of the module so you don't need to implement any special applications to handle this until you need some additional functionalities which are not provided. When OTAP SMS comes and the update procedure is started any running applications are stopped and module is restarted after download.
All of your functionalities seem to depend on each other so I think that it could be better to create one MIDlets in this case.
For HTTP and FTP connections you should listen on dedicated ports. Please note that there is no provided Java API for FTP and HTTP servers.
Please also note that (according to documentation) sockets are limited and it may take up to 60 seconds to release the resources after closing the socket. If TCP/IP connections are rapidly open and closed (e.g. SocketConnection, HTTPConnection), a ConnectionNotFoundException "No buffer space available" may be thrown, indicating that all TCP/IP socket resources are exhausted.
Thankyou for your replies.
The impression I get from your response that trying to cater for all the above connections would cause a resources issue, so need to look at other options.
The HTTP socket is to cater for user access via a standard browser, whereas uploads to an external FTP Server would be for uploading data to, which would be a very infrequent event.
This may give two options to consider:
i) Only connect to the external FTP server when required, though at the expense of the initial connection time penalty - somthing I was hoping to avoid. Though access to a external FTP server can give other issues if hosted on a customers site, apart from customer user issues for access to internal / external FTP Servers.
ii) : Instead of automatically uploading data to a FTP server allow the user to download via the browser page?. I am familar with methods for generating a browser page and populate with data and sending to the user - but not on what is required to allow a user download afile - so any suggestions / help in this area would be appreciated.
The resource issue doesn't mean that your solution is impossible. I only wanted to show you some limitations. Anyhow it's a small device so it will not be able to act as a regular web server and accept big traffic but you can have a server on it and accept connections from a limited group of users. I don't know your solution but usually many devices in the field communicate with one server which collects data from devices which can be accessed by some group of users.
In the field data will be collected from a number of devices. However there will normally not be a lot of data, about 11Kb, since it is basically being used to collect data when a device reports a fault. There will be a limited number of people who will access that data, so the limited number of sockets on the EHS6T would not be an issue.
Having a FTP Server means the data can be dumped onto this server and accessed by any number of people, though normally in reality there would only be two or three. My current query is whether I could have the option, ie where there is only one user, to be able to instigate a download to a users computer rather than to a FTP Server, and thus save the hassle of dealing with IT to get access, particularly if the FTP server is hosted externally. However my knowledge in this area, is very much lacking on what can be achieved and the best way of achieving it, and thus looking for any pointers to how each of my possible congigurations could be achieved.
As I understand your intention well the FTP is to make it possible for the user to connect to the device directly to download some data without having any dedicated application, just any ftp client.
This of course should be possible. FTP server would need to be implemented on the device. FTP protocol is quite simple.
Implementation of simple FTP client would not be complicated. Server should also be possible. Tests with some ftp clients would be needed.
But you would need a public IP address for each device from your operator to access the server. And this is usually an additional extra paid service.