Example: /Bluetooth/Mac Bluetooth/CoreBluetooth Devices

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/Bluetooth/Mac Bluetooth/CoreBluetooth Devices


Required plugins for this example: MBS Bluetooth Plugin, MBS MacBase Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Bluetooth/Mac Bluetooth/CoreBluetooth Devices

This example is the version from Sun, 15th Jan 2022.

Project "CoreBluetooth Devices.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open() cm = New MyCBCentralManagerMBS(Nil) Try Dim n As Integer = cm.authorization Select Case n Case cm.kAuthorizationStatusNotDetermined MsgBox "Authorization not determined." Case cm.kAuthorizationStatusRestricted MsgBox "Authorization restricted." Case cm.kAuthorizationStatusDenied MsgBox "Authorization denied." Case cm.kAuthorizationStatusAuthorized MsgBox "Authorized." End Select Catch r As RuntimeException End Try End EventHandler
Property CM As MyCBCentralManagerMBS
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 MyCBCentralManagerMBS Inherits CBCentralManagerMBS
EventHandler Sub DidDiscoverPeripheral(peripheral as CBPeripheralMBS, advertisementData as Dictionary, RSSI as String) System.DebugLog CurrentMethodName Dim l As listbox = MainWindow.List Dim u As Integer = l.ListCount-1 For i As Integer = 0 To u If l.RowTag(i) = peripheral Then // same l.Cell(i, 1) = peripheral.Name l.Cell(i, 2) = peripheral.RSSI Return End If Next l.AddRow Str(peripheral.Handle), peripheral.Name, peripheral.RSSI l.RowTag(l.LastIndex) = peripheral End EventHandler
EventHandler Sub DidUpdateState() Dim state As Integer = Me.State System.DebugLog CurrentMethodName+" with state: "+state.ToString Select case state Case Me.kStatePoweredOff Case Me.kStatePoweredOn System.DebugLog "scanForPeripheralsWithServices..." If True Then // scan for all devices Me.scanForPeripheralsWithServices Else // scan for a specific service like weight scale (181D) Dim weightUID As CBUUIDMBS = CBUUIDMBS.UUIDWithString("181D") Me.scanForPeripheralsWithServices Array(weightUID) End If End Select End EventHandler
End Class
ExternalFile info
End ExternalFile
End Project

See also:

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


💬 Ask a question or report a problem