Hot File

A Simple Guide To Mobile Phone File Transferring

View: 2343    Dowload: 0   Comment: 0   Post by: naruto  
Author: none   Category: Windows phone   Fields: Other

9 point/5 review File has been tested

Download   a-simple-guide-to-mobile-phone.zip (96.21 KB)

You need to Sign In to download the file a-simple-guide-to-mobile-phone.zip
If you do not have an account then Sign up for free here

Download error   Report copyright violation

With the extensive development of the mobile phone industry, our mobile phones are becoming more powerful than before. Today, mobile phones can process pictures, sound, and even video. We can get pictures from a phone's camera, or download them from a PC or from a web site. I have two phones, a Siemens CXV65 and a Nokia 6021. It is boring that I must install two separate software when I want to transfer a picture to them. And this really takes a lot of my disk space and slows down my machine. Though we can buy commercial software to do this, I was wondering if it was possible to develop a software by myself? That was a surprising idea, and I did finish it. Now I will tell you how I did it, in a top-down perspective. In this article, you will learn what is OBEX, FBUS, and a plug-in scheme. I hope the code or data examples and the comments in the source code will give you a clear picture. Hope you like this article!

Introduction

Before I started this program, I did a lot of work on SMS (Short Message Service) using Visual Studio 2003. It's hard to find a really stable and extensible serial port class under .NET 1.1, and because of this, a lot of work failed at this period. But today, both .NET 2.0 and .NET 2.0 Compact Framework provide us a pretty good serial port class under the System.IO.Ports namespace, which is stable, extensible, and easy to use. So now, we can write our own serial port programs much easier than before.

Both of my phones are serial port based phones which provide a data cable plug-in. The Siemens CXV65 phone has two kinds of data cables, a 540 data cable and a 510 data cable. I have both of them. When the 540 data cable is plugged, my PC will find a Siemens Modem using COM3. And the 510 data cable is just a PL2303 USB to the Serial Port bridge. Nokia phones have two kinds of cables too, DKU-2 and DKU-5 data cables. My Nokia 6021 uses the DKU-5 data cable which is also just a PL2303 bridge.

As you will see later, Siemens phones use the OBEX (Object Exchange) protocol to handle file transferring, and most Nokia phones use a protocol called the FBUS protocol, and some use the MBUS protocol. OBEX protocol is documented in detail, but it's hard to find FBUS documentation. I'll introduce both OBEX and FBUS later.

Let's start!

A look at my demo program

The complete solution contains seven projects:

  1. FileTransferCodeDemo

    Demo project main form.

  2. SDK

    Software Development Kit for my plug-ins, containing:

    1. An OBEX client protocol (OBEX folder)

      Provides major features including connect, disconnect, and file transfer.

    2. Plug-in interface (IPhonePlugIn.vb)
    3. Serial port connection monitor (Monitor.vb)

      Auto detect a phone by this program.

    4. Plug-in discovery and use service (PlugInSerivce.vb).
  3. Plug-ins

    Other projects are all plug-ins. Plug-ins are mainly based on the service the SDK provides. All plug-ins are used for demo only, and they provide only one way transfer from a PC to a phone. SonyEricsson, Siemens CX6C, and Moto are based on the OBEX protocol. NokiaS40 is based on the FBUS protocol. Samsung is based on its own AT based protocol.

Caution:

  1. NokiaS40 FBUS protocol has only a core technology on PC to phone transferring; no error report, no fail notice. If it fails, it even creates a dead file on your phone, and you can't delete it!!!
  2. All plug-ins should be used at your own risk!!!

I will focus on the SDK project and the plug-ins. To get these projects to work together, please look into the FileTransferCodeDemo project.

The plug-in scheme

Advantages of a plug-in scheme

As mobile phones from different companies are different from each other, we can't write a single program to support all the phones. If we could, it will surely be a large project and will lack extensibility. We must find a way to make our life easier. A plug-in scheme will satisfy such needs:

  1. It's flexible. We can write a main program, and the only work left is to just write plug-ins and copy their DLL files.
  2. It's easy to manage. When we find bugs, we simply modify and test individual plug-ins without touching other plug-ins and the main program.
  3. It's easy to use. If I have one phone, I can copy only one of the DLLs.

The plug-in interface

