473,890 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

a little help in bluetooth

excuse me, im a newbie programmer and i need a code on how to to be able to
send files from a mobile phone to a pc through bluetooth in vb.net

can anyone post a code here on how to detect a bluetooth device and how to
send files to the pc in vb.net?

i would really really appreciate your help!!

Dec 21 '07 #1
6 8517
JDS
On Dec 21, 3:25*pm, "jabslim" <u40064@uwewrot e:
excuse me, im a newbie programmer and i need a code on how to to be able to
send files from a mobile phone to a pc through bluetooth in vb.net

can anyone post a code here on how to detect a bluetooth device and how to
send files to the pc in vb.net?

i would really really appreciate your help!!
One way to do it is to assign a com port to the PC Bluetooth
connection and then use System.IO.Seria lPort. You will then also need
a program on the PC to receive the file.

HTH
Dec 22 '07 #2
>One way to do it is to assign a com port to the PC Bluetooth
>connection and then use System.IO.Seria lPort. You will then also need
a program on the PC to receive the file.

HTH


thanks for the info!! if it's convenient for you, can you please post a
sample on how to really use the codes for it? because i haven't the slightest
idea on how to really control the dongle(bluetoot h) using codes in vb.net. i
have searched and read other forums about bluetooth, but i just cant
understand how it is being controlled to receive files.

what kind of program for the pc do you recommend for the dongle?

--
Message posted via http://www.dotnetmonster.com

Dec 22 '07 #3
JDS
On 22 Dec, 16:13, "jabslim via DotNetMonster.c om" <u40064@uwewrot e:
One way to do it is to assign a com port to the PC Bluetooth
connection and then use System.IO.Seria lPort. You will then also need
a program on the PC to receive the file.
HTH

thanks for the info!! if it's convenient for you, can you please post a
sample on how to really use the codes for it? because i haven't the slightest
idea on how to really control the dongle(bluetoot h) using codes in vb.net. i
have searched and read other forums about bluetooth, but i just cant
understand how it is being controlled to receive files.

what kind of program for the pc do you recommend for the dongle?

--
Message posted viahttp://www.dotnetmonst er.com
Try the following. It is only a test piece of code and does not have
any file IO but you should be able to adapt it easily. It has a simple
form with a combo box to display the available com ports (you will
have to assign a com port to the Bluetooth connection manually
beforehand) and a text box that displays received data (well the first
6 characters of each received line in this case).

For testing you could use Hyperterminal on the PC and the functions on
the Transfer menu ("Capture text..." and "Send text file..."). Again
you will have to assign a com port to the Bluetooth connection
manually beforehand.

Imports System.IO.Ports

Public Class frmMain
#Region "Variables"
Dim WithEvents mserialPort As New SerialPort
Dim mstrRxData As String
#End Region

