614 lines
29 KiB
VB.net
614 lines
29 KiB
VB.net
Imports System.ComponentModel
|
|
Imports System.Text
|
|
Imports TAPI3Lib
|
|
|
|
Public Class frmTapi
|
|
|
|
Private Const MediaAudio As Integer = 8
|
|
Private Const MediaModem As Integer = 16
|
|
Private Const MediaFax As Integer = 32
|
|
Private Const MediaVideo As Integer = 32768
|
|
|
|
Private WithEvents oTAPI As TAPI3Lib.TAPI ' will hold our TAPI object
|
|
' will hold our selected address (you can hold many addresses in an array)
|
|
Private oAddress As ITAddress
|
|
Private RegCookie As Integer
|
|
|
|
Sub New()
|
|
Try
|
|
InitializeComponent()
|
|
' creating a new instance to first initialize TAPI
|
|
' before attaching the events
|
|
Dim m_TAPI As New TAPI3Lib.TAPIClass
|
|
' a variable to hold supported media types for the address
|
|
Dim MediaTypes As Integer
|
|
' initializing TAPI
|
|
m_TAPI.Initialize()
|
|
' attaching event sink
|
|
oTAPI = m_TAPI
|
|
' getting rid of the private instance as we have another
|
|
' global instance (oTAPI)
|
|
m_TAPI = Nothing
|
|
Dim AddressCollection As ITCollection = oTAPI.Addresses()
|
|
' looping through address collection
|
|
For Each Address As ITAddress In AddressCollection
|
|
' checking if address is working
|
|
If Address.State = ADDRESS_STATE.AS_INSERVICE Then
|
|
' extracting media support interface from the address
|
|
Dim MediaSupport As ITMediaSupport = Address
|
|
' extracting media types supporting
|
|
MediaTypes = MediaSupport.MediaTypes
|
|
MediaSupport = Nothing ' dispose of the object
|
|
|
|
|
|
'If (MediaTypes And MediaModem) = MediaModem Then
|
|
If MediaModem = MediaModem Then
|
|
' the address is a data Modem
|
|
If MediaTypes = MediaAudio Then
|
|
' Select the address since it supports Audio
|
|
' and is a FAX/Modem
|
|
oAddress = Address ' select this address
|
|
' show the selected address name
|
|
SetLabStatus(lblStatusTAPI, "we have selected this address: " & oAddress.AddressName)
|
|
Exit For
|
|
End If
|
|
End If
|
|
End If
|
|
Next Address
|
|
If Not (oAddress Is Nothing) Then
|
|
' registering notifications for the selected address
|
|
RegCookie = oTAPI.RegisterCallNotifications(oAddress, True, False, MediaTypes, 1)
|
|
' Note: this registration can be done on
|
|
' as many addresses as you want
|
|
' we will not receive notifications unless we specify
|
|
' which type of events we are interested in
|
|
oTAPI.EventFilter = (TAPI_EVENT.TE_CALLNOTIFICATION Or
|
|
TAPI_EVENT.TE_CALLSTATE Or TAPI_EVENT.TE_CALLINFOCHANGE)
|
|
Else
|
|
MsgBox("no address selected")
|
|
End If
|
|
Catch ex As Exception
|
|
MsgBox("Error occurred:" & vbCrLf & ex.Message,
|
|
MsgBoxStyle.Critical, "VBCITY.VBTAPI")
|
|
End Try
|
|
' by now we are done for the initialization and registration
|
|
' and the events should fire
|
|
' Note: you must dispose of TAPI before you destroy the class
|
|
' and I will leave this for now
|
|
End Sub
|
|
|
|
Private Sub oTAPI_Event(ByVal TapiEvent As TAPI3Lib.TAPI_EVENT,
|
|
ByVal pEvent As Object) Handles oTAPI.Event
|
|
' making a thread asynchronously process the event
|
|
Dim thAsyncCall As System.Threading.Thread
|
|
Select Case TapiEvent
|
|
|
|
Case TAPI_EVENT.TE_CALLNOTIFICATION 'Call Notification Arrived
|
|
' assigning our sub's delegate to the thread
|
|
thAsyncCall = New Threading.Thread(AddressOf CallNotificationEvent)
|
|
' passing the variable for the thread
|
|
CallNotificationObject = CType(pEvent, ITCallNotificationEvent)
|
|
' starting the thread
|
|
thAsyncCall.Start()
|
|
|
|
Case TAPI_EVENT.TE_CALLSTATE 'Call State Changes
|
|
' assigning our sub's delegate to the thread
|
|
thAsyncCall = New Threading.Thread(AddressOf CallStateEvent)
|
|
' passing the variable for the thread
|
|
CallStateObject = CType(pEvent, ITCallStateEvent)
|
|
' starting the thread
|
|
thAsyncCall.Start()
|
|
|
|
Case TAPI_EVENT.TE_CALLINFOCHANGE 'Call Info Changes
|
|
' assigning our sub's delegate to the thread
|
|
thAsyncCall = New Threading.Thread(AddressOf CallInfoEvent)
|
|
' passing the variable for the thread
|
|
CallInfoObject = CType(pEvent, ITCallInfoChangeEvent)
|
|
' starting the thread
|
|
thAsyncCall.Start()
|
|
|
|
End Select
|
|
End Sub
|
|
|
|
Private CallNotificationObject As ITCallNotificationEvent
|
|
Private Sub CallNotificationEvent()
|
|
' here we should check to see various notifications of new and ended calls
|
|
Select Case CallNotificationObject.Event
|
|
|
|
Case CALL_NOTIFICATION_EVENT.CNE_MONITOR
|
|
' the notification is for a monitored call
|
|
Case CALL_NOTIFICATION_EVENT.CNE_OWNER
|
|
' the notification is for an owned call
|
|
|
|
End Select
|
|
End Sub
|
|
|
|
Private CallStateObject As ITCallStateEvent
|
|
Private Sub CallStateEvent()
|
|
|
|
|
|
' here we should check to see call state and handle connects and disconnects
|
|
Select Case CallStateObject.State
|
|
|
|
Case CALL_STATE.CS_IDLE
|
|
SetLabStatus(lblStatusTAPI, "CS_IDLE")
|
|
Case CALL_STATE.CS_INPROGRESS
|
|
SetLabStatus(lblStatusTAPI, "CS_IDLE")
|
|
Case CALL_STATE.CS_OFFERING
|
|
' a call is offering so if you don't want it then pass it
|
|
' The code to pass the call is the following
|
|
' Dim CallControl As ITBasicCallControl = CallStateObject.Call
|
|
' CallControl.HandoffIndirect(CallStateObject.Call.CallInfoLong(CALLINFO_LONG.CIL_MEDIATYPESAVAILABLE))
|
|
'Dim c = CallStateObject.Call.get_CallInfoString(TAPI3Lib.CALLINFO_STRING.CIS_CALLERIDNUMBER)
|
|
Dim target = CallStateObject.Call.Address.DialableAddress
|
|
'SetLabStatus(lblStatusTAPI, CallStateObject.)
|
|
SetLabStatus(Label1, target)
|
|
Dim oCallInfo As ITCallInfo2 = CallStateObject.Call
|
|
|
|
|
|
'SetLabStatus(lblStatusTAPI, CallStateObject.Call.CallInfoString(CALLINFO_STRING.CIS_CALLERIDNAME))
|
|
SetLabStatus(Label1, CallStateObject.Call.CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER))
|
|
' SetLabStatus(lblStatusTAPI, CallStateObject.Call.CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER)) ' oCallInfo.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNAME))
|
|
' SetLabStatus(lblStatusTAPI, oCallInfo.CallInfoString(CALLINFO_STRING.CIS_CALLERIDNAME))' oCallInfo.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNAME))
|
|
|
|
|
|
|
|
Case CALL_STATE.CS_CONNECTED
|
|
' call is connected
|
|
SetLabStatus(lblStatusTAPI, " call is connected ")
|
|
SetLabStatus(lblCallState, "Anruf läuft, bitte nennen Sie Ihr Anliegen.")
|
|
|
|
' CallStateObject.Call.
|
|
'CallStateObject.Call.CallInfoString()
|
|
|
|
Case CALL_STATE.CS_QUEUED
|
|
' call is being queued
|
|
SetLabStatus(lblStatusTAPI, " call is being queued ")
|
|
Case CALL_STATE.CS_HOLD
|
|
' call is on hold
|
|
SetLabStatus(lblStatusTAPI, "call is on hold ")
|
|
Case CALL_STATE.CS_DISCONNECTED
|
|
' call is disconnected
|
|
SetLabStatus(lblStatusTAPI, "call is disconnected ")
|
|
'SetLabStatus(lblCallState, "Anruf beendet.")
|
|
End Select
|
|
End Sub
|
|
|
|
|
|
|
|
'threadsicherer Aufruf
|
|
Delegate Sub SetLabStatusCallback(lbl As Label, txt As String)
|
|
Private Sub SetLabStatus(lbl As Label, txt As String)
|
|
If Me.InvokeRequired Then
|
|
Dim d As New SetLabStatusCallback(AddressOf SetLabStatus)
|
|
Try
|
|
Me.Invoke(d, New Object() {lbl, txt})
|
|
Catch ex As Exception : End Try
|
|
Else
|
|
lbl.Text = txt
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private CallInfoObject As ITCallInfoChangeEvent
|
|
Private Sub CallInfoEvent()
|
|
' here you can extract information from the call
|
|
' the code to extract the caller ID
|
|
' >>> put the following code in a try block and
|
|
' swallow the exception if it gives errors
|
|
Try
|
|
|
|
Dim CallerID As String
|
|
CallerID = CallInfoObject.Call.CallInfoString(CALLINFO_STRING.CIS_CALLERIDNAME)
|
|
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn.Click
|
|
Dim PhoneNumber As String = "00436644178557"
|
|
' Dim PhoneNumber As String = "147"
|
|
makePhoneCall(PhoneNumber)
|
|
'makeVideoCall(PhoneNumber)
|
|
End Sub
|
|
|
|
|
|
Dim CURRENTCALL As TAPI3Lib.ITBasicCallControl
|
|
Sub makePhoneCall(PhoneNumber As String)
|
|
Try
|
|
' Dim lMediaTypes As Long = TAPI3Lib.TapiConstants.TAPIMEDIATYPE_VIDEO, lCallbackInstance As Long = 1
|
|
Dim lMediaTypes As Long = TAPI3Lib.TapiConstants.TAPIMEDIATYPE_AUDIO, lCallbackInstance As Long = 1
|
|
Dim TestCall As TAPI3Lib.ITBasicCallControl
|
|
|
|
Dim lAddressType As Long = TAPI3Lib.TapiConstants.LINEADDRESSTYPE_PHONENUMBER
|
|
TestCall = oAddress.CreateCall(PhoneNumber, lAddressType, TapiConstants.TAPIMEDIATYPE_AUDIO)
|
|
TestCall.Connect(False)
|
|
CURRENTCALL = TestCall
|
|
'Dim pITMediaSupport = .QueryDispatchInterface(IID_String_ITMediaSupport, pITAddress)
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message & ex.StackTrace)
|
|
End Try
|
|
End Sub
|
|
|
|
Sub makeVideoCall(PhoneNumber As String)
|
|
Try
|
|
' Dim lMediaTypes As Long = TAPI3Lib.TapiConstants.TAPIMEDIATYPE_VIDEO, lCallbackInstance As Long = 1
|
|
Dim lMediaTypes As Long = TAPI3Lib.TapiConstants.TAPIMEDIATYPE_VIDEO, lCallbackInstance As Long = 1
|
|
Dim TestCall As TAPI3Lib.ITBasicCallControl
|
|
|
|
Dim lAddressType As Long = TAPI3Lib.TapiConstants.LINEADDRESSTYPE_PHONENUMBER
|
|
TestCall = oAddress.CreateCall(PhoneNumber, lAddressType, TapiConstants.TAPIMEDIATYPE_AUDIO Or TapiConstants.TAPIMEDIATYPE_VIDEO)
|
|
TestCall.Connect(False)
|
|
|
|
'Dim pITMediaSupport = .QueryDispatchInterface(IID_String_ITMediaSupport, pITAddress)
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message & ex.StackTrace)
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
Sub makeVideoCall2(PhoneNumber As String)
|
|
|
|
SetLabStatus(lblStatusTAPI, "Dialing to " & PhoneNumber & " ...")
|
|
Dim call_control As TAPI3Lib.ITBasicCallControl
|
|
call_control = oAddress.CreateCall(PhoneNumber, TapiConstants.LINEADDRESSTYPE_IPADDRESS, TapiConstants.TAPIMEDIATYPE_AUDIO Or TapiConstants.TAPIMEDIATYPE_VIDEO)
|
|
' call_control = call_address.CreateCall(addr, TapiConstants.LINEADDRESSTYPE_IPADDRESS, TapiConstants.TAPIMEDIATYPE_AUDIO Or TapiConstants.TAPIMEDIATYPE_VIDEO)
|
|
' button1.Enabled = False
|
|
Dim enum_stream As IEnumStream
|
|
'Dim pstream_control As ITStreamControl
|
|
'pstream_control = CType(call_control, ITStreamControl)
|
|
' pstream_control.EnumerateStreams(enum_stream)
|
|
Dim p_stream As ITStream
|
|
Dim a11 As UInteger = 0
|
|
call_control.EnumerateStreams(enum_stream)
|
|
enum_stream.[Next](1, p_stream, a11)
|
|
Dim imedia As Integer
|
|
imedia = p_stream.MediaType
|
|
Dim dir As TERMINAL_DIRECTION
|
|
dir = p_stream.Direction
|
|
Dim termi, termi1 As ITTerminal
|
|
Dim term_support As ITTerminalSupport = CType(oAddress, ITTerminalSupport)
|
|
termi = term_support.GetDefaultStaticTerminal(imedia, dir)
|
|
p_stream.SelectTerminal(termi)
|
|
enum_stream.[Next](1, p_stream, a11)
|
|
termi1 = term_support.GetDefaultStaticTerminal(imedia, TERMINAL_DIRECTION.TD_CAPTURE)
|
|
p_stream.SelectTerminal(termi1)
|
|
call_control.EnumerateStreams(enum_stream)
|
|
call_control.Connect(False)
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub btn3_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|
' Try
|
|
|
|
'MsgBox(PlathosysApiWrapper.Plathosys.ApiVersionNumber())
|
|
openConnectionPLATHOSYS()
|
|
|
|
|
|
|
|
'Dim HookPttInfo = -1
|
|
'PlathosysApiWrapper.Plathosys.ReadHookAndPTT(HookPttInfo)
|
|
'MsgBox(HookPttInfo)
|
|
|
|
'PlathosysApiWrapper.Plathosys.Closedevice()
|
|
|
|
|
|
|
|
' Catch ex As Exception
|
|
' MsgBox(ex.Message & ex.StackTrace)
|
|
' End Try
|
|
End Sub
|
|
|
|
|
|
Function openConnectionPLATHOSYS() As Boolean
|
|
Try
|
|
Dim isDeviceOpen As Boolean = PlathosysApiWrapper.Plathosys.IsDeviceOpen()
|
|
If Not isDeviceOpen Then
|
|
Dim apiVersionNumber As Integer = PlathosysApiWrapper.Plathosys.ApiVersionNumber()
|
|
Console.WriteLine("ApiVersionNumber: {0}", Convert.ToString(apiVersionNumber, 2))
|
|
Dim successful As Boolean
|
|
Dim vendorID As Integer = 0
|
|
Dim productID As Integer = 0
|
|
Dim selectedVendorID As Integer
|
|
Dim selectedProductID As Integer
|
|
Dim deviceName As StringBuilder = New StringBuilder(200)
|
|
Dim serialNumber As StringBuilder = New StringBuilder(200)
|
|
successful = PlathosysApiWrapper.Plathosys.Opendevice(vendorID, productID, selectedVendorID, selectedProductID, deviceName, serialNumber)
|
|
Console.WriteLine($"Open successful? {successful}")
|
|
Console.WriteLine("Selected Vendor ID: {0:X}", selectedVendorID)
|
|
Console.WriteLine("Selected Product ID: {0:X}", selectedProductID)
|
|
Console.WriteLine($"Device name: {deviceName}")
|
|
Console.WriteLine($"Serial number: {serialNumber}")
|
|
|
|
If successful Then
|
|
|
|
|
|
successful = PlathosysApiWrapper.Plathosys.SetHandsetVolume(200)
|
|
successful = PlathosysApiWrapper.Plathosys.SetIntSpeakerVolume(0)
|
|
successful = PlathosysApiWrapper.Plathosys.SetHandsetMicVolume(128)
|
|
|
|
successful = PlathosysApiWrapper.Plathosys.SetMicMute(False)
|
|
|
|
'successful = PlathosysApiWrapper.Plathosys.SetSpeakerOutMute(False) 'alle
|
|
'successful = PlathosysApiWrapper.Plathosys.SetIntSpeakerMute(True)
|
|
'' Console.WriteLine($"SetHeadsetActive successful? {successful}")
|
|
''PlathosysApiWrapper.Plathosys.SetIntSpeakerMute(False)
|
|
''PlathosysApiWrapper.Plathosys.SetIntSpeakerVolume(255)
|
|
''PlathosysApiWrapper.Plathosys.SetHandsetVolume(128)
|
|
'successful = PlathosysApiWrapper.Plathosys.SetConference(False)
|
|
'Console.WriteLine($"SetConference successful? {successful}")
|
|
|
|
' PlathosysApiWrapper.Plathosys.SetConference(False) 'Lautsprecher deaktivieren
|
|
'PlathosysApiWrapper.Plathosys.SetHeadsetEar(True) 'Hörer aktivieren
|
|
' PlathosysApiWrapper.Plathosys.SetIntSpeakerVolume(0) 'Hörer Lautstäreke = 0
|
|
|
|
|
|
isDeviceOpen = PlathosysApiWrapper.Plathosys.IsDeviceOpen()
|
|
If isDeviceOpen Then
|
|
Timer.Enabled = True
|
|
Return True
|
|
End If
|
|
End If
|
|
End If
|
|
' Public Shared Function Opendevice(ByVal vendorID As Integer, ByVal productID As Integer, <Out> ByRef gotVendorID As Integer, <Out> ByRef gotProductID As Integer, ByVal gotProductName As StringBuilder, ByVal gotSerialNumber As StringBuilder) As Boolean
|
|
|
|
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message & ex.StackTrace)
|
|
End Try
|
|
Return False
|
|
End Function
|
|
Sub allFunc()
|
|
' Try
|
|
|
|
MsgBox(PlathosysApiWrapper.Plathosys.ApiVersionNumber())
|
|
|
|
|
|
|
|
'Dim HookPttInfo = -1
|
|
'PlathosysApiWrapper.Plathosys.ReadHookAndPTT(HookPttInfo)
|
|
'MsgBox(HookPttInfo)
|
|
|
|
'PlathosysApiWrapper.Plathosys.Closedevice()
|
|
Try
|
|
|
|
Dim apiVersionNumber As Integer = PlathosysApiWrapper.Plathosys.ApiVersionNumber()
|
|
Console.WriteLine("ApiVersionNumber: {0}", Convert.ToString(apiVersionNumber, 2))
|
|
Dim successful As Boolean
|
|
Dim vendorID As Integer = 0
|
|
Dim productID As Integer = 0
|
|
Dim selectedVendorID As Integer
|
|
Dim selectedProductID As Integer
|
|
Dim deviceName As StringBuilder = New StringBuilder(200)
|
|
Dim serialNumber As StringBuilder = New StringBuilder(200)
|
|
successful = PlathosysApiWrapper.Plathosys.Opendevice(vendorID, productID, selectedVendorID, selectedProductID, deviceName, serialNumber)
|
|
Console.WriteLine($"Open successful? {successful}")
|
|
Console.WriteLine("Selected Vendor ID: {0:X}", selectedVendorID)
|
|
Console.WriteLine("Selected Product ID: {0:X}", selectedProductID)
|
|
Console.WriteLine($"Device name: {deviceName}")
|
|
Console.WriteLine($"Serial number: {serialNumber}")
|
|
Dim isDeviceOpen As Boolean = PlathosysApiWrapper.Plathosys.IsDeviceOpen()
|
|
Console.WriteLine($"IsDeviceOpen? {isDeviceOpen}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetHandsetVolume(128)
|
|
Console.WriteLine($"SetHandsetVolume successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetHeadsetVolume(128)
|
|
Console.WriteLine($"SetHeadsetVolume successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetIntSpeakerVolume(128)
|
|
Console.WriteLine($"SetIntSpeakerVolume successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetIntSpeakerMute(True)
|
|
Console.WriteLine($"SetIntSpeakerMute successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetHandsetMicVolume(128)
|
|
Console.WriteLine($"SetHandsetMicVolume successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetExtMicVolume(128)
|
|
Console.WriteLine($"SetExtMicVolume successful? {successful}")
|
|
Dim info1, info2, info3, info4, info5, info6, info7, info8, info9, info10 As Byte
|
|
successful = PlathosysApiWrapper.Plathosys.ReadCurrentInfo(info1, info2, info3, info4, info5, info6, info7, info8, info9, info10)
|
|
Console.WriteLine($"ReadCurrentInfo successful? {successful}")
|
|
Console.WriteLine($"Connected / PTT Info: {Convert.ToString(info1, 2).PadLeft(8, "0"c)}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetSideTone(True)
|
|
Console.WriteLine($"SetSideTone successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetMicMute(True)
|
|
Console.WriteLine($"SetMicMute successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetWideBand(True)
|
|
Console.WriteLine($"SetWideBand successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetEchoCanceller(True)
|
|
Console.WriteLine($"SetEchoCanceller successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetExtMic(True)
|
|
Console.WriteLine($"SetExtMic successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetConference(True)
|
|
Console.WriteLine($"SetConference successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetHeadsetActive(True)
|
|
Console.WriteLine($"SetHeadsetActive successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetWirelessHeadsetRinging(True)
|
|
Console.WriteLine($"SetWirelessHeadsetRinging successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetWirelessCall(True)
|
|
Console.WriteLine($"SetWirelessCall successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetPttFunctions(9)
|
|
Console.WriteLine($"SetPttPlathosys successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetHeadsetEar(1)
|
|
Console.WriteLine($"SetHeadsetEar successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetExtmicLed(True)
|
|
Console.WriteLine($"SetExtmicLed successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetByListening(True)
|
|
Console.WriteLine($"SetByListening successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetCodecType(1)
|
|
Console.WriteLine($"SetCodecType successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetSerialNumber(12345678)
|
|
Console.WriteLine($"SetSerialNumber successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.InitHookAndPTTState()
|
|
Console.WriteLine($"InitHookAndPTTState successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.MuteSpkCt140(True)
|
|
Console.WriteLine($"MuteSpkCt140 successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.MuteMicCt140(True)
|
|
Console.WriteLine($"MuteMicCt140 successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetHeadsetdBVolume(-6)
|
|
Console.WriteLine($"SetHeadsetdBVolume successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetHeadsetMicdBVolume(6)
|
|
Console.WriteLine($"SetHeadsetMicdBVolume successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetExtMicdBVolume(3)
|
|
Console.WriteLine($"SetExtMicdBVolume successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetIntSpeakerdBVolume(3)
|
|
Console.WriteLine($"SetIntSpeakerdBVolume successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetIntAlarmSpeakerdBVolume(3)
|
|
Console.WriteLine($"SetIntAlarmSpeakerdBVolume successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetIntAlarmSpeakerVolume(3)
|
|
Console.WriteLine($"SetIntAlarmSpeakerVolume successful? {successful}")
|
|
successful = PlathosysApiWrapper.Plathosys.SetLyncFeature(True)
|
|
Console.WriteLine($"SetLyncFeature successful? {successful}")
|
|
Dim info11, info12, info13, info14, info15, info16 As Byte
|
|
successful = PlathosysApiWrapper.Plathosys.ReadCurrentInfodB(info1, info2, info3, info4, info5, info6, info7, info8, info9, info10, info11, info12, info13, info14, info15, info16)
|
|
Console.WriteLine($"ReadCurrentInfodB successful? {successful}")
|
|
Console.WriteLine($"Connected Info: {Convert.ToString(info1, 2).PadLeft(8, "0"c)}")
|
|
Console.WriteLine($"Standard headset connected? {(info1 And 2) <> 0}")
|
|
Console.WriteLine($"Info3: {info3}")
|
|
Dim hardwareVersion As String = Convert.ToString(info3, 2).PadLeft(8, "0"c)
|
|
Dim first As Integer = Convert.ToInt32(hardwareVersion.Substring(0, 4), 2)
|
|
Dim second As Integer = Convert.ToInt32(hardwareVersion.Substring(4, 4), 2)
|
|
Console.WriteLine($"Hardware version: {first}.{second}")
|
|
Console.WriteLine($"Info4: {info4}")
|
|
Dim softwareVersion As String = Convert.ToString(info4, 2).PadLeft(8, "0"c)
|
|
first = Convert.ToInt32(hardwareVersion.Substring(0, 4), 2)
|
|
second = Convert.ToInt32(hardwareVersion.Substring(4, 4), 2)
|
|
Console.WriteLine($"Software version: {first}.{second}")
|
|
Console.WriteLine($"Serial number high: {info7}")
|
|
Console.WriteLine($"Serial number: {info8}")
|
|
Console.WriteLine($"Serial number: {info9}")
|
|
Console.WriteLine($"Serial number low: {info10}")
|
|
Console.WriteLine($"Speaker volume on bylisten: {info14}")
|
|
Dim hookAndPttInfo As Integer
|
|
successful = PlathosysApiWrapper.Plathosys.ReadHookAndPTT(hookAndPttInfo)
|
|
Console.WriteLine($"ReadHooAndPttInfo successful? {successful}")
|
|
Console.WriteLine($"HookAndPttInfo: {Convert.ToString(hookAndPttInfo, 2).PadLeft(4, "0"c)}")
|
|
Console.WriteLine($"HookOff? {(hookAndPttInfo And 1) <> 0}")
|
|
isDeviceOpen = PlathosysApiWrapper.Plathosys.IsDeviceOpen()
|
|
Console.WriteLine($"IsDeviceOpen: {isDeviceOpen}")
|
|
successful = PlathosysApiWrapper.Plathosys.Closedevice()
|
|
Console.WriteLine($"DeviceClosed successful? {successful}")
|
|
isDeviceOpen = PlathosysApiWrapper.Plathosys.IsDeviceOpen()
|
|
Console.WriteLine($"IsDeviceOpen: {isDeviceOpen}")
|
|
''Public Static extern bool Opendevice(
|
|
''Int VendorID,
|
|
''Int productID,
|
|
''out Int gotVendorID,
|
|
''out Int gotProductID,
|
|
''StringBuilder GotProductName,
|
|
''StringBuilder gotSerialNumber);
|
|
'Dim VendorID As Integer '= &H299D '&H299D '
|
|
''Dim VendorID = 665
|
|
'Dim ProductID As Integer '= &H1 '0
|
|
'Dim GotVendorID As Integer
|
|
'Dim GotProductID As Integer
|
|
'Dim GotProductName As String = ""
|
|
'Dim gotSerialNumber As String = ""
|
|
'MsgBox(PlathosysApiWrapper.Plathosys.IsDeviceOpen())
|
|
|
|
'If PlathosysApiWrapper.Plathosys.Opendevice(VendorID, ProductID, GotVendorID, GotProductID, GotProductName, gotSerialNumber) Then
|
|
' MsgBox(GotVendorID)
|
|
' MsgBox(GotProductID)
|
|
'Else
|
|
' MsgBox("No")
|
|
'End If
|
|
|
|
|
|
|
|
' Public Shared Function Opendevice(ByVal vendorID As Integer, ByVal productID As Integer, <Out> ByRef gotVendorID As Integer, <Out> ByRef gotProductID As Integer, ByVal gotProductName As StringBuilder, ByVal gotSerialNumber As StringBuilder) As Boolean
|
|
|
|
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message & ex.StackTrace)
|
|
End Try
|
|
|
|
|
|
' Catch ex As Exception
|
|
' MsgBox(ex.Message & ex.StackTrace)
|
|
' End Try
|
|
End Sub
|
|
|
|
Private Sub frmTapi_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
|
|
Try
|
|
Dim isDeviceOpen = PlathosysApiWrapper.Plathosys.IsDeviceOpen()
|
|
If isDeviceOpen Then
|
|
Dim successful = PlathosysApiWrapper.Plathosys.Closedevice()
|
|
Console.WriteLine($"DeviceClosed successful? {successful}")
|
|
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
Dim STATE = "NOT PICKUP"
|
|
Private Sub Timer_Tick(sender As Object, e As EventArgs) Handles Timer.Tick
|
|
|
|
|
|
Dim isDeviceOpen = PlathosysApiWrapper.Plathosys.IsDeviceOpen()
|
|
If isDeviceOpen Then
|
|
Dim HookPttInfo = -1
|
|
Dim ReadHook = PlathosysApiWrapper.Plathosys.ReadHookAndPTT(HookPttInfo)
|
|
|
|
Console.WriteLine($"ReadHook? {ReadHook}")
|
|
Console.WriteLine($"HookPttInfo? {HookPttInfo}")
|
|
|
|
'Dim HookAndPTTState = PlathosysApiWrapper.Plathosys.InitHookAndPTTState()
|
|
'Console.WriteLine($"HookAndPTTState? {HookAndPTTState}")
|
|
|
|
Select Case HookPttInfo
|
|
Case "17" 'PICKUP
|
|
If STATE <> "PICKUP" Then
|
|
STATE = "PICKUP"
|
|
' --> ANRUF STARTEN
|
|
picCallState.BackgroundImage = My.Resources._call
|
|
|
|
'picCallState.BackgroundImage = Nothing
|
|
'picCallState.Image = My.Resources._call
|
|
lblCallState.Text = "Anruf wird gestartet..."
|
|
Dim PhoneNumber As String = "00436644178557"
|
|
' Dim PhoneNumber As String = "147"
|
|
makePhoneCall(PhoneNumber)
|
|
' MsgBox("PICKUP!!!")
|
|
End If
|
|
Case Else
|
|
If STATE = "PICKUP" Then
|
|
STATE = "NOT PICKUP"
|
|
' --> ANRUF BEENDEN
|
|
picCallState.BackgroundImage = My.Resources.PLATHOSYS
|
|
'picCallState.BackgroundImage = My.Resources.PLATHOSYS
|
|
'picCallState.Image = Nothing
|
|
lblCallState.Text = "Bitte heben Sie den Höhrer ab, um den Anruf zu starten."
|
|
CURRENTCALL.Disconnect(DISCONNECT_CODE.DC_NORMAL)
|
|
' MsgBox("PICKUP DOWN!!!")
|
|
End If
|
|
End Select
|
|
Else
|
|
'NEU VERBINDEN
|
|
openConnectionPLATHOSYS()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub frmTapi_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
'allFunc()
|
|
Timer.Enabled = True
|
|
End Sub
|
|
|
|
Private Sub lblClose_Click(sender As Object, e As EventArgs) Handles lblClose.Click
|
|
Me.Close()
|
|
End Sub
|
|
|
|
Private Sub lblClose_MouseHover(sender As Object, e As EventArgs) Handles lblClose.MouseHover
|
|
lblClose.BackColor = Color.Red
|
|
lblClose.ForeColor = Color.White
|
|
End Sub
|
|
|
|
Private Sub lblClose_MouseLeave(sender As Object, e As EventArgs) Handles lblClose.MouseLeave
|
|
lblClose.BackColor = Panel2.BackColor
|
|
lblClose.ForeColor = Panel2.BackColor
|
|
End Sub
|
|
End Class |