Archive for 17 mayo 2010

Programming PyS60 in Linux

mayo 17, 2010

Some time ago I wrote about how to control your PC using your Nokia S60 mobile phone (see it here). It consisted in an application written in Python which stablished a connection between the phone an the computer and according to user inputs in the phone it performed one or another action in the computer.

I was really interested in programming my mobile phone to develop some applications I have in mind and as I also wanted to learn some Python this past weeks I’ve spent some spare time doing my first applications. I’m going to explain how can you program your S60 phone with Python under Linux and in following posts I’ll try to write some tutorials about how to develop some applications.

In order to program your S60 phone with Python, first of all you should get the interpreter and install it into your phone. You can find it in sourceforge (current version is 1.4.5) and where you should download the one according to your phone. As mine is a Nokia N70 I’m using PythonForS60_1_4_5_SDK_2ndEdFP3. Download both the interpreter and the script shell and install them into your phone. I also recommend to download the latest API documentation.

At this point you should be able to execute Python scripts in your phone, by the way, some examples are provided with the interpreter try to run them in order to check that the installation was succesfully done.

Lets go now with the funny part, programming our own applications under Linux. The following options are available:

  • Programming the application directly on the phone (which I consider very cumbersome so lets discard it).
  • Programming the application on your computer and transfering and running it in the phone (which is not a bad option but, in my opinion, it is not really the best option).
    In order to do this in a more easy way you could use the PUTools utility which will help you transferring the files, interacting with the phone, taking snapshots… in an easier way through a terminal running in your computer.
    In the PUTools page, the instructions are writter for Windows users, but it’s not hard to adapt them for Linux users, basically what you have to do is:
    • Edit the pcfiles/sync.config to specify the connction port (I’ll use rfcomm0)


      #COM_PORT = 11
      COM_PORT = '/dev/rfcomm0'

    • Adding a Serial Port service for the bluetooth:


      sdptool add service=SP --channel=3

    • Getting ready for incomming connections on rfcomm0:


      $> rfcomm listen /dev/rfcomm0
      Waiting for connection on channel 1

    • Considering that you have previously installed the push.py script in your phone, run it and choose your computer in the connect dialog. If everything was done correctly you should see a message on your computer like the following:


      $> rfcomm listen /dev/rfcomm0
      Waiting for connection on channel 1
      Connection from 00:1C:9A:40:CB:BB to /dev/rfcomm0
      Press CTRL-C for hangup

    • And now, just run pcfiles/push script to get the terminal which will let you directly interact with the phone!
      Putools connected

      PUTools working console

  • Programming in your computer, testing your applications on it using an emulator, and once the applications are working correctly transferring them to the phone (which for me is the best option).
    In order to do this, you’ll have to download the PyS60 emulation library (S60-compact) available in sourceforge and which will let you test a lot of your applications directly in your computer without needing to transfer them to your phone. (Notice that modules like camera or some fonts are not available but will be more than enough for letting us introduce in the world of PyS60 programming!).
    What I usually do is programming the application on my phone, test that it works correctly and later on transferring to my phone with the single following command, and later on run the interpreter in the phone and selecting the transferred script.


    $> obexftp -b 00:1C:9A:40:CB:BB -c C:\\System\\Apps\\Python -p script.py

Now it’s time to start coding our first applications in Python. I recommend reading the API and the following tutorial which is one of the best I could find:

In following posts I’ll show you how to code step by step a very simple eyecandy-but-useless application covering several aspects of the PyS60 API.

Happy coding!

Anuncios

ViñaRock ’10

mayo 6, 2010

Si hace un año escribía acerca de mi primer ViñaRock, este año no podía dejarlo pasar aunque seré bastante menos extenso… creo que le estoy perdiendo el gusto a esto de escribir y comunicarle al mundo lo que pienso o lo que me pasa 😦

El jueves 29 de abril salí hacia Villarrobledo con un par de amigos (Adri y Nacho), como siempre la hora de salida esperada diferió mucho de lo planificado aunque esta vez solo nos retrasamos un par de horillas. Llegamos de noche y cansados tras habernos dado muchas vueltas por culpa del GPS, yo no sé que le pasa pero en los últimos viajes se empeña en hacerme conocer la España profunda y alejada de la civilización que, siendo sinceros, no tengo ninguna gana de conocer.

Al día siguiente tuvimos que ir a buscar a Sara a Ocaña y luego nos juntamos con un par de amigos de Huesca que, como auténticos señores, habían venido en una caravana con todo tipo de lujos.

Todos en el Viña

Club del ojo negro

Resumiré los cuatro días como un periodo de defase absoluto. Música conocida (DefConDos, S.A, SKA-P, Benito Kamelas. Violadores del Verso…) y desconocida (O’Funkillo, La Pulqueria, Skunk D.F…), que quizás este año me pareció algo peor que el anterior, dormir muy poco, comer mejor que la mayoría (ventajas de ir con un hornillo y tener ganas de cocinar), encontrarse con conocidos y antiguos conocidos, muchas risas, guitarreos a altas horas de la noche, una parrillada, alguna que otra droga blanda y por lo general, en un estado en el cual tu mayor preocupación es pegarte una ducha para quitarte el polvo y encontrar un baño decente donde hacer tus necesidades.

Si al año que viene estoy por estas tierras repetiré. Aunque la música me haya decepcionado un poco: mediocre fue la actuación de Celtas Cortos, sin embargo Lehendakaris Muertos me pareció un grupo con un directo impresionante y divertidísimo, además, en este tipo de festivales la música es importante pero, desde mi punto de vista, puede quedar en un segundo plano después del ambiente y las ganas de pasarlo bien de todo el mundo.

El año que viene os lo vuelvo a contar… 🙂