Bluetooth send / receive text without pairing using C # on 2 Windows 7 computers

I read that a connection must be required before transmitting anything via bluetooth, but I want to know

Can I create an application that will read text that is broadcast by another Bluetooth application without pairing.

Because we can see the names of other bluetooth devices around the device. Thus, we cannot set our Bluetooth radio to a state in which it will read any buradcasting bluetooth text message.

Example: in android there is createInsecureRfcommSocketToServiceRecord () and listenUsingInsecureRfcommWithServiceRecord (), but there are no such in C # for windows?

thanks


My ultimate goal :-)

creates an application running on a Windows 7 PC that creates an instant Bluetooth network for transferring peer-to-peer files and chat

Scenario

There is a group of people, each of whom has this application on each computer, and wants to share a file (maybe an e-book, PDF, or something else) with the rest. It sets its net network (or any other name) in its application configuration, while others also put the same name in each application. Finally, each user can see a list of other Bluetooth nodes around them on their application screen configured to the same network name "net". therefore, everyone can send files to selected nodes on the same network.

Design

  • Each user only turns on the Bluetooth radio and then enters the desired network name in the application
  • Each application on the PC will transmit to iteratively accessible Bluetooth devices through temporarily created connections ( without pairing or user participation ), check their network names and a list of detected computers with similar network names
  • Then they will share these lists with each other, so one computer knows computers on their same network, even if they are not in range.
  • Send files from one computer to one or more computers along the path allowed by the algorithm, even send chat texts.
  • All this will be achieved through simple temporary Bluetooth connections established between each application from time to time, which does not require pairing or authentication, except for the network name. (Because I do not know how to create Piconets using C #, or how to create Bluetooth routing protocols.
  • No other security is implemented.

Please let me know about another better design or method. Thanks so much for reading the long text. Also include any useful code that will help me achieve the above.

+6
source share
1 answer

I make dozens of unpaired connections every day ... I do not know where this rumor came from. :-)

As you point out, Android was by default for an authenticated connection - maybe from where the rumor started? Even there, as you have noticed, there are ways to request a connection "not required", for example. listenUsingInsecureRfcommWithServiceRecord.

So, in the Microsoft stack on Windows, one uses Bluetooth (RFCOMM) through a socket (winsock). By default, this connection does not require authentication (pairing) or encryption - in fact, for the auth / enc request, you need to set the socket parameters. Similarly with Widcomm, you indicate when you create a connection, what level of security you want, and which may be "No." Similarly on Bluetopia, similarly on BlueZ on Linux.

So, if you use my 32feet.NET library, just use BluetoothClient and BluetoothListener and don't set cli.Authenticate=true , etc . cli.Authenticate=true

Some code examples

What is your ultimate goal? I just realized that you were asking about file transfer in another question ... :-)

In any case, for text transmission ... On the server side there is a code, as shown on: http://32feet.codeplex.com/wikipage?title=Bluetooth%20Server-side and on the client, like: http: // 32feet. codeplex.com/wikipage?title=General%20Bluetooth%20Data%20Connections I don’t know if you know that TextWriter / -Reader sublclasses is on .NET, on the one hand, anyway:

 .... 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 is a code in the Bluetooth code that pretty much does something like that.

Alan

+6
source

Source: https://habr.com/ru/post/894765/


All Articles