The btHsConnected is used to get the status of the headset audio connection previously opened with btHsOpen.
Input:
None
Return: BOOL
TRUE:
|
- Connection active.
|
FALSE:
|
- No connection.
|
Declaration:
FUNCTION btHsConnected : BOOL;
Example:
INCLUDE rtcu.inc
PROGRAM test;
VAR
rc : INT;
ConID_Headset : SINT;
btCon_Headset : btConnection;
incomingCall : gsmIncomingCall;
END_VAR;
gsmPower(power := TRUE);
btOpen(name := "RTCU MX2");
btSetPin(pin := "1234");
ConID_Headset:=btConnect(address:="00:e0:98:ae:17:23",pin:="0000", Headset:=TRUE);
DebugFmt(message:="Headset Connection ID =\1", v1:=ConID_Headset);
btCon_Headset.id:=ConID_Headset;
BEGIN
btCon_Headset();
incomingCall();
IF btCon_Headset.changed THEN
DebugMsg(message:="Connection info changed:");
DebugFmt(message:=" Connected=\1",v1:=INT(btCon_Headset.connected));
DebugMsg(message:=" Address="+btCon_Headset.Address);
DebugFmt(message:=" Error=\1", v1:=btCon_Headset.Errorcode);
END_IF;
IF incomingCall.status > 0 THEN
DebugMsg(message:="Incoming call");
rc:=btHsOpen(Ring:=TRUE, RingCount:=5);
IF rc = 0 THEN
DebugMsg(message:=" Call accepted");
gsmHeadset(enable:=TRUE);
gsmAnswer();
WHILE btHsConnected() AND gsmOffHook() DO
END_WHILE;
DebugMsg(message:=" Call finished");
btHsClose();
IF gsmOffHook() THEN gsmHangup(); END_IF;
ELSE
DebugMsg(message:=" Call Rejected");
gsmHangup();
END_IF;
END_IF;
...
END;
END_PROGRAM;
|