Administrator
发布于 2026-11-10 / 3 阅读
0
0

FreeSWITCH configuration lab 13: DTMF transport and digit collection

English
中文

Use two extensions to test collection

Reuse 7101, 7102 and the training-internal listener. From 7101, dial 7813 and press 12 after answer. Expect 7102 to ring. Enter 99 or let collection time out to exercise retry and the failure route at 7814. 7102 is a directory SIP extension. Agent contact and queue tier settings remain separate.

Use a test instance with backups, two working phones and packet capture access. Keep normal media through FreeSWITCH and the common codec from episode 11. Restore normal mode if episode 12's bypass or proxy test is still active. The example was checked against v1.11.2 templates and source, the current manual and RFC 4733. Verify the expected behavior on your instance.

Identify how the digit arrives

An RTP telephone-event carries the key, duration and end indication in the media stream. SIP INFO carries keypad signaling inside a dialog using a payload format agreed with the peer. Inband DTMF is audio that a receiver detects. Working speech alone cannot confirm how digits travel.

Set 7101 to telephone-event mode, often labeled RFC2833 or RTP Event. RFC 4733 superseded RFC 2833, but the old label remains in configuration. Verify telephone-event in the negotiated audio SDP and decode packets using that leg's payload type. 101 is common in the shipped template and can differ on other legs. The payload type identifies the format. The key itself is in the event field.

Sofia's dtmf-type selects how FreeSWITCH sends digits. Keep the existing setting if the lab already uses telephone events. If it was switched to info, back up sip_profiles/training-internal.xml, verify its settings, restore rfc2833 for the lab and restart the profile in a test window. Register again. Compare what actually arrives on the receiving leg after a change.

Install a route with a failure path

Run eval $${conf_dir} in fs_cli to locate the configuration root. Confirm the context reached after 7101 authenticates. Save the example as dialplan/default/00_training_dtmf_13.xml. Verify that the directory is included and that 7813 and 7814 are available. For another controlled context, change the include location and the context in the failure transfer. Keep the lab route inside authenticated access.

<include>
  <extension name="fs_dtmf_lab_13">
    <condition field="destination_number" expression="^7813$">
      <!-- 接听后收两个键,仅接受12 -->
      <action application="answer"/>
      <action application="unset" data="lab_digits"/>
      <!-- 失败跳到7814,两次机会,首键5秒、键间2秒 -->
      <action application="play_and_get_digits"
              data="2 2 2 5000 # silence_stream://500 silence_stream://300 lab_digits ^12$ 2000 '7814 XML default'"/>
      <!-- 这里只记录实验输入通过,避免把按键值写进日志 -->
      <action application="log" data="INFO DTMF_LAB_ACCEPTED"/>
      <action application="set" data="hangup_after_bridge=true"/>
      <!-- 使用现有目录域定位被叫分机 -->
      <action application="bridge" data="user/7102@${domain_name}"/>
    </condition>
  </extension>
  <extension name="fs_dtmf_lab_13_failed">
    <condition field="destination_number" expression="^7814$">
      <!-- 实验收号失败,结束当前通话 -->
      <action application="log" data="INFO DTMF_LAB_REJECTED"/>
      <action application="hangup" data="NORMAL_CLEARING"/>
    </condition>
  </extension>
</include>

The first two values of 2 set the minimum and maximum length. The third sets two attempts. The first-digit wait is 5000 ms, and the interdigit wait is 2000 ms. The hash key can finish collection early. Reaching the two-digit maximum also completes collection, so 12 needs no hash. One digit is too short, and 99 fails the regular expression.

The silence_stream entries supply 500 ms and 300 ms of silence for the prompt and invalid-input prompt. Use a build with the corresponding audio file interface. In production, substitute readable prompts and account for paths containing spaces. The whole input must match ^12$. lab_digits holds the result. The optional transfer specifies the failure extension, dialplan and context. Clear the previous value before collecting again on the same channel.

The accepted branch locates 7102 using the directory domain verified earlier. The failure route records a test marker and hangs up. Retain outcome and channel identity in logs. Use dummy input for packet captures because real digits can contain credentials.

Reload and validate each layer

Run reloadxml in fs_cli and dial 7813 from 7101. A dialplan-only edit needs no profile restart. Verify the extension match, answer and bridge target. Enter 12 and expect the acceptance marker and a ring at 7102. Answer and verify two-way audio. Use separate calls for 99 and for no input, verifying that two attempts lead to 7814. Enter 1 and wait longer than two seconds in another call to verify interdigit timeout. Measure prompt time and collection waits separately.

If the call fails, align ingress packets, FreeSWITCH DTMF events and dialplan logs by channel and time. For absent packets, check negotiation and reachability. If events reach FreeSWITCH, inspect the required length, expression, timers and whether another application consumed digits first. If collection succeeds but 7102 does not ring, inspect registration lookup and bridge outcomes.

Match options to the actual transport

  • A peer sends only SIP INFO. Check the received INFO and the peer agreement, then test on a dedicated route. Review dtmf-type or per-call dtmf_type for sending without changing all trunks.
  • Audible tones yield no event. Confirm inband tones and test start_dtmf before collection in normal media mode. Stop detection with stop_dtmf or end the test call. If telephone events are also present, check for duplicate detection.
  • Duration and spacing appear inconsistent. dtmf-duration specifies generated event duration at an 8000 Hz clock. 2000 corresponds to 250 ms. rtp-digit-delay specifies sending spacing in milliseconds. The application's digit_timeout controls how long it waits for the next user input.
  • Multiple packets appear for one press. Reports for a short event can share a starting timestamp and repeat the final report. Compare event and timestamp within one RTP stream, then count digits delivered to the application. liberal-dtmf broadens reception compatibility. Validate a short press, a long press and two consecutive presses of the same key.

End test calls and move the XML outside the include path, then reloadxml. If you changed a profile or phone settings, restore the backups, restart the relevant profile in a test window and register again. Repeat the original 7101 and 7102 calls and the existing IVR test. Verify the lab destination no longer matches this route.

Sources


评论