Introduction To Bluetooth Messenger (BTM)
Introduction To Bluetooth Messenger (BTM)
Share
Bluetooth Messenger
More
Next Blog
Create Blog
Sign In
Bluetooth Messenger
Friday, September 24, 2010
3/26/2014
Bluetooth Messenger
This Bluetooth chat application enables two users with Bluetooth-enabled Pocket PCs/PCs/laptops/mobiles to communicate with each other so long as they are within the range of Bluetooth. This application has a scope in wireless technology; it is useful as a communication tool during meetings, where private conversations can take place without affecting the meeting or as a mobile substitute for instant messenger. The main objectives of our project are as under:
1.3 Achievements
The idea about developing such an application came to our minds from the rapidly increasing number of users who are using the technology of Bluetooth or who are going for wireless technologies. We had decided to develop such application which can work on Bluetooth network as well as over Wi-Fi network. But due to certain problems we have done the development only for Bluetooth network. This application enables two PCs or laptops to communicate with each other. This application searches the Bluetooth devices and the connection between two devices is established successfully. Two PCs or Laptops with the help of USB dongle and this application can successfully communicate with each other.
http://bluetoothmessenger.blogspot.in/ 2/6
3/26/2014
Bluetooth Messenger
The transfer of files was also one of the objectives defined by us in the start, and this objective is also successfully achieved.
3/26/2014
Bluetooth Messenger
is been clicked, then the following code will be executed SelectBluetoothDeviceDialog sbdd = new SelectBluetoothDeviceDialog(); sbdd.ShowAuthenticated = true; sbdd.ShowRemembered = true; sbdd.ShowUnknown = true; The above lines will discover and search for the available bluetooth devices on the bluetooth network to send files. The following code will open the file dialog box and after selecting file the selected file will be send to the client. if (sbdd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (ofdFileToBeam.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; Uri theuri = new Uri("obex://" + sbdd.SelectedDevice.DeviceAddress.ToString() + "/" + System.IO.Path.GetFileName(ofdFileToBeam.FileName)); ObexWebRequest request = new ObexWebRequest(theuri); request.ReadFile(ofdFileToBeam.FileName); ObexWebResponse response = (ObexWebResponse)request.GetResponse(); MessageBox.Show(response.StatusCode.ToString()); response.Close(); MessageBox.Show("File sent :" + DateTime.Now.ToString("dd/mm/yy/*/HH:mm") + " " + ofdFileToBeam.FileName); File.AppendAllText("C:\\History of file transfer.txt", "File sent to " + sbdd.SelectedDevice.DeviceName + ":" + DateTime.Now.ToString("dd/mm/yy/*/HH:mm") + " " + ofdFileToBeam.FileName + Environment.NewLine);
Cursor.Current = Cursors.Default; } } After sending the request to the client, the DealWithRequest( ) will be executed. Here the file will be received by the client. After receiving file, the message box will be shown, which will contains the notification about the file received. The below code is doing this job. public void DealWithRequest() { while (ol.IsListening) { try {
http://bluetoothmessenger.blogspot.in/ 4/6
3/26/2014
Bluetooth Messenger
ObexListenerContext olc = ol.GetContext(); ObexListenerRequest olr = olc.Request; string filename = Uri.UnescapeDataString(olr.RawUrl.TrimStart(new char[] { '/' })); olr.WriteFile(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "\\" + DateTime.Now.ToString("ddMMyyHHmm") + " " + filename); MessageBox.Show("File received :" + DateTime.Now.ToString("dd/mm/yy/*/HH:mm") + " " + filename); File.AppendAllText("C:\\History of file transfer.txt", "File received :" + DateTime.Now.ToString("dd/mm/yy/*/HH:mm") + " " + filename + Environment.NewLine); } catch (Exception ex) { break; } } } } The history of send and received files is also being saved in our application.This is done by the following code. For history of sent files. File.AppendAllText("C:\\History of file transfer.txt", "File sent to " + sbdd.SelectedDevice.DeviceName + ":" + DateTime.Now.ToString("dd/mm/yy/*/HH:mm") + " " + ofdFileToBeam.FileName + Environment.NewLine); For history of received files. File.AppendAllText("C:\\History of file transfer.txt", "File received :" + DateTime.Now.ToString("dd/mm/yy/*/HH:mm") + " " + filename + Environment.NewLine); An additional feature of saving the chat has also been added in our Bluetooth messenger.The following code will create the text file at the location selected by the user with the user defined name. string Saved_File = ""; saveFileDialog1.InitialDirectory = "C:"; saveFileDialog1.Title = "Save a Text File "; saveFileDialog1.FileName = ""; saveFileDialog1.Filter = "Text Files|*.txt|All Files|*.*"; if (saveFileDialog1.ShowDialog() != DialogResult.Cancel) { Saved_File = saveFileDialog1.FileName; richTextBox1.SaveFile(Saved_File, RichTextBoxStreamType.PlainText); } Other additional features like edit menu, which contains copy, paste, cut, undo, redo, select all have also
http://bluetoothmessenger.blogspot.in/ 5/6
3/26/2014
Bluetooth Messenger
been added in Bluetooth Messenger. There is another features, that is for making our chat more attractive and its about the formatting of font. User can choose and select the Color, Font size, Style of his own choice.
Posted by v4.csit at 1:02 AM No comments:
Home
Subscribe to: Posts (Atom)
Followers
Join this site
w ith Google Friend Connect
About Me
v4.csit View my complete profile
Blog Archive
2010 (1) September (1) Introduction to Bluetooth Messenger (BTM)
http://bluetoothmessenger.blogspot.in/
6/6