<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: s60 code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 00:55:16 GMT</pubDate>
    <description>DZone Snippets: s60 code</description>
    <item>
      <title>gps gsm location python s60</title>
      <link>http://snippets.dzone.com/posts/show/2029</link>
      <description>Hi Guys,&lt;br /&gt;&lt;br /&gt;I've just put together two smaller Python apps I've seen around in this discussion board.&lt;br /&gt;&lt;br /&gt;The resulting app prints 1) info obtained by a BT gps (i.e. $GPRMC sentence, but may change as you like) and 2) GSM cell id.&lt;br /&gt;&lt;br /&gt;My wish is to collect these info periodically (i.e. 2/3 minutes) and send them back via an HTTP POST to a specified host.... could anybody help? ;-)&lt;br /&gt;&lt;br /&gt;Thanks&lt;br /&gt;&lt;br /&gt;-Luca&lt;br /&gt;&lt;br /&gt;____________________________________&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Simple BT App&lt;br /&gt;#$GPRMC,161229.487,A,3723.2475,N,12158.3416,W,0.13,309.62,120598, ,*10&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import socket,location,urllib&lt;br /&gt;&lt;br /&gt;class BTReader:&lt;br /&gt;&lt;br /&gt;def connect(self):&lt;br /&gt;self.sock=socket.socket(socket.AF_BT,socket.SOCK_STREAM)&lt;br /&gt;address,services=socket.bt_discover()&lt;br /&gt;print "Discovered: %s, %s"%(address,services)&lt;br /&gt;target=(address,services.values()[0])&lt;br /&gt;print "Connecting to "+str(target)&lt;br /&gt;self.sock.connect(target)&lt;br /&gt;&lt;br /&gt;def readposition(self):&lt;br /&gt;try:&lt;br /&gt;buffer=""&lt;br /&gt;ch = self.sock.recv(1)&lt;br /&gt;while(ch !='\n'):&lt;br /&gt;buffer+=ch&lt;br /&gt;ch = self.sock.recv(1)&lt;br /&gt;# print buffer&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (buffer[0:6]=="$GPRMC"):&lt;br /&gt;(GPRMC,utc,status,lat,latns,lon,lonew,knots,course,date,xx1,xx2)=buffer.split(",")&lt;br /&gt;return "GPS (%s,%s,%s,%s,%s)"%(utc,lat+latns,lon+lonew,knots,course)&lt;br /&gt;except Error:&lt;br /&gt;return "Error!\n"&lt;br /&gt;return ""&lt;br /&gt;&lt;br /&gt;def close(self):&lt;br /&gt;self.sock.close()&lt;br /&gt;&lt;br /&gt;class GSM_loc:&lt;br /&gt;&lt;br /&gt;def upd(self):&lt;br /&gt;self.loc = location.gsm_location()&lt;br /&gt;return "GSM (MCC:%s MNC:%s LAC:%s CID=%s)"%(self.loc[0], self.loc[1], self.loc[2], self.loc[3])&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;gsm = GSM_loc()&lt;br /&gt;&lt;br /&gt;bt=BTReader()&lt;br /&gt;bt.connect()&lt;br /&gt;&lt;br /&gt;i=0&lt;br /&gt;while (i&lt;15):&lt;br /&gt;print gsm.upd()&lt;br /&gt;print bt.readposition()&lt;br /&gt;i+=1&lt;br /&gt;&lt;br /&gt;bt.close()</description>
      <pubDate>Mon, 15 May 2006 21:09:44 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2029</guid>
      <author>ollip1 ()</author>
    </item>
    <item>
      <title>s60 http post python</title>
      <link>http://snippets.dzone.com/posts/show/2028</link>
      <description>From (http://www.python.org/doc/current/lib/httplib-examples.html)&lt;br /&gt;&lt;br /&gt;==&lt;br /&gt;import httplib, urllib&lt;br /&gt;&lt;br /&gt;# replace with whatever you want POSTed...&lt;br /&gt;gps_coords = urllib.urlencode({'param_1': 'value_1', 'param_2': 'value_2'})&lt;br /&gt;&lt;br /&gt;# form contents&lt;br /&gt;headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}&lt;br /&gt;&lt;br /&gt;conn = httplib.HTTPConnection("location-server.com:80")&lt;br /&gt;conn.request("POST", "/cgi-bin/collect_loc", gps_coords, headers)&lt;br /&gt;response = conn.getresponse()&lt;br /&gt;data = response.read()&lt;br /&gt;conn.close()&lt;br /&gt;==&lt;br /&gt;&lt;br /&gt;Both httplib and urllib are shipped with PyS60. Of course, you will have to create the CGI script separately.&lt;br /&gt;&lt;br /&gt;Cheers,&lt;br /&gt;Sandeep&lt;br /&gt;http://sandeep.weblogs.us/</description>
      <pubDate>Mon, 15 May 2006 21:08:37 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2028</guid>
      <author>ollip1 ()</author>
    </item>
    <item>
      <title>Discover bluetooth devices around you</title>
      <link>http://snippets.dzone.com/posts/show/982</link>
      <description>Pys60 has good bluetooth support from the beginning.&lt;br /&gt;However, to discover another device, it require you to&lt;br /&gt;interact with the app, choosing a device from the list.&lt;br /&gt;&lt;a href=http://pdis.hiit.fi/pdis/download/pdis/&gt;PDIS&lt;/a&gt; has a library that help you list all devices silently.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# need to install these 2 modules from PDIS first&lt;br /&gt;import aosocketnativenew&lt;br /&gt;from aosocket.symbian.bt_device_discoverer import *&lt;br /&gt;&lt;br /&gt;def callback(error, devices, cb_param=None):&lt;br /&gt;    for address, name in devices:      &lt;br /&gt;        print "Found: ", name, address&lt;br /&gt;# You can get more data by importing socket and try &lt;br /&gt;# bt_discover(address) or bt_obex_discover(address)&lt;br /&gt;# see details in official pys60 doc on socket module&lt;br /&gt;&lt;br /&gt;lister = BtDeviceLister()&lt;br /&gt;lister.discover_all(callback, None)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;I summarize the code above from thejamo's example &lt;a href=http://discussion.forum.nokia.com/forum/showthread.php?p=176190#post175725&gt;here&lt;/a&gt;.&lt;br /&gt;His code is more complete with error checking.</description>
      <pubDate>Fri, 16 Dec 2005 03:30:52 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/982</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>Getting key press</title>
      <link>http://snippets.dzone.com/posts/show/937</link>
      <description>In Pys60 1.2 there are 3 types for app.body, namely&lt;br /&gt;- Canvas&lt;br /&gt;- Text&lt;br /&gt;- Listbox&lt;br /&gt;They can recieve and process key press.&lt;br /&gt;In older versions, they all have a bind method:&lt;br /&gt;&lt;code&gt;bind(event_code, callback)&lt;/code&gt;&lt;br /&gt;event codes are defined in key_codes module&lt;br /&gt;You can import some or all of them&lt;br /&gt;&lt;code&gt;from key_codes import EKeyLeftArrow, EKeySelect, EKey9, EKeyEdit&lt;/code&gt; See &lt;a href=http://www.flickr.com/photos/korakot/69980686/&gt;diagram &lt;/a&gt;for 6630.&lt;br /&gt;&lt;br /&gt;In the latest version, Canvas gains ability to respond&lt;br /&gt;to events in more details. You can give it 2 callbacks&lt;br /&gt;when creating a Canvas object.&lt;br /&gt;&lt;code&gt;c = Canvas(redraw_callback=None, event_callback=None)&lt;/code&gt;&lt;br /&gt;event_callback will get a dict of the key event containing:&lt;br /&gt;- 'type': one of EEventKeyDown, EEventKey, or EEventKeyUp&lt;br /&gt;- 'keycode': the logical key&lt;br /&gt;- 'scancode': the physical key&lt;br /&gt;- 'modifier': probably about Shift, Ctrl ?&lt;br /&gt;&lt;br /&gt;The simplest use is to detect when type=EEventKey&lt;br /&gt;and use the 'keycode' value.&lt;br /&gt;For advanced use, look at keyviewer.py example.</description>
      <pubDate>Sun, 04 Dec 2005 19:58:08 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/937</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>Nokia platform version</title>
      <link>http://snippets.dzone.com/posts/show/851</link>
      <description>The way Nokia names their phone versions is rather confusing.&lt;br /&gt;For example.&lt;br /&gt;&lt;code&gt;Series 60 Platform 2nd edition feature pack 2&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;I wonder why don't they just use s60.2.2&lt;br /&gt;Now, at least they have renamed 'Series 60' to 'S60'&lt;br /&gt;which is a good step in the right direction.&lt;br /&gt;&lt;br /&gt;So, I will tag all new python for series 60 scripts with&lt;br /&gt;'python, s60' instead of the old 'python, series60'.</description>
      <pubDate>Fri, 04 Nov 2005 13:08:44 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/851</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