#Region "Form"
Private Sub frmMain_Load(By Val sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Try
Dim strPorts() As String
strPorts = SerialPort.GetP ortNames
For Each port As String In strPorts
Me.cbComPort.It ems.Add(port)
Next
If Me.cbComPort.It ems.Count = 0 Then
MsgBox("No com ports found")
Else
Me.cbComPort.Se lectedIndex = 0
End If
Catch ex As Exception
MsgBox("Form load error: " & ex.Message)
End Try
End Sub
#End Region

#Region "Data"
Private Sub DataReceived(By Val sender As Object, ByVal e As
System.IO.Ports .SerialDataRece ivedEventArgs) Handles
mserialPort.Dat aReceived
Try
Me.tbRxData.Inv oke(New myDelegate(Addr essOf ProcessData),
New Object() {})
Catch ex As Exception
MsgBox("DataRec eived() error: " & ex.Message)
End Try
End Sub

Public Delegate Sub myDelegate()
Public Sub ProcessData()
Try
Dim rxData As String = ""
Static strBuffer As String

rxData = mserialPort.Rea dExisting
strBuffer &= rxData
If strBuffer.EndsW ith(vbCrLf) Then
Me.tbRxData.Tex t = Mid(strBuffer, 1, 6)
strBuffer = ""
End If
Catch ex As Exception
MsgBox("Process Data() error: " & ex.Message)
End Try
End Sub
#End Region

#Region "Menus"
Private Sub mnuConnect_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles mnuConnect.Clic k
Try
With mserialPort
If Not .IsOpen Then
.PortName = Me.cbComPort.Te xt
.Open()
Me.tbRxData.Tex t = "Connected"
Me.mnuConnect.T ext = "Disconnect "
Me.mnuExit.Enab led = False
Else
.Close()
Me.tbRxData.Tex t = "Disconnect ed"
Me.mnuConnect.T ext = "Connect"
Me.mnuExit.Enab led = True
End If
End With
Catch ex As InvalidOperatio nException
MsgBox("mnuConn ect error: port already open")
Catch ex As ArgumentOutOfRa ngeException
MsgBox("mnuConn ect error: invalid port setting")
Catch ex As ArgumentExcepti on
MsgBox("mnuConn ect error: invalid port name or file type")
Catch ex As IO.IOException
MsgBox("mnuConn ect error: invalid port state or port
setting")
Catch ex As UnauthorizedAcc essException
MsgBox("mnuConn ect error: access denied to specified
port")
Catch ex As Exception
MsgBox("mnuConn ect error: " & ex.Message)
End Try
End Sub

Private Sub mnuExit_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles mnuExit.Click
Application.Exi t()
End Sub
#End Region
End Class

Dec 23 '07 #4
thanks a lot pal!! ill try to understand and learn how the code works!!

if i have further questions, ill just post it here again!!

once again, i really thank you!! you're really helpful!!

--
Message posted via DotNetMonster.c om
http://www.dotnetmonster.com/Uwe/For...b-net/200712/1

Dec 23 '07 #5
On Dec 23, 2:44 pm, JDS <ad...@jeremysa ge.comwrote:
On 22 Dec, 16:13, "jabslim via DotNetMonster.c om" <u40064@uwewrot e:
>One way to do it is to assign a com port to the PC Bluetooth
>connection and then use System.IO.Seria lPort. You will then also need
>a program on the PC to receive the file.
>HTH
thanks for the info!! if it's convenient for you, can you please post a
sample on how to really use the codes for it? because i haven't the slightest
idea on how to really control the dongle(bluetoot h) using codes in vb.net. i
have searched and read other forums about bluetooth, but i just cant
understand how it is being controlled to receive files.
what kind of program for the pc do you recommend for the dongle?
--
Message posted viahttp://www.dotnetmonst er.com

Try the following. It is only a test piece of code and does not have
any file IO but you should be able to adapt it easily. It has a simple
form with a combo box to display the available com ports (you will
have to assign a com port to the Bluetooth connection manually
beforehand) and a text box that displays received data (well the first
6 characters of each received line in this case).

For testing you could use Hyperterminal on the PC and the functions on
the Transfer menu ("Capture text..." and "Send text file..."). Again
you will have to assign a com port to the Bluetooth connection
manually beforehand.

Imports System.IO.Ports

Public Class frmMain
#Region "Variables"
Dim WithEvents mserialPort As New SerialPort
Dim mstrRxData As String
#End Region

#Region "Form"
Private Sub frmMain_Load(By Val sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Try
Dim strPorts() As String
strPorts = SerialPort.GetP ortNames
For Each port As String In strPorts
Me.cbComPort.It ems.Add(port)
Next
If Me.cbComPort.It ems.Count = 0 Then
MsgBox("No com ports found")
Else
Me.cbComPort.Se lectedIndex = 0
End If
Catch ex As Exception
MsgBox("Form load error: " & ex.Message)
End Try
End Sub
#End Region

#Region "Data"
Private Sub DataReceived(By Val sender As Object, ByVal e As
System.IO.Ports .SerialDataRece ivedEventArgs) Handles
mserialPort.Dat aReceived
Try
Me.tbRxData.Inv oke(New myDelegate(Addr essOf ProcessData),
New Object() {})
Catch ex As Exception
MsgBox("DataRec eived() error: " & ex.Message)
End Try
End Sub

Public Delegate Sub myDelegate()
Public Sub ProcessData()
Try
Dim rxData As String = ""
Static strBuffer As String

rxData = mserialPort.Rea dExisting
strBuffer &= rxData
If strBuffer.EndsW ith(vbCrLf) Then
Me.tbRxData.Tex t = Mid(strBuffer, 1, 6)
strBuffer = ""
End If
Catch ex As Exception
MsgBox("Process Data() error: " & ex.Message)
End Try
End Sub
#End Region

#Region "Menus"
Private Sub mnuConnect_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles mnuConnect.Clic k
Try
With mserialPort
If Not .IsOpen Then
.PortName = Me.cbComPort.Te xt
.Open()
Me.tbRxData.Tex t = "Connected"
Me.mnuConnect.T ext = "Disconnect "
Me.mnuExit.Enab led = False
Else
.Close()
Me.tbRxData.Tex t = "Disconnect ed"
Me.mnuConnect.T ext = "Connect"
Me.mnuExit.Enab led = True
End If
End With
Catch ex As InvalidOperatio nException
MsgBox("mnuConn ect error: port already open")
Catch ex As ArgumentOutOfRa ngeException
MsgBox("mnuConn ect error: invalid port setting")
Catch ex As ArgumentExcepti on
MsgBox("mnuConn ect error: invalid port name or file type")
Catch ex As IO.IOException
MsgBox("mnuConn ect error: invalid port state or port
setting")
Catch ex As UnauthorizedAcc essException
MsgBox("mnuConn ect error: access denied to specified
port")
Catch ex As Exception
MsgBox("mnuConn ect error: " & ex.Message)
End Try
End Sub

Private Sub mnuExit_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles mnuExit.Click
Application.Exi t()
End Sub
#End Region
End Class
Does it work for USB Bluetooth dongles?
Dec 24 '07 #6
JDS
On 24 Dec, 22:16, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
On Dec 23, 2:44 pm, JDS <ad...@jeremysa ge.comwrote:


On 22 Dec, 16:13, "jabslim via DotNetMonster.c om" <u40064@uwewrot e:
One way to do it is to assign a com port to the PC Bluetooth
connection and then use System.IO.Seria lPort. You will then also need
a program on the PC to receive the file.
HTH
thanks for the info!! if it's convenient for you, can you please post a
sample on how to really use the codes for it? because i haven't the slightest
idea on how to really control the dongle(bluetoot h) using codes in vb.net. i
have searched and read other forums about bluetooth, but i just cant
understand how it is being controlled to receive files.
what kind of program for the pc do you recommend for the dongle?
--
Message posted viahttp://www.dotnetmonst er.com
Try the following. It is only a test piece of code and does not have
any file IO but you should be able to adapt it easily. It has a simple
form with a combo box to display the available com ports (you will
have to assign a com port to the Bluetooth connection manually
beforehand) and a text box that displays received data (well the first
6 characters of each received line in this case).
For testing you could use Hyperterminal on the PC and the functions on
the Transfer menu ("Capture text..." and "Send text file..."). Again
you will have to assign a com port to the Bluetooth connection
manually beforehand.
Imports System.IO.Ports
Public Class frmMain
#Region "Variables"
* * Dim WithEvents mserialPort As New SerialPort
* * Dim mstrRxData As String
#End Region
#Region "Form"
* * Private Sub frmMain_Load(By Val sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
* * * * Try
* * * * * * Dim strPorts() As String
* * * * * * strPorts = SerialPort.GetP ortNames
* * * * * * For Each port As String In strPorts
* * * * * * * * Me.cbComPort.It ems.Add(port)
* * * * * * Next
* * * * * * If Me.cbComPort.It ems.Count = 0 Then
* * * * * * * * MsgBox("No com ports found")
* * * * * * Else
* * * * * * * * Me.cbComPort.Se lectedIndex = 0
* * * * * * End If
* * * * Catch ex As Exception
* * * * * * MsgBox("Form load error: " & ex.Message)
* * * * End Try
* * End Sub
#End Region
#Region "Data"
* * Private Sub DataReceived(By Val sender As Object, ByVal e As
System.IO.Ports .SerialDataRece ivedEventArgs) Handles
mserialPort.Dat aReceived
* * * * Try
* * * * * * Me.tbRxData.Inv oke(New myDelegate(Addr essOf ProcessData),
New Object() {})
* * * * Catch ex As Exception
* * * * * * MsgBox("DataRec eived() error: " & ex.Message)
* * * * End Try
* * End Sub
* * Public Delegate Sub myDelegate()
* * Public Sub ProcessData()
* * * * Try
* * * * * * Dim rxData As String = ""
* * * * * * Static strBuffer As String
* * * * * * rxData = mserialPort.Rea dExisting
* * * * * * strBuffer &= rxData
* * * * * * If strBuffer.EndsW ith(vbCrLf) Then
* * * * * * * * Me.tbRxData.Tex t = Mid(strBuffer, 1, 6)
* * * * * * * * strBuffer = ""
* * * * * * End If
* * * * Catch ex As Exception
* * * * * * MsgBox("Process Data() error: " & ex.Message)
* * * * End Try
* * End Sub
#End Region
#Region "Menus"
* * Private Sub mnuConnect_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles mnuConnect.Clic k
* * * * Try
* * * * * * With mserialPort
* * * * * * * * If Not .IsOpen Then
* * * * * * * * * * .PortName = Me.cbComPort.Te xt
* * * * * * * * * * .Open()
* * * * * * * * * * Me.tbRxData.Tex t = "Connected"
* * * * * * * * * * Me.mnuConnect.T ext = "Disconnect "
* * * * * * * * * * Me.mnuExit.Enab led = False
* * * * * * * * Else
* * * * * * * * * * .Close()
* * * * * * * * * * Me.tbRxData.Tex t = "Disconnect ed"
* * * * * * * * * * Me.mnuConnect.T ext = "Connect"
* * * * * * * * * * Me.mnuExit.Enab led = True
* * * * * * * * End If
* * * * * * End With
* * * * Catch ex As InvalidOperatio nException
* * * * * * MsgBox("mnuConn ect error: port already open")
* * * * Catch ex As ArgumentOutOfRa ngeException
* * * * * * MsgBox("mnuConn ect error: invalid port setting")
* * * * Catch ex As ArgumentExcepti on
* * * * * * MsgBox("mnuConn ect error: invalid port name or file type")
* * * * Catch ex As IO.IOException
* * * * * * MsgBox("mnuConn ect error: invalid port state or port
setting")
* * * * Catch ex As UnauthorizedAcc essException
* * * * * * MsgBox("mnuConn ect error: access denied to specified
port")
* * * * Catch ex As Exception
* * * * * * MsgBox("mnuConn ect error: " & ex.Message)
* * * * End Try
* * End Sub
* * Private Sub mnuExit_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles mnuExit.Click
* * * * Application.Exi t()
* * End Sub
#End Region
End Class

Does it work for USB Bluetooth dongles?- Hide quoted text -

- Show quoted text -
I have used it with a USB Bluetooth dongle on the PC communicating
with a Windows Mobile device. It is not that sophisticated as it
requires the user to assign a com port to the Bluetooth interface on
both the PC and the mobile device - but it works! I am sure there will
be ways of creating a more user-friendly interface by handling the
Bluetooth directly but it is bound to require more programming.

One note on assigning ports. The terminology uses "outgoing" and
"incoming" which is a little confusing as it does not relate to the
direction of the data. It refers to which device initiates the
connection; i.e. if the PC is listening for the connection and the
mobile device initiates, then the PC port will be "incoming" and the
mobile device "outgoing" even if all the data is transmitted only from
the PC to the mobile device.

HTH
Dec 26 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2291
by: Thomas_Germany | last post by:
I would like to develop a smart device bluetooth application for pocket PC 2003. As I know, Pocket PC 2003 includes the microsoft bluetooth stack. My intention is to use the SDK from mircrosoft and not the expensive SDK from WIDCOMM to use the bluetooth programming interfaces. But, as I know most pocket PCs with integrated bluetooth chips use the WIDCOMM bluetooth stack. So my questions are as follows: 1) Is it possible to...
2
3003
by: Federico Caselli | last post by:
Is it possible write a program to communicate with an external device via bluetooth using visual basic .net (of course for windows xp sp1 or later)? I tryed to read MSDN library about System.Net.Sockets.Socket, but I'm not expert enough to see if it supports bluetooth connections. Can you please tell me if it does? If not, could you please show me how to wrap bluetooth functions in winsock api using VB.net? Thank you.
3
8048
by: Tor Erik Sønvisen | last post by:
Hi I'm making a server-side solution in Python and need to be able to communicate through bluetooth. Is there any bluetooth-packages out there for python? regards tores
1
5795
by: cmartin64x | last post by:
Hi, I am trying to make this simple code work but I have no success doing so: BLUETOOTH_DEVICE_SEARCH_PARAMS btsp = { sizeof(btsp) }; BLUETOOTH_DEVICE_INFO btdi = { sizeof(btdi) }; btsp.fReturnAuthenticated = TRUE; btsp.fReturnRemembered = TRUE;
1
4009
by: =?Utf-8?B?dGhlZ3JlZW5vbmU=?= | last post by:
How can i fix my issue of only being able to connect one device to a bluetooth connection. Situation: - I connect one device to a bluetooth device and finish using it. turn the device off and want to use a diffrent device with the same bluetooth device. currently i am not able to where should i look / do? -- i have little experience be kind
2
5436
by: colin | last post by:
Hi, Im having a tiresome amount of trouble with using a bluetooth serial link. The receiving end is a bluetooth-rs232 module conected to my embeded system. The PC has a little usb bluetooth dongle, ive tried a another dongle with widicom software as I was having problems with the IVT bluesoleil software. that seems to have got rid of some other problems,
7
3787
by: haytham D | last post by:
hey every one , i am lokking for a c#.net library to send and recive files via bluetooth , it does not has to be file transferring . its for my graduate project , workin in integrating my unifersity's database with the students phones .... so hope 2 get some help , thank you all. *** Sent via Developersdex http://www.developersdex.com ***
1
2446
by: gringgos | last post by:
hi, friends... Currently i am doing a project based on bluetooth and Visual Basic 6.0. But i am unable to find any solution regarding bluetooth. But my supervisor gave her idea about do a code where it runs the bluetooth application as a hidden program to send the audio file. It is where when i click the button send, it will operate the file transfer wizard in the bluetooth application and when i click the bluetooth button it should operate...
1
6096
by: Z.K. | last post by:
I know this is probably not the correct newsgroup, but I can't find anywhere else that is appropriate to post it in. I need to figure out how to write a bluetooth program to access a bluetooth barcode scanner. After a lot of searching the Internet, I have come to the conclusion that something using RFCOMM would be best. Unfortunately, Bluetooth programming books are not exactly plentiful and finding a book on RFCOMM is almost...
0
9975
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9812
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10799
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7154
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6032
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4655
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4255
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.