This gets the type of a device found with btSearch. The type or ClassOfDevice (CoD) is a number that indicates what type or class the device is. This may be used to determine if the device is a PC, Headset, GPS, etc.
Input:
device : INT
The device number found with btSearch.
Returns: DINT
The device type.
-1
|
- Bluetooth library is not open.
|
-9
|
- Invalid device.
|
Declaration:
FUNCTION btGetDeviceType : DINT;
VAR_INPUT
device : INT;
END_VAR;
Example:
INCLUDE rtcu.inc
PROGRAM test;
VAR
rc : INT;
i : INT;
headsetID : INT;
END_VAR;
btOpen(name := "RTCU MX2");
BEGIN
...
DebugMsg(message:="Starting search....");
rc:=btSearch();
DebugFmt(message:=" btSearch=\1", v1:=rc);
FOR i:=1 TO rc DO
DebugMsg(message:=" ("+intToStr(v:=i)+") Addr="+btGetDeviceAddress(device:=i)+" Type="+dintToStr(v:=btGetDeviceType(device:=i))+" name="+btGetDeviceName(device:=i));
IF btGetDeviceName(device:=i) = "Motorola H300" THEN
headsetID:=i;
DebugMsg(message:=" Motorola H300 found at device ->"+intToStr(v:=i));
END_IF;
END_FOR;
...
END;
END_PROGRAM;
|