Mobile Phone Programming and Its Application to Wireless Networking
Total Page:16
File Type:pdf, Size:1020Kb
Mobile Phone Programming Mobile Phone Programming and its Application to Wireless Networking Edited by Frank H.P. Fitzek Aalborg University Denmark and Frank Reichert Agder University College Norway A C.I.P. Catalogue record for this book is available from the Library of Congress. ISBN 978-1-4020-5968-1 (HB) ISBN 978-1-4020-5969-8 (e-book) Published by Springer, P.O. Box 17, 3300 AA Dordrecht, The Netherlands. www.springer.com Printed on acid-free paper © 2007 Springer No part of this work may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, microfilming, recording or otherwise, without written permission from the Publisher, with the exception of any material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. To Sterica and Lilith. — Frank H.P. Fitzek I dedicate this book to Tim (WoW Level 70, mighty Undead Warrior), Max (Wow Level 70, fearless Tauren Hunter), and Aida (Reality Level 80++, loving Human Wife and Mother) — Frank Reichert (Level 64) Foreword Saila Laitinen Nokia The technology evolution has been once and for all beyond comparison during the past decade or two. Any of us can nowadays do numerous things with numerous devices to help in everyday life. This applies not least to mobile phones. If we compare the feature set of a mobile phone model in 1995 with the latest smartphone models the most visible difference is of course in the user interface, the mp3 player, integrated camera, and the access to the mobile Internet. This evolution is a result of multiple members in the entire mobile eco- system: (1) device manufacturers have managed to bring richer devices into markets, (2) operators have invested in network enablers heavily, (3) develop- ers have found mobile platforms fancy to innovate on, and last but not least (4) consumers have discovered the benefits of using the rich feature set of mobile devices and they have welcomed them into their lives. This book gives a thorough picture of all options a developer can choose from when developing mobile applications or other content. It explains Python; that is especially suitable for scripting, supports procedural programming, and object-oriented programming. Java, an object-oriented programming language developed by Sun Microsystems. Symbian C++, a programming language tai- lored to mobile programming. Open C provides the familiar standard C func- tion libraries in mobile development. Qtopia’s greenphone is a Linux mobile development device open for innovation. Maemo Linux, an embedded Linux development environment for mobile innovation. Windows Mobile, a com- pact operating system combined with a suite of basic applications for mobile devices based on the Microsoft Win32 API. In addition to the above, the book focuses on mobile application design for wireless communication systems. Besides the well-known cellular architec- ture also the peer-to-peer and cooperative networking is introduced. Concepts such as cross-layer design and the convergence of wireless sensors with mobile phones are introduced and examples are given. Furthermore the energy con- sumption of mobile phones is addressed and designing rules to develop energy- efficient mobile applications are presented. I truly see that once the wireless viii Foreword internet really goes live all around the world; there are only winners in this industry. I highly recommend reading this book, start the real mobile innovation so that together we can make people all around the world connected with each other without compromising in our mobility. Helsinki, Finland Saila Laitinen April 2007 Head of Regional Operations, Forum Nokia Preface The main source of motivation to write this book is the beauty of the mobile phones as an inspiring platform for research as well as teaching activities. To prove an idea or a concept in the research domain, there are mainly three possibilities, namely analytical evaluation, simulative evaluation, and implementation on an appropriate platform. The problem with the analytical and the simulative evaluation is that analytical derivations become more and more complicated reducing the possible audience or that the chosen simula- tion environment is not fully transparent. Therefore we need to implement our proof of concept on omnipresent platforms to introduce it to a larger audience. The mobile phones are omnipresent entities and are suitable as proof-of-concept platforms as they have two advantages over any other plat- form; first they are not that cost-intensive and second mostly everybody owns one mobile phone by themselves or at least has had experience with it. As we will show throughout this book, the degree of freedom to implement whatever idea in the world of wireless networking is nearly infinite and sometime only restricted on purpose by the mobile phone manufacturer. Of course a mobile phone has some limitations in the memory capacity, the processing power, and the limited energy due to the battery-driven entity. But those limitations should not be understood as a disadvantage, but more as setting design rules for new solutions in the real world. To use the mobile platform in student and master projects we started to introduce mobile phone programming within our teaching activities. This topic is mostly new to students and they come with heterogeneous knowl- edge of programming languages. Different courses cover Python, JAVA, and Symbian/C++. Within the book we have extended the group of programming languages and deployment environments with topics such as Windows Mobile, Maemo, Qtopia, and Open C. In addition to the programming teaching, we encourage students to use their new knowledge within future research projects and to make their own mobile applications. The importance of mobile applications introducing new kinds of services has been and is still underestimated. With the introduction of the second xPreface generation networks, new services were provided to the customers namely mobile speech services, roaming between different countries, low data rate IP connection, and more advanced security. The introduction of the third gen- eration did not bring de facto revolutionary new services, which may explain why this generation of mobile communication systems is not having the same success as its forerunner had when it was introduced. Thus services are the key for successful communication networks. We sincerely hope that this book is a contribution to enable a new wave of exciting mobile applications that enrich our lives, and that gives students a great start ramp to launch their future careers. Planet Earth Frank H.P. Fitzek April 2007 Frank Reichert Contents Foreword Saila Laitinen ................................................... vii Part I Introduction 1 Introduction to Mobile Phone Programming Frank H.P. Fitzek, Frank Reichert.................................. 3 1.1 Evolution of the Mobile Phones, Networks, and Services . 3 1.1.1 Mobile Phone Family . 3 1.1.2 The Flexible Mobile Phone . 6 1.2 Wireless Technologies and Architectures . 9 1.2.1 Cellular Communication Systems . 9 1.2.2 Short-Range Communication Systems . 11 1.3 Mobile Application Deployment . 14 1.4 StructureoftheBook....................................... 18 References . 20 Part II Mobile Phone Programming Languages 2 Python for Symbian Phones J¨urgen Scheible .................................................. 23 2.1 Introduction . 23 2.2 Python for S60 Installation and Resources . 24 2.2.1 Software Installation on the Phone . 24 2.2.2 Software Installation on the PC (for S60 Platform Device Emulator Use) . 25 2.3 Writing a Python Script . 26 2.3.1 How Python Runs Programs . 26 2.3.2 Three Basic Steps . 26 2.3.3 The First Script Example . 27 xii Contents 2.4 AShortPythonSyntaxLesson............................... 28 2.5 OverviewofPythonforS60Modules.......................... 28 2.6 Modules – and How to Program Python for S60 Scripts . 29 2.6.1 Messaging Module. 29 2.6.2 Appuifw Module . 31 2.6.3 Application Basics . 36 2.6.4 Audio Module: Sound Recording and Playing . 37 2.6.5 Variable Scope: Local, Global . 39 2.6.6 Debugging . 40 2.6.7 Inbox Module: Reading Incoming SMS . 40 2.6.8 Graphics Module and the Use of Keyboard Keys . 41 2.6.9 Image Composition Application: MobileArtBlog . 43 2.6.10 3D Graphics: gles and glcanvas Modules . 44 2.6.11 Camera Module . 45 2.6.12 Video Download and Playing – the Use of Content Handler 46 2.6.13 File Upload to a URL . 47 2.6.14 Mobile Photo Blogging Application . 48 2.6.15 File Handling and Data Storing . 48 2.6.16 Socket Module: Bluetooth, TCP/IP, and SSL . 49 2.6.17 sysinfo Module . 55 2.6.18 Location Module . 55 2.6.19 Telephone Module . 57 2.6.20 Contact Module . 57 2.7 Creating Stand-Alone Applications . 58 2.8 Symbian Platform Security and Python for S60 . 59 2.9 Creating Python Extensions in C++ . 60 2.10 Further Reading Sources on Python for S60 . 60 2.11 Code Appendix . 60 2.12 Links . 61 References . 61 3 Java 2 Micro Edition Gian Paolo Perrucci, Andreas H¨aber ............................... 63 3.1 Java Family Overview . 63 3.2 J2ME Platform . 64 3.2.1 Less Capable Devices: Targeting CLDC . 66 3.2.2 More Capable Devices: Targeting CDC . 67 3.2.3 Networking Support . 68 3.2.4 Optional Packages . 70 3.2.5 Java Technology Standardization . 71 3.3 DevelopmentEnvironment................................... 74 3.3.1 Java Development Kit . 74 3.3.2 NetBeans IDE . 75 3.3.3 Developing MIDP Applications for CLDC . 77 3.3.4 Developing CDC Applications . 82 Contents xiii 3.4 Application Examples . 86 3.4.1 Wireless Messaging API: Sending SMS . 87 3.4.2 Mobile Multimedia API: Audio Player . 88 3.4.3 Communication: Downloading Documents with GCF . 90 3.4.4 XML Parsing: Parsing RSS .