visual estudio y blueetooh.pdf

Upload: javier-sanabria-a

Post on 02-Jun-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Visual Estudio y Blueetooh.pdf

    1/2

    PublicClassForm1DimbtClient AsNewInTheHand.Net.Sockets.BluetoothClientDimSearchThread AsSystem.Threading.ThreadDimresponse AsInTheHand.Net.ObexWebResponsePrivateSubButton1_Click(ByValsender AsSystem.Object, ByVale As

    System.EventArgs) HandlesButton1.ClickTry

    Dimx AsString= "obex://"& CType(cboDevices.SelectedItem,InTheHand.Net.Sockets.BluetoothDeviceInfo).DeviceAddress.ToString & "/"+System.IO.Path.GetFileName(LBLFileName.Text)

    Dimtheuri AsNewUri("obex://"& CType(cboDevices.SelectedItem,InTheHand.Net.Sockets.BluetoothDeviceInfo).DeviceAddress.ToString & "/"+System.IO.Path.GetFileName(LBLFileName.Text))

    Dimrequest AsNewInTheHand.Net.ObexWebRequest(theuri)request.ReadFile(Application.StartupPath & "\FilesToSend\"&

    LBLFileName.Text)Dims AsDateTimes = Nowresponse = CType(request.GetResponse(), InTheHand.Net.ObexWebResponse)' & " " & response.StatusCode.ToString' Label4.Text = DateDiff(DateInterval.Second, s, Now) & " Sec"' Label7.Text = CType(cboDevices.SelectedItem,

    InTheHand.Net.Sockets.BluetoothDeviceInfo).DeviceName.ToString

    Ifresponse.StatusCode.ToString.Trim = "BadRequest"ThenLabel1.Text = "Not success"

    ElseIfresponse.StatusCode.ToString.Trim = "OK, Final"ThenLabel1.Text = "Success"

    ElseLabel1.Text = "Error: : "& vbCrLf & _response.StatusCode.ToString.Trim

    EndIfresponse.Close()

    Catchex AsExceptionMsgBox(Err.Description)

    EndTry

    EndSub

    PrivateSubButton2_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs) HandlesButton2.ClickIfCheckHardwareStatus() = FalseThen

    MsgBox("Please check BT..", MsgBoxStyle.Information +MsgBoxStyle.MsgBoxRtlReading)

    ExitSubEndIf'SearchThread = New System.Threading.Thread(AddressOf SearchSub)

    'SearchThread.Priority = Threading.ThreadPriority.Highest'SearchThread.Start()SearchSub()

    EndSub

    SubSearchSub()btClient = NewInTheHand.Net.Sockets.BluetoothClientDims AsDateTime

    s = NowDimbdi AsInTheHand.Net.Sockets.BluetoothDeviceInfo() =

    btClient.DiscoverDevices()LBlDuration.Text = "Duration: "& DateDiff(DateInterval.Second, s, Now) & "

    Sec"cboDevices.DataSource = bdicboDevices.DisplayMember = "DeviceName"

    EndSub

    PrivateSubButton3_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs) HandlesButton3.Click

  • 8/10/2019 Visual Estudio y Blueetooh.pdf

    2/2

    Dimof1 AsNewOpenFileDialogof1.Filter = "All files (*.*)|*.*"Ifof1.ShowDialog = Windows.Forms.DialogResult.OK Then

    LBLFileName.Text = System.IO.Path.GetFileName(of1.FileName)DimFInfo AsNewIO.FileInfo(of1.FileName)LBLFileSize.Text = "File size : "& CType(CType(FInfo.Length / 1024,

    Integer), String) & " KB"Try

    System.IO.File.Copy(of1.FileName, Application.StartupPath &"\FilesToSend\"& System.IO.Path.GetFileName(of1.FileName), True)

    Catchex AsExceptionMsgBox("Error:"& vbCrLf & _

    ex.Message, MsgBoxStyle.Information +MsgBoxStyle.MsgBoxRight)

    EndTryEndIf

    EndSub

    FunctionCheckHardwareStatus() AsBooleanDimbr AsInTheHand.Net.Bluetooth.BluetoothRadio =

    InTheHand.Net.Bluetooth.BluetoothRadio.PrimaryRadioIfNotbr IsNothingThen

    Ifbr.Mode = InTheHand.Net.Bluetooth.RadioMode.Discoverable Then

    ReturnTrueElseIfbr.Mode = InTheHand.Net.Bluetooth.RadioMode.Connectable Then

    ReturnTrueElseIfbr.Mode = InTheHand.Net.Bluetooth.RadioMode.PowerOff Then

    ReturnTrueEndIf

    ElseReturnFalse

    EndIfEndFunction

    EndClass

    Now I have a more proble too.

    this code send a file but I want to send a string as a smsPermalink

    Posted1-Jun-12 8:53am

    barbodsoft485

    Edited1-Jun-12 9:00am

    v2