Platforms to show: All Mac Windows Linux Cross-Platform

/WinFrameworks/Bluetooth/BluetoothLE Watcher


Required plugins for this example: MBS WinFrameworks Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /WinFrameworks/Bluetooth/BluetoothLE Watcher

This example is the version from Thu, 28th Sep 2022.

Project "BluetoothLE Watcher.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() End EventHandler
End Class
Class MainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open() Watcher = new WindowsBluetoothLEAdvertisementWatcher Watcher.list = list watcher.ScanningMode = Watcher.ScanningModeActive Watcher.Start End EventHandler
Property Watcher As WindowsBluetoothLEAdvertisementWatcher
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class WindowsBluetoothLEAdvertisementWatcher Inherits WindowsBluetoothLEAdvertisementWatcherMBS
EventHandler Sub Received(Args as WindowsBluetoothLEAdvertisementReceivedEventArgsMBS) dim now as new date dim ba as string = args.BluetoothAddress.ToHex dim localName as string dim a as WindowsBluetoothLEAdvertisementMBS = args.Advertisement if a <> nil then localName = a.LocalName end if dim type as string Select case args.AdvertisementType case args.AdvertisementTypeConnectableDirected type = "ConnectableDirected" case args.AdvertisementTypeConnectableUndirected type = "ConnectableUndirected" case args.AdvertisementTypeNonConnectableUndirected type = "NonConnectableUndirected" case args.AdvertisementTypeScannableUndirected type = "ScannableUndirected" case args.AdvertisementTypeScanResponse type = "ScanResponse" end Select dim u as integer = list.RowCount-1 for i as integer = 0 to u if list.Cell(i,0) = ba then list.Cell(i,1) = args.RawSignalStrengthInDBm.ToString list.Cell(i,2) = now.SQLDateTime if localName <> "" then // if we got a new name, we show it list.Cell(i,4) = localName end if return end if next // new entry list.AddRow ba, args.RawSignalStrengthInDBm.ToString, now.SQLDateTime, type, LocalName End EventHandler
EventHandler Sub Stopped(Error as Integer) dim m as string = "Stopped "+str(Error) dim e as string Select case Error case me.ErrorNotSupported e = "Error: not supported." case me.ErrorRadioNotAvailable e = "Error: Radio not available." case me.ErrorDisabledByUser e = "Error: Disabled by user." case me.ErrorDisabledByPolicy e = "Error: Disabled by policy." case me.ErrorResourceInUse e = "Error: Resource in use." end Select MessageBox m + EndOfLine+EndOfLine + e End EventHandler
Property list As Listbox
End Class
End Project

See also:

The items on this page are in the following plugins: MBS WinFrameworks Plugin.


The biggest plugin in space...