}
bool
-Class1Modem::switchingPause(fxStr& emsg)
+Class1Modem::switchingPause(fxStr& emsg, u_int times)
{
- if (!silenceHeard && !atCmd(conf.class1SwitchingCmd, AT_OK)) {
+ /*
+ * If class1SwitchingCmd is of the AT+FRS=n form we honor
+ * the caller's indicattion for a multiplication of the
+ * configured silence detection. This is primarily used
+ * to avoid sending CRP as a receiver during a sender's TCF,
+ * but it could also be used in places where we find a
+ * longer wait often necessary.
+ */
+ fxStr scmd = fxStr(conf.class1SwitchingCmd);
+ if (times != 1) {
+ fxStr ncmd = fxStr(scmd);
+ ncmd.raiseatcmd();
+ if (ncmd.length() > 7 && ncmd.head(7) == "AT+FRS=") {
+ int dur = atoi(ncmd.tail(ncmd.length()-7)) * times;
+ scmd = scmd.head(7) | fxStr(dur, "%d");
+ }
+ }
+ if (!silenceHeard && !atCmd(scmd, AT_OK)) {
emsg = "Failure to receive silence.";
protoTrace(emsg);
if (wasTimeout()) abortReceive();
frame.reset();
gotframe = recvRawFrame(frame);
} while (!gotframe && docrp && crpcnt++ < 3 && !wasTimeout() &&
- switchingPause(emsg) && transmitFrame(dir|FCF_CRP));
+ switchingPause(emsg, 3) && transmitFrame(dir|FCF_CRP)); /* triple switchingPause to avoid sending CRP during TCF */
return (gotframe);
} else {
gotCONNECT = false;
virtual ATResponse atResponse(char* buf, long ms = 30*1000);
virtual bool waitFor(ATResponse wanted, long ms = 30*1000);
virtual bool atCmd(const fxStr& cmd, ATResponse = AT_OK, long ms = 30*1000);
- bool switchingPause(fxStr& emsg);
+ bool switchingPause(fxStr& emsg, u_int times = 1);
void encodeTSI(fxStr& binary, const fxStr& ascii);
void encodeNSF(fxStr& binary, const fxStr& ascii);
const fxStr& decodeTSI(fxStr& ascii, const HDLCFrame& binary);