With lots of GPRS modem applications, data needs to be stored inside the modem itself. A while ago we saw how to create files inside the GPRS modem’s Flash memory, so it was working as if it were a disk drive.

What type of applications? Well for example, it could be a datalogger, a GPS tracker or any other application that needs to keep a log (a file) that has certain data collected periodically. Obviously if we are working with GPRS modems, it’s to transmit data at some point. When it’s time to transmit the data stored in the modem to a central server via GPRS, compressing data before sending it could be quite interesting depending on the size of the data file that we are working with.

Why would sending compressed data be interesting?

For two reasons. One to save time in the sending process. The other is for economic reasons, remember that in most cases telephone operators charge for traffic volume i.e. the more data you transmit, the more you pay.


And how do you compress files with J2ME?

Well the first thing that usually occurs to all of us is we start looking to see if J2ME has a class that can help us with this task. Regrettably you soon realize that there isn’t, J2ME doesn’t have these classes due to its limitations (remember that J2ME is designed for devices with little resources). Instead, J2SE (Java Standard Edition) has classes. With the complete Java edition you only have to use the java.util.zip package to manage compressed files easily. After seeing this, the next thing that occurs to us is “ok, I am going to see if I can adapt these J2SE classes to try and make them work with J2ME”. But after a few wasted hours of trying, you realize it’s not going to be an easy task as certain native Zlib classes are used.

So you investigate alternatives…  There’s not a lot on the internet when you Google about J2ME compression and there’s a lot less if we search for something related to compression and GPRS modems, so I think that internet users will land on this post. So after searching for a while, you find project JZLib (on the web http://www.jcraft.com/jzlib/), which is a free software project where you can re-implement ZLIB. You can get all the information that you want about this site, I won’t go into details.

And does it work? Can you compress files inside the modem using this software library?

Well yes, it works. :)

I’ll post a little Java example that works with a TC65 or MTX65 modem. You can download it by clicking here.

The example basically compresses the text: “en la granja de mi tia iaiaooooooooooooooooooooooooo” :) (equivalent to Old McDonald had a farm in English) and it saves the final result i.e. it saves the compressed text in a file (in the modem’s internal Flash memory) with the name “data.z”. If you see the project’s source code, you can see that I’ve put all of the .java files from the compression library in the same project. Obviously it could have been used as a library but I didn’t want to cause any confusion and you can test out the example without any difficulties.

It works! I’ve compressed the test in a file. But if then if I remove the modem’s compressed file with MES and I put it on my PC, can I not unzip it with WinZip?

No it won’t work with WinZip as a file with just compressed data has been created i.e. ZLIB compresses the file but if you want to use WinZip you will have to build the ZIP files structures, with the headers and everything else. (http://www.pkware.com/products/enterprise/white_papers/appnote.html).

Whew, ZIP headers are difficult. Can I not decompress the files in any other way?

Well yes, with a Zlib decompressor. But I will put that in a post in a few days time (probably Sunday). I will also try to include a little program made in VB6 (with a source code that you can use of course) which is able to unzip files made by the modem. That way you will have everything you need in order to compress a file with a modem, send it via GPRS and decompress it afterwards using our server.

Well I hope that you found the post interesting and that it’s useful to you one day. I’m going to have dinner now. ;)

Post relacionados:

  1. J2ME File Compression in Siemens TC65 GPRS Modems – II A few weeks ago  I posted about J2ME file compression in Cinterion TC65 and...
  2. Java FTP example for Cinterion GPRS modems TC65 and XT65 You will possibly at some point have to make a...
  3. Adding Data to Files from Java with Siemens-Cinterion Modems On several occasions I have been asked how to add...
  4. Locating Difficult Reproduction Failures in TC65/XT65 Cinterion Modems If you develop applications in Java for GPRS TC65, XT65 (or their MTX65 or MTX65+G terminals...
  5. FTP Java Example for Siemens Modems Today I am going to write a small post with...

Tags: , , , , , ,
8 Responses to “J2ME File Compression in Siemens TC65 GPRS Modems”
  1. Carlos Garcia says:

    hola blogelectronica,
    ante todo te agradezco el trabajo que haces en este estupendo blog. Muy completo.

    me gustaria preguntarte si pondrás el programa (en el lenguaje que sea) para descomprimir el fichero comprimido por el módem como dices en el post. Me viene muy bien para un proyecto que estoy haciendo con un módulo TC65. Un cordial saludo y gracias de antemano.

  2. blogElectronica says:

    Hola Carlos,

    sí, lo pondré esta semana. Disculpa la espera, ya sabes … las vacaciones.


  3. Juan says:

    Carlos, la descarga del ejemplo del link que comentas es un proyecto con codigo vb…. ¿?

  4. Javier says:

    Antetodo muchas gracias.
    Donde decis “A continuación os voy a poner un ejemplito java que funciona en un módem TC65 ó MTX65. Lo podéis descargar haciendo click aquí.”, se descarga un proyecto en “VB” (supongo el q descomprime), necesitaria saber si tenes el link donde poder descargar el ejemplo en “JAVA j2me” (el q comprime)….

    Muchas Gracias.

Leave a Reply

Puedes publicar un comentario aquí si quieres, pero te recomiendo que uses el nuevo foroElectronica.com para introducir comentarios. Te contestaré más rápido. Recuerda que debes registrarte si no lo estás para publicar un comentario.