A plug-in interface is an interface that defines the major common functions we will use in our plug-ins. All plug-ins will implement this interface. Later on, my plug-in service will find all the classes in the DLLs that implement this interface. My interface is shown below:

The plug-in service

Plug-in services provide the ability to search for the DLLs to implement a certain interface. .NET provides us with the System.Reflection namespace to do reflection from a DLL. The FindPlugins function finds all DLLs, and then the ExamineAssembly() function uses reflection to examine the DLLs. The CreateInstance() function is used to create an object instance of the plug-in. Please see the code for details. I thank the author for writing these segments.

I wrote a SelectPlugin() function. This function checks a mobile phone's model ID and then compares it with the <Plug-in>.SupportModelID() string. If they match, the function will return a plug-in number to indicate which plug-in to use.

It's easy to check the model ID of a phone. You can simply send an AT command called "AT+CGMM" to the serial port and then compare the return string.

Use my plug-in code

Here is the code segment to demonstrate the usage of my plug-in scheme:

Dim ap As PluginServices.AvailablePlugin()
ap = PluginServices.FindPlugins(Application.StartupPath, _
     "Dreamworld.FileTransfer.SDK.IPhonePlugIn")
Dim pluginToUse As Integer = _
  PluginServices.SelectPlugin(phoneID, ap)
Dim phone As IPhonePlugIn = _
  CType(PluginServices.CreateInstance(ap(pluginToUse)), _
  IPhonePlugIn)

Basic serial port operation

Here, I will only show you some basic serial port operations used in my code. For more serial port examples, please see MSDN documents.

First, you must import the System.IO.Ports namespace to your project. Then you create a new instance of SerialPort; here, we will call it mPort.

Then you must do some settings to the serial port.

'Replace x with your COM port number
mPort.PortName = "COMx"
'Speed of your link. If you get 
'bad data, please slow down this.
mPort.BaudRate = 115200
'Data Terminal Ready signal. 
'It's better to set this enable.
mPort.DtrEnable = True
'Data Ready to Send signal. 
'It's better to set this enable.
mPort.RtsEnable = True
'Optional, If you want to send AT commands.
mPort.NewLine = Chr(13)
'Open the port
mPort.Open()

At this point, you can simply use mPort.Write() or mPort.Read() to send and receive binary data. To send AT commands, you can use mPort.WriteLine() and mPort.ReadLine() instead.

Here is a simple function to send and receive AT commands.

Function SendAT(ByVal cmd As String) As String
    mPort.NewLine = Chr(13)
    mPort.WriteLine(cmd)
    mATTimeOut = 1000

    Dim response As New Text.StringBuilder
    Dim start As Date = Now
    Do
        Thread.Sleep(10)
        Dim rsp As String = mPort.ReadExisting()
        response.Append(rsp)
        If Now.Subtract(start).TotalMilliseconds > _
                               mATTimeOut Then
            Throw New TimeoutException("AT TimeOut")
        If response.ToString.Contains("OK") Or _
           response.ToString.Contains("ERROR") Then
              Exit Do
    Loop
     Return response.ToString
End Function

For more details, please see my program and also MSDN documents.

Tools to monitor and analyze data transfer

I found a very powerful tool called HHD Serial Monitor for monitoring and analyzing data transfer. It can monitor the data sent and received by your serial port. The newest version can be found here. In this article, I use the version 3.22 because I found that I couldn't monitor a modem in the 4.0 version.

OBEX file transferring

What is OBEX

OBEX is an abbreviation of Object Exchange, which is a top level protocol of the IrDA or Bluetooth technology. OBEX is widely used on mobile devices such as PDAs and mobile phones. Both my phones support OBEX. For Siemens, SonyEricsson, and Motorola, OBEX is easy to use, but Nokia phones use OBEX over FBUS which is hard to use.

OBEX object model and headers

Please refer to the IrOBEX protocol for more details on this subject.

OBEX examples

These examples are from my previous article. I use a serial monitor to monitor the data. A PC is the client and a Siemens M55 is the server.

Note:

Gray color is used for the explanations and yellow color for real data.

  1. Connect, Disconnect

    Data transfer:

  2. Send a file to \Sound\1.mid, 313 bytes.

    Siemens has a maximum package length of 474 bytes. So this file can fill in a package.

    Brief process: Connection->Switch to root->Switch to Sound folder->Put->…

    Exact process: (Ignore connection portion)

  3. Send a file to \Pictures\102725.jpg, 5314 bytes.

    Brief process: Connection->Switch to root->Switch to \Pictures folder->Put->…

    Exact process: (Ignore connection portion)

