7

I have read that pairing is a must before communicating anything over bluetooth, but I want to know,

Can I create an application which would read a text which is broadcasted by another bluetooth App without being paired.

Because we can see the names of other bluetooth devices around a device. So can't we set our bluetooth radio to a state that it would read any bluetooth boradcasting text message.

Example: there is createInsecureRfcommSocketToServiceRecord() & listenUsingInsecureRfcommWithServiceRecord() in android but aren't there such in C# for windows?

Thanks


My Ultimate Goal :-)

is creating an application running on windows 7 PCs, which create instant Bluetooth network for peer to peer file transfer and chat

Scenario

There is a group of people, each has this app on each computer, one wants to share a file, (may be an eBook, PDF or anything) with the rest. He sets his network "net" ( or any other name) in his app configuration and others also put that same name on each app. Finally each user can see the list of other Bluetooth nodes around them in their apps display, configured to same network name "net". so each can send files to selected nodes in the same network.

Design

  • Each user only turns on the Bluetooth radio and then enters a desired Network name in then app
  • Each application on PCs will communicate iteratively to reachable Bluetooth devices, through temporarily created connections (without pairing or user involvement), check their network names and list discoverable PCs with similar network names
  • Then they will share these lists among each other, so one PC knows the computers in their same network even though they are not in range directly.
  • Send files from one computer to one or many computers through a path resolved by an algorithm, even send chat texts.
  • All of this is going to be achieved through simple temporarily Bluetooth connections established between each application time to time, which requires no pairing or authentication, other than the Network Name. ( Because I don't know how to create Piconets using C#, or how to create bluetooth routing protocols.
  • No other security is implemented.

Please let me know of any other better design or way. Thank you very much for reading the lengthy text. Also include any helpful code which can help me achieve the above.

Zerone
  • 566
  • 4
  • 10
  • 24

1 Answers1

7

I make tens of un-paired connections every day... I don't know where this rumour comes from. :-,)

As you note on Android the default was for an authenticated connection -- maybe that's where the rumour started from? Even there, as you note, there are ways to request a 'pairing-not-required' connection e.g. listenUsingInsecureRfcommWithServiceRecord.

So, on the Microsoft stack on Windows one uses Bluetooth (RFCOMM) through a socket (winsock). By default that connection does not require authentication (pairing), nor encryption -- in fact to request auth/enc one must set a socket options. Similarly with Widcomm, you specify when you create the connection what security level you want, and that can be 'None'. Similarly on Bluetopia, similarly on BlueZ on Linux.

So if you use my library 32feet.NET, just use BluetoothClient and BluetoothListener and do not set cli.Authenticate=true etc. :-)

Some code examples

What's your ultimate goal? I've just realised that you were asking about file-transfer in another question... :-)

Anyway for transferring text... On the server-side have code like shown at: http://32feet.codeplex.com/wikipage?title=Bluetooth%20Server-side and on the client like: http://32feet.codeplex.com/wikipage?title=General%20Bluetooth%20Data%20Connections Don't know if you know TextWriter/-Reader sublclasses on .NET, anyway on one side:

....
var wtr = new StreamWriter(peerStream);
wtr.WriteLine("hello");
wtr.Flush();

and on the other:

....
var wtr = new StreamReader(peerStream);
var line = wtr.ReadLine();
MessageBox.Show(line);

There's code in the BluetoothChat which pretty much does something like that.

Alan

alanjmcf
  • 3,430
  • 1
  • 17
  • 14
  • Thank you this is exactly what I wanted to know, you have explained it very clearly. I'm trying this right away. Thank you – Zerone Aug 12 '11 at 01:30
  • I'm little confused creating this because I'm new to bluetooth programming, can you share a simple code if it's possible (ideally in C#) which does the above (sending a text etc.). Thank you. – Zerone Aug 12 '11 at 01:34
  • Thank you very much for the Code Samples Allan I'm testing them. Also I edited my question which describes my ultimate goal. I'm very much new to this entire area of network and bluetooth programming, so please don't mind the confusing question I have made here and there, since I don't know what to look for right now coz I lack some technical expertise in this field to create a proper design first. Thank you again. – Zerone Aug 13 '11 at 10:19