Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
navisluni
Old
#1  
Member - OP
Thanks Meter 37
Posts: 50
Join Date: Mar 2006
Location: Torino
Default [XAP] Bluetooth Chat (Based on DllImport)

Hi all,
I've spent some time to investigate about Bluetooth status on Windows Phone 7 using DllImport approach for some applications I'm developing.

This is a simple chat app between a WP7 device and a counterpart (i.e a PC, another WP7 device, ...) using bluetooth serial communication.
I tried this app by connect my WP7 device to a PC and to another WP7 device.

It permits to exchange text messages between each side, like a classic chat program.
Tested WP7 devices (LG Optimus 7, Nokia Lumia 800 and HTC Mondrian) are all dev-unloked.

Application main page have the following possible actions:
- Connect to a remote device (if selected it will open a new page where to choose previously paired device or to find new one)
- Act as server (if selected it creates a new serial connection using device port 10 and it will listen for new incoming connection from remote device)
- Disconnect (to stop a connection towards remote device, or to stop server mode)
- Send (it will be enable only when connected as client or server. If selected will send your message to counterpart).
- Settings (if selected it will open a new page where to set application option)

Note: at the moment there is no automatic notification about connection down event.

Thanks to Heathcliff74 and fiinix for their works on WP7

Note: This is a simple project to verify if all core procedures (connection open and close, send and receive messages, ...) are working in the right way.

Ciao

P.S 1: if you eant to test the app between WP7 device and a PC use this procedure:
- Start Bluetooth on WP7 device
- From PC search for WP7 device and pair it
- Start BlueChat on WP7 device in server mode
- From PC search for Device exported services: you'd see a SPP (AUX3) option, if yes select it and then PC will create a new local COM Port
- Open a Putty using this COM Port and start to write to WP7 device!

P.S. 2: if you eant to communicate between 2 WP7 devices:
- On device 1 go to bluetooth settings page and activate it (this is important because only when we are in this page the device is discoverable from outside)
- On device 2 open BlueChat and choose "Connect" button. In the "Connect To" page choose "Search" option and in some seconds you'd see device 1
- Select device 1 form the list. Before select "Done" button, on device 2 open BlueChat and starts it in Server mode
- Then on device 1 select "Done" button and the devices will be connected
- Now you can exchange data between the two devices
Attached Thumbnails
Click image for larger version

Name:	BlueChat_7-30-2012_15.8.53.304.jpg
Views:	458
Size:	17.7 KB
ID:	1231084   Click image for larger version

Name:	BlueChat_7-30-2012_15.17.58.676.jpg
Views:	554
Size:	22.3 KB
ID:	1231085   Click image for larger version

Name:	BlueChat_7-30-2012_15.12.56.364.jpg
Views:	407
Size:	19.7 KB
ID:	1231086   Click image for larger version

Name:	BlueChat_7-30-2012_16.7.42.332.jpg
Views:	207
Size:	17.8 KB
ID:	1231099  
Attached Files
File Type: xap BlueChat_1000.xap - [Click for QR Code] (372.0 KB, 551 views)
The Following 4 Users Say Thank You to navisluni For This Useful Post: [ Click to Expand ]
 
坏天使
Old
#2  
Member
Thanks Meter 3
Posts: 39
Join Date: Aug 2011
Location: 成都市
nice work!
Pain makes you stronger, tear makes you braver, heartbreak makes you wiser, so thank the past for a better future.—坏天使
 
GoodDayToDie
Old
#3  
Recognized Developer
Thanks Meter 1372
Posts: 3,582
Join Date: Jan 2011
Location: Seattle
Very cool! Would you mind sharing the source code? I assume it's done using the standard WinCE Bluetooth APIs, but I'd like to see how you made it work exactly as that may enable writing a BT File Transfer app that doesn't rely on full-unlock the way the current one does.
Win8/Windows RT Projects:
EnableFlash script
List of desktop apps for hacked RT devices

WP7 projects:
XapHandler, Root Webserver, OEM Marketplace XAPs, Bookmarklets collection (Find On Page), Interop-unlock hacks.
 
navisluni
Old
#4  
Member - OP
Thanks Meter 37
Posts: 50
Join Date: Mar 2006
Location: Torino
Quote:
Originally Posted by GoodDayToDie View Post
Very cool! Would you mind sharing the source code? I assume it's done using the standard WinCE Bluetooth APIs, but I'd like to see how you made it work exactly as that may enable writing a BT File Transfer app that doesn't rely on full-unlock the way the current one does.
Project source code will be shared when it will be completed and fully functional (Actually it is finished at 60-70%)
I'm using a mix between Windows Mobile/Windows CE/Windows Embedded APIs.

This is only a test project to verify base bluetooth routines on multiple WP7 devices.
Main goal is transmit and receive file using OPP (Obex Object Push Profile) without the constraints of a Fully unlock device.

In this development phase, WP7 device can receive file through OPP but there are some problems on file trasmission.
In addition WP7 devices don't pair another phone device (for example pair a WP7 with an Android), and this requires efforts on pairing phase also.
The Following User Says Thank You to navisluni For This Useful Post: [ Click to Expand ]
 
davide136
Old
#5  
davide136's Avatar
Member
Thanks Meter 5
Posts: 90
Join Date: Dec 2011
Location: padua

 
DONATE TO ME
I would like to suggest you something to send files...i'm bit a developer, i don't know even if it's possible...just tell me where i am failing with my theory

If, within your app, you decode a file in hexadecimal code to text, like this,

00 00 00 00 00 00 00
To
00000000000000 and injecting a string that sets nme and extension like
*namefile**.rar*00000000000000

And then you send this to an other WP with your app as a text that will decode the text to a file...
Is this possible? It only have the bug that doesn't work with other devices right but is possible?

Sent from my LG-E900 using Board Express
 
navisluni
Old
#6  
Member - OP
Thanks Meter 37
Posts: 50
Join Date: Mar 2006
Location: Torino
Quote:
Originally Posted by davide136 View Post
I would like to suggest you something to send files...i'm bit a developer, i don't know even if it's possible...just tell me where i am failing with my theory

If, within your app, you decode a file in hexadecimal code to text, like this,

00 00 00 00 00 00 00
To
00000000000000 and injecting a string that sets nme and extension like
*namefile**.rar*00000000000000

And then you send this to an other WP with your app as a text that will decode the text to a file...
Is this possible? It only have the bug that doesn't work with other devices right but is possible?

Sent from my LG-E900 using Board Express
Ciao Davide,
the problem is in connection establishment between WP7 devices.

When they are connected, files will be exchanged using OPP rules so no problem on it.
As said in previous post, I can send to my WP7 device an image and save it into Media Hub (or where I want)

Unfortunately connection management on WP7 is not so comfortable and require some time to be deeply understood...
 
davide136
Old
#7  
davide136's Avatar
Member
Thanks Meter 5
Posts: 90
Join Date: Dec 2011
Location: padua

 
DONATE TO ME
Yes i had misunderstood thanks to have cleared it:P

Sent from my LG-E900 using Board Express
 
281463288
Old
(Last edited by 281463288; 6th August 2012 at 11:09 AM.)
#8  
Junior Member
Thanks Meter 0
Posts: 9
Join Date: Dec 2008
Quote:
Originally Posted by navisluni View Post
Hi all,
I've spent some time to investigate about Bluetooth status on Windows Phone 7 using DllImport approach for some applications I'm developing.

This is a simple chat app between a WP7 device and a counterpart (i.e a PC, another WP7 device, ...) using bluetooth serial communication.
I tried this app by connect my WP7 device to a PC and to another WP7 device.

It permits to exchange text messages between each side, like a classic chat program.
Tested WP7 devices (LG Optimus 7, Nokia Lumia 800 and HTC Mondrian) are all dev-unloked.

Application main page have the following possible actions:
- Connect to a remote device (if selected it will open a new page where to choose previously paired device or to find new one)
- Act as server (if selected it creates a new serial connection using device port 10 and it will listen for new incoming connection from remote device)
- Disconnect (to stop a connection towards remote device, or to stop server mode)
- Send (it will be enable only when connected as client or server. If selected will send your message to counterpart).
- Settings (if selected it will open a new page where to set application option)

Note: at the moment there is no automatic notification about connection down event.

Thanks to Heathcliff74 and fiinix for their works on WP7

Note: This is a simple project to verify if all core procedures (connection open and close, send and receive messages, ...) are working in the right way.

Ciao

P.S 1: if you eant to test the app between WP7 device and a PC use this procedure:
- Start Bluetooth on WP7 device
- From PC search for WP7 device and pair it
- Start BlueChat on WP7 device in server mode
- From PC search for Device exported services: you'd see a SPP (AUX3) option, if yes select it and then PC will create a new local COM Port
- Open a Putty using this COM Port and start to write to WP7 device!

P.S. 2: if you eant to communicate between 2 WP7 devices:
- On device 1 go to bluetooth settings page and activate it (this is important because only when we are in this page the device is discoverable from outside)
- On device 2 open BlueChat and choose "Connect" button. In the "Connect To" page choose "Search" option and in some seconds you'd see device 1
- Select device 1 form the list. Before select "Done" button, on device 2 open BlueChat and starts it in Server mode
- Then on device 1 select "Done" button and the devices will be connected
- Now you can exchange data between the two devices
THX,but it can not support chinese chat ~
 
navisluni
Old
#9  
Member - OP
Thanks Meter 37
Posts: 50
Join Date: Mar 2006
Location: Torino
Quote:
Originally Posted by 281463288 View Post
THX,but it can not support chinese chat ~
Can you explain which problem have you got?
Some issues with chinese chars?
 
281463288
Old
#10  
Junior Member
Thanks Meter 0
Posts: 9
Join Date: Dec 2008
Quote:
Originally Posted by navisluni View Post
Can you explain which problem have you got?
Some issues with chinese chars?
Sorry for late~

Like this

Click image for larger version

Name:	Send.jpg
Views:	58
Size:	53.8 KB
ID:	1246431

Click image for larger version

Name:	Receive.jpg
Views:	40
Size:	61.1 KB
ID:	1246432

 
Post Reply+
Tags
bluetooth, xap
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...

XDA PORTAL POSTS

Guide to Using Adobe Air on Android

When writing an app with performance in mind, you most likely want to write it native code using the … more

Boot Animation Paradise for your Android Device

The default boot animations on any device, no matter whichmanufacturer, are generally pretty … more