How to enter and leave the OBEX mode

Now we know how to transfer files, but how do we enter the OBEX mode? A mobile phone company makes their own decision on how to enter the OBEX mode.

Siemens

First you must be able to send an AT command. Then you send "AT^SQWE=0", waiting for a response, and then "AT^SQWE=3", and wait for the response. Then you will be in the OBEX mode.

Tip: I can also see a serial status from GIPSY to OBEX in the phone's factory mode on Siemens M55.

In order to quit the OBEX mode, please send "+++" and wait for more than a second.

Motorola C650

You must be able to send an AT command. Then send "AT+MODE=22", and you are in the OBEX mode.

To leave OBEX mode, you should close your port and re-open, and then everything will be OK.

Sony Ericssion T618/K508

You must be able to send an AT command. Then send "AT*EOBEX", and you will be in OBEX mode.

Using my OBEX code

My Dreamworld.Protocol.OBEXClient.Command class provides basic operations of OBEX, such as connecting, disconnecting, folder-listing, and file transferring. Your work is to implement EnterOBEX() and ExitOBEX() functions. For more details and as an example, please see my Siemens CX6C project.

Nokia FBUS file transferring

As I mentioned above, the FBUS protocol has no detailed documents on the Internet. I know of an open-source project called Gnokii which has done some work on this protocol, but it is still not detailed enough. What to do next? I can only monitor the file transfer process other software, analyse it, and then implement it.

To enter the Nokia FBUS protocol, you must first set your baudrate to 115200, and set DTR=off and RTS=off.

FBUS basics and examples

FBUS calls every data segment as a Frame. Here is the Frame format for FBUS version 2 (From the Gnokii document):

[FrameID, DestDev, SrcDev, MsgType, 0x00, FrameLength, 
      {block}, FrameToGo, SeqNo, PaddingByte?, ChkSum1, ChkSum2]
Name Description
FrameID 0x1c: IR/FBUS
0x1e: Serial/FBUS
DestDev, SrcDev 0x00: Mobile Phone
0x0c, 0x10: TE (PC)
MsgType See Gnokii for details
FrameLength length of [block] + 2
FrameToGo 0x0n means there are n-1 frames to go after this frame.
SeqNo [0xXY] X=4: first block X=0: continuing block Y: sequence number
PaddingByte 0x00 if FrameLength would be an odd number, anyway it doesn't exist
ChkSum1 XOR on Frame's odd numbers
ChkSum2 XOR on Frame's even numbers

Let's first look at two FBUS segments from a mobile to a PC:

Request from PC

You will notice that before sending the first Frame, plenty of 0x55s are sent. These 0x55s are known as a Sync Signal. Why send 0x55s instead of other hex values? You know that the binary for 0x55 is 1010101, and when on the serial line, it will be 01010101. These "0x55"s will be linked together as repeating "01"s, and when the phone receive enough "01"s to ensure that the line is OK, the phone will switch to the FBUS mode.

Let's look at:

Frame 1

This is a request Frame which requests for the phone version info:

Frame 2

This is an acknowledgement frame. Every frame TE send will return an acknowledgement frame with MsgID=0x7F. Its format is:

{FrameID, DestDev, SrcDev, 0x7F, 0x00, 0x02, 
        ID_Command, ID_SeqNo, ChkSum1, ChkSum2}
  • ID_Command: The commandID that you are acknowledging.
  • ID_SeqNo: The sequence number that you are acknowledging.

In our example, the ID_Command is 0xD1 which is the ID in our request 0xD1.

The ID_SeqNo is a number that equals to (SeqNo AND 0x0F). Here, (0x40 AND 0x0F) = 0x00.

Frame 3

This is the version info we get from the phone. Note here that the sequence is 0x44. This means the sequence number is 4 right now. Every time you send a new frame, the sequence number should be (seq+1) MOD 8. So the sequence number of Frame 5 should be 5.

Frame 4

Acknowledgement frame to the last frame. You must return an acknowledgement to the last frame as soon as you receive and check the frame. Normally, you must respond, approximately, within 300ms. If not, the phone will retry thrice to send the same frame. If no acknowledgement frame is received by the phone, the phone will disconnect the link.

FBUS file transfer

I think it's hard to give a full example to show this, but I'll show how to do it. Please look at my draft code for an example.

  • Step 1: Switch to FBUS mode. As you know, send '0x55' several times.
  • Step 2: Send, what I call, initialization frames to the phone. See my Sub Prepare() for details.
  • Step 3: Send the full file name including the path on the phone and prepare to send the data. See privateSendFile().
  • Step 4: Send the data. See privateSendFile().
  • Step 5: Send the complete message.

My code is a draft code, so it will be hard to read, and it will have bugs because I have no more detailed documents about FBUS. I learned these steps by monitoring other software. If you like, you can try and monitor the MobTime Cell Phone manager.

Samsung AT based file transferring

Some of the AT commands are listed below:

AT command Description
AT+FSCD="<DIR>" Change to <DIR>
AT+FSDI="<DIR>" Directory information
AT+FSDL="<DIR>" Directory list
AT+FSFW=-1, "<FILENAME>", 0, "", <LEN>, <CRC> Send a file.
AT+FSFE=0, "<FILENAME>" Delete a file.

Let's see an example:

Request

<em>Change the directory to "/å?¾ç?". Don't care the folder name here.
    If your phone is English, then it will be /Picture</em>
41 54 2B 46 53 43 44 3D 22 2F E5 9B BE E7 89 87 AT+FSCD="/å?¾ç??
22 0D                                           ".

Answer

<em>Folder Successfully changed.</em>
41 54 2B 46 53 43 44 3D 22 2F E5 9B BE E7 89 87 AT+FSCD="/å?¾ç??
22 0D 0D 0A 4F 4B 0D 0A                         "...OK..

Request

<em>Repeat. I don't know why.</em>
41 54 2B 46 53 43 44 3D 22 2F E5 9B BE E7 89 87 AT+FSCD="/å?¾ç??
22 0D                                           ".

Answer

<em>Repeat. I don't know why.</em>
41 54 2B 46 53 43 44 3D 22 2F E5 9B BE E7 89 87 AT+FSCD="/å?¾ç??
22 0D 0D 0A 4F 4B 0D 0A                         "...OK..

Request

<em>Write a file. 18752 is the length.
   880445898 is unsigned CRC32 code for the file.</em>
41 54 2B 46 53 46 57 3D 2D 31 2C 20 22 E6 B5 8B AT+FSFW=-1, "æµ?
E8 AF 95 2E 6A 70 67 22 2C 20 30 2C 20 22 22 2C è¯.jpg", 0, "",
31 38 37 35 32 2C 38 38 30 34 34 35 38 39 38 0D 18752,880445898.

Answer

<em>OK. You can continue. "##>" indicates continue your transfer.</em>
41 54 2B 46 53 46 57 3D 2D 31 2C 20 22 E6 B5 8B AT+FSFW=-1, "æµ?
E8 AF 95 2E 6A 70 67 22 2C 20 30 2C 20 22 22 2C è¯.jpg", 0, "",
31 38 37 35 32 2C 38 38 30 34 34 35 38 39 38 0D 18752,880445898.
23 23 3E 0D 0A                                  ##>.. 

Request

<em>Send data. Maximum data length is 512 bytes.</em>
FF D8 FF E0 00 10 4A 46 49 46 00 01 02 00 00 01 ÿØÿà..JFIF......
......
<Total 512 bytes data here>

Answer

<em>Please continue.</em>
0D 0A 23 23 3E 0D 0A                            ..##>..

Request

<em>...
<Continue data segment></em>

Answer

Request

<em>Send last segment of data. Phone will calculate
   total data you send. When phone received 
   18752 bytes, it will return OK</em>
   
91 56 53 E9 BF 5B 55 68 AF 8E 35 66 87 06 3D 35 VSé¿[Uh¯?5f.=5
<.......>
E3 C6 63 31 E3 C6 63 31 E3 C6 63 31 E3 C7 FF D9 ãÆc1ãÆc1ãÆc1ãÇÿÙ

Answer

<em>Phone has received all your data.</em>
0D 0A 4F 4B 0D 0A ..OK.. 

That's all the process is, easy and human-readable. Try to program it!

A Simple Guide To Mobile Phone File Transferring

A Simple Guide To Mobile Phone File Transferring Posted on 16-05-2014  With the extensive development of the mobile phone industry, our mobile phones are becoming more powerful than before. Today, mobile phones can process pictures, sound, and even video. We can get pictures from a phone's camera, or download them from a PC or from a web site. I have two phones, a Siemens CXV65 and a Nokia 6021. It is boring that I must install two separate software when I want to transfer a picture to them. And this really takes a lot of my disk space and slows down my machine. Though we can buy commercial software to do this, I was wondering if it was possible to develop a software by myself? That was a surprising idea, and I did finish it. Now I will tell you how I did it, in a top-down perspective. In this article, you will learn what is OBEX, FBUS, and a plug-in scheme. I hope the code or data examples and the comments in the source code will give you a clear picture. Hope you like this article! 1.8/10 2343

Comment:

To comment you must be logged in members.

Files with category

  • Creating a Virtual Windows Phone 8 Development Environment

    View: 1919    Download: 0   Comment: 0   Author: none  

    Creating a Virtual Windows Phone 8 Development Environment

    Category: Windows phone
    Fields: Other

    0/4 review
    Like me, many developers didn't want to switch Operating Systems to develop for Windows 8 and Windows Phone 8 (WP8). After following the instructions in this tip, if you are one of these developers, you will be able to start developing for WP8 while...

  • Windows Phone WebBrowser control: Manipulating Page DOM

    View: 2616    Download: 0   Comment: 0   Author: none  

    Windows Phone WebBrowser control: Manipulating Page DOM

    Category: Windows phone
    Fields: Other

    0.64285714285714/7 review
    If you've programmed for Desktop (Windows Forms), you should know that WebBrowser control has a property called Document (of type HtmlDocument). This property allows us to manipulate the DOM of the page. However, that property does not exist in...

  • A Simple Guide To Mobile Phone File Transferring

    View: 2343    Download: 0   Comment: 0   Author: none  

    A Simple Guide To Mobile Phone File Transferring

    Category: Windows phone
    Fields: Other

    0.9/5 review
    With the extensive development of the mobile phone industry, our mobile phones are becoming more powerful than before. Today, mobile phones can process pictures, sound, and even video. We can get pictures from a phone's camera, or download them...

  • How to Publish your Windows Phone 8 Application on the Store

    View: 1335    Download: 0   Comment: 0   Author: none  

    How to Publish your Windows Phone 8 Application on the Store

    Category: Windows phone
    Fields: Computers - Technology

    1.5/3 review
    Almost of my friends asked me how to publish my Windows Phone 8 application on the store and this process can take time because your application must meet all the store requirements. So, in this tip, we will see together how to publish a Windows...

  • Air hockey

    View: 785    Download: 0   Comment: 0   Author: none  

    Air hockey

    Category: Windows phone
    Fields: Computers - Technology

    0/6 review
    Introduction Have you ever played Air Hockey? Air Hockey is a fairly popular game in game centers and other places where people hang out. Not that many people had a chance to try it as a pre-installed game on operating systems. The purpose of the...

  • Pairs game

    View: 458    Download: 0   Comment: 0   Author: none  

    Pairs game

    Category: Windows phone
    Fields: Computers - Technology

    0/1 review
    Introduction Pairs, also known as Concentration, Memory cards, Pexeso etc. is a simple card game, where player must find two identical cards. This game is great for memory training and good to kill some time for kids and adults. Nevertheless, our...

  • Snake game for tablets and Smartphones

    View: 928    Download: 1   Comment: 0   Author: none  

    Snake game for tablets and Smartphones

    Category: Windows phone
    Fields: Computers - Technology

    0/9 review
    Introduction The Snake game is a well-known game for mobile devices. The first time Snake made its debut was in 1997 and people usually know the game from Nokia 6110. Since then, this game changed many times and now it is time to adjust it for...

  • Work-Around for DataContractJsonSerializer ArgumentNullExceptions

    View: 1197    Download: 0   Comment: 0   Author: none  

    Work-Around for DataContractJsonSerializer ArgumentNullExceptions

    Category: Windows phone
    Fields: Computers - Technology

    1/4 review
    If you've tried using a DataContractJsonSerializer or a DataContractSerializer with Push Notification for the Windows Phone, you may have experienced an ArgumentNullException during deserialization. This can happen because the MemoryStream is...

 
Newsletter Email

File suggestion for you

File top downloads

logo codetitle
Codetitle.com - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.com Develope by Vinagon .Ltd