This gets the name of a connected or found device.
Input:
device : INT
The device number found with btSearch. Use only one input parameter i.e. either device or ID.
ID : SINT
The connection ID obtained with btConnect or btListen.
Returns: STRING
The device name.
Blank if invalid device, library not open, etc.
Declaration:
FUNCTION btGetDeviceName : STRING;
VAR_INPUT
device : INT;
ID : SINT;
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;
|