This function is used to make the headset stop ringing and let btHsOpen return as if the user had rejected the ring. When btHsOpen is called with ring activated, it will wait for the user to accept or reject the call or for the timeout to occur. Sometimes the application needs to answer or reject the call instead of waiting for the headset - for example if the call was hung up by the caller. Please also see the btHsRingAccept for the accept function.
Input:
None
Return: INT
0
|
- Success.
|
-1
|
- Bluetooth library is not open.
|
-5
|
- Headset not ringing.
|
-7
|
- Headset not connected.
|
-17
|
- Timeout.
|
Declaration:
FUNCTION btHsRingReject : INT;
Example:
INCLUDE rtcu.inc
VAR_INPUT
DIP1 : BOOL;
DIP2 : BOOL;
END_VAR;
THREAD_BLOCK GSM_Thread;
VAR
incomingCall : gsmIncomingCall;
rc : INT;
END_VAR;
gsmPower(power := TRUE);
WHILE TRUE DO
incomingCall();
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;
ELSIF rc = -15 THEN
DebugMsg(message:=" Call Rejected");
gsmHangup();
ELSE
DebugMsg(message:=" Call Timeout");
gsmHangup();
END_IF;
END_IF;
END_WHILE;
END_THREAD_BLOCK;
PROGRAM test;
VAR
ConID_Headset : SINT;
btCon_Headset : btConnection;
END_VAR;
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();
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 DIP1 THEN
btHsRingAccept();
END_IF;
IF DIP2 THEN
btHsRingReject();
END_IF;
...
END;
END_PROGRAM;
|