-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeviceInfo.go
68 lines (60 loc) · 2.32 KB
/
deviceInfo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
/*
#cgo LDFLAGS: -ljabra
#include <stdlib.h>
#include "jabra/Common.h"
*/
import "C"
import "log"
func NewDeviceInfo(cDeviceInfo C.Jabra_DeviceInfo) *DeviceInfo {
deviceInfo := DeviceInfo{
DeviceID: (uint16)(cDeviceInfo.deviceID),
ProductID: (uint16)(cDeviceInfo.productID),
VendorID: (uint16)(cDeviceInfo.vendorID),
DeviceName: C.GoString(cDeviceInfo.deviceName),
USBDevicePath: C.GoString(cDeviceInfo.usbDevicePath),
ParentInstanceID: C.GoString(cDeviceInfo.parentInstanceId),
IsDongle: (bool)(cDeviceInfo.isDongle),
DongleName: C.GoString(cDeviceInfo.dongleName),
Variant: C.GoString(cDeviceInfo.variant),
SerialNumber: C.GoString(cDeviceInfo.serialNumber),
IsInFirmwareUpdateMode: (bool)(cDeviceInfo.isInFirmwareUpdateMode),
ParentDeviceId: (uint16)(cDeviceInfo.parentDeviceId),
}
deviceInfo.IsBusylightSupported = (bool)(C.Jabra_IsBusylightSupported(cDeviceInfo.deviceID))
deviceInfo.BusylightStatus = (bool)(C.Jabra_GetBusylightStatus(cDeviceInfo.deviceID))
return &deviceInfo
}
type DeviceInfo struct {
DeviceID uint16 // unsigned short deviceID
ProductID uint16 // unsigned short productID
VendorID uint16 // unsigned short vendorID
DeviceName string // char* deviceName
USBDevicePath string // char* usbDevicePath
ParentInstanceID string // char* parentInstanceId
IsDongle bool // bool isDongle
DongleName string // char* dongleName
Variant string // char* variant
SerialNumber string // char* serialNumber
IsInFirmwareUpdateMode bool // bool isInFirmwareUpdateMode
ParentDeviceId uint16 // unsigned short parentDeviceId
IsBusylightSupported bool
BusylightStatus bool
}
func (d *DeviceInfo) SetBusylightStatus(value bool) {
if !d.IsBusylightSupported {
return
}
if d.BusylightStatus == value {
return
}
d.BusylightStatus = value
C.Jabra_SetBusylightStatus(C.ushort(d.DeviceID), C.bool(value))
log.Printf("Set busy light on %s to %t", d.DeviceName, d.BusylightStatus)
}
func (d *DeviceInfo) EnableBusylightStatus() {
d.SetBusylightStatus(true)
}
func (d *DeviceInfo) DisableBusylightStatus() {
d.SetBusylightStatus(false)
}