VB.NET BLETrial --------------- The code...... Public Sub OnConnected(sender As Object, arguments As EventArgs) Handles masteremulator.Connected 'The connection is up, proceed with Bond and pipe discovery. 'Using a background task in order not to block the event caller. */ Try Dim msg As String = "OnConnect() Event Recieved [CONNECTED]" If Me.txtStatus.InvokeRequired Then Dim d As New SetTextCallback(AddressOf updateStatus) Me.Invoke(d, New Object() {msg}) Else Me.txtStatus.Text = msg End If Dim taskOne = Task.Factory.StartNew(Function() DoBond(pipesetup)) Catch ex As Exception frmErrorMessage.txtClassName.Text = classname frmErrorMessage.txtVersion.Text = version frmErrorMessage.txtSystemMessage.Text = ex.Message frmErrorMessage.txtApplicationMessages.Text = "OnConnected()" frmErrorMessage.ShowDialog() End Try End Sub Public Function DoBond(ByRef pipesetup As PipeSetup) Dim bondOK As Boolean = Bond() If bondOK = True Then Dim intTest As Integer = pipesetup.DeviceNamePipe DiscoverPipes() 'OpenRemotePipes() 'ReadBatteryLevel() 'WriteHidProtocolMode() End If Return bondOK End Function Public Function DiscoverPipes() As Boolean Dim success As Boolean = False Try success = masteremulator.DiscoverPipes() Catch ex As Exception frmErrorMessage.txtClassName.Text = classname frmErrorMessage.txtVersion.Text = version frmErrorMessage.txtSystemMessage.Text = ex.Message & vbCrLf & vbCrLf & "STACK TRACE" & vbCrLf & ex.StackTrace frmErrorMessage.txtApplicationMessages.Text = "DiscoverPipes() =PipeSetup did not match ATT table of connected device. " frmErrorMessage.ShowDialog() End Try Return success End Function #Properties as set just before masteremulator.DiscoverPipes() is called pipesetup .DeviceNamePipe = 1 .BatteryLevelPipe = 2 .HidProtocolModePipe = 3 .HidReportPipe1 = 4 .HIDReportPipe2 = 5 .HidReportPipe3 = 0 masteremulator .IsConnected = True .IsDeviceDiscoveryOngoing = False .IsEncryptionOngoing = False .IsLinkEncrypted = True .IsOpen = True .IsRunning = True .LogVerbosity = High {2} 28;15:34:20.7605 [MainThread] Setup: add service 0x1800 store REMOTE_STORE 29;15:34:20.7825 [MainThread] Setup: add char def 0x2A00 30;15:34:20.8245 [MainThread] Setup: assigned pipenumber 1 type REQUEST_RECEIVE 31;15:34:20.8265 [MainThread] Setup: add service 0x180F store REMOTE_STORE 32;15:34:20.8275 [MainThread] Setup: add char def 0x2A19 33;15:34:20.8285 [MainThread] Setup: assigned pipenumber 2 type REQUEST_RECEIVE 34;15:34:20.8295 [MainThread] Setup: add service 0x1812 store REMOTE_STORE 35;15:34:20.8305 [MainThread] Setup: add char def 0x2A4E 36;15:34:20.8355 [MainThread] Setup: assigned pipenumber 3 type TRANSMIT 37;15:34:20.8365 [MainThread] Setup: add char def 0x2A4D 38;15:34:20.8375 [MainThread] Setup: assigned pipenumber 4 type RECEIVE 39;15:34:20.8405 [MainThread] Setup: add char desc 0x2908 40;15:34:20.8515 [MainThread] Setup: add char def 0x2A4D 41;15:34:20.8525 [MainThread] Setup: assigned pipenumber 5 type TRANSMIT 42;15:34:20.8535 [MainThread] Setup: add char desc 0x2908 No pipes have been set up STACK TRACE at DLRCachedCode._checkHavePipesBeenSetUp$177(Closure , PythonFunction $function, Object self) at IronPython.Runtime.PythonFunction.FunctionCaller`1.Call1(CallSite site, CodeContext context, Object func, T0 arg0) at IronPython.Runtime.Method.MethodBinding.SelfTarget(CallSite site, CodeContext context, Object target) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at DLRCachedCode.DiscoverPipes$184(Closure , PythonFunction $function, Object self) at IronPython.Runtime.PythonFunction.FunctionCaller`1.Call1(CallSite site, CodeContext context, Object func, T0 arg0) at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at _Scripting_(Object[] ) at Nordicsemi.MasterEmulator.DiscoverPipes() at WindowsApplication1.frmMain.DiscoverPipes() in C:\BLETrial\BLETrial\frmMain.vb:line 474 C# HidDemo -- pipesetup .DeviceNamePipe = 1 .BatteryLevelPipe = 2 .HidProtocolModePipe = 3 .HidReportPipe1 = 4 .HidReportPipe2 = 5 .HidReportPipe3 = 0 masterEmulator .IsConnected = true .IsDeviceDiscoveryOngoing = false .IsEncryptionOngoing = false .IsLinkEncrypted = true .IsOpen = true .IsRunning = true .LogVerbosity = High Loading Select setup: 1) Keyboard 2) Mouse Keyboard setup selected Registering event handlers Found master emulator device: COM11 480103684 [LOG_MESSAGE]: Open [LOG_MESSAGE]: Device address: 0x29CD0099FF56 [LOG_MESSAGE]: Setup: add service 0x1800 store REMOTE_STORE [LOG_MESSAGE]: Setup: add char def 0x2A00 [LOG_MESSAGE]: Setup: assigned pipenumber 1 type REQUEST_RECEIVE [LOG_MESSAGE]: Setup: add service 0x180F store REMOTE_STORE [LOG_MESSAGE]: Setup: add char def 0x2A19 [LOG_MESSAGE]: Setup: assigned pipenumber 2 type REQUEST_RECEIVE [LOG_MESSAGE]: Setup: add service 0x1812 store REMOTE_STORE [LOG_MESSAGE]: Setup: add char def 0x2A4E [LOG_MESSAGE]: Setup: assigned pipenumber 3 type TRANSMIT [LOG_MESSAGE]: Setup: add char def 0x2A4D [LOG_MESSAGE]: Setup: assigned pipenumber 4 type RECEIVE [LOG_MESSAGE]: Setup: add char desc 0x2908 [LOG_MESSAGE]: Setup: add char def 0x2A4D [LOG_MESSAGE]: Setup: assigned pipenumber 5 type TRANSMIT [LOG_MESSAGE]: Setup: add char desc 0x2908 [LOG_MESSAGE]: Run [LOG_MESSAGE]: Device discovery started. [LOG_MESSAGE]: Device discovery stopped. Connecting to F7291AB09086 Nordic_Keyboard [LOG_MESSAGE]: Connecting [LOG_MESSAGE]: Connected to F7291AB09086 [CONNECTED] [LOG_MESSAGE]: Bonding [LOG_MESSAGE]: Encryption change: Link encryption is ON [LOG_MESSAGE]: Negotiated security level: JustWorks [LOG_MESSAGE]: Bonded successfully [LOG_MESSAGE]: Discover pipes [LOG_MESSAGE]: Discovered pipe 1 (characteristic 0x2A00, service 0x1800) [LOG_MESSAGE]: Discovered pipe 2 (characteristic 0x2A19, service 0x180F) [LOG_MESSAGE]: Discovered pipe 3 (characteristic 0x2A4E, service 0x1812) [LOG_MESSAGE]: Discovered pipe 4 (characteristic 0x2A4D, service 0x1812) [LOG_MESSAGE]: Discovered pipe 4 CCCD (descriptor 0x2902, service 0x1812) [LOG_MESSAGE]: Discovered pipe 5 (characteristic 0x2A4D, service 0x1812) [LOG_MESSAGE]: Opening pipe 4 [LOG_MESSAGE]: Data read on pipe number 2: 0x63 Battery level was successfully read: 99 [LOG_MESSAGE]: Data sent on pipe number 3: 0x01 HID Protocol Mode was successfully written: 1 Ready