> For the complete documentation index, see [llms.txt](https://prosbcdocs.telcobridges.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://prosbcdocs.telcobridges.com/telecom-references/protocols/cas-r1-e-and-m.md).

# CAS R1 E\&M

### Overview

The E\&M (often called "Wink Start") variants of CASR1 are "symmetrical" CASR1 variants (both sides use identical signaling and state machines, and calls can be made in both directions).

* Only bit A is used (generally replicated to bit B)
  * Idle ("on hook") pattern is to set bit A to 0
  * "Off hook" pattern is to set bit A to 1

Summary of the "wink start" call flow:

* Caller side goes "off hook"
* Receiver side "winks" (goes "off hook" for short period of \~200ms)
* Caller side detects "wink" and sends digits
* Receiver side receives digit (sends another "wink" in "Wink-start-ack" variant)
* Receiver side eventually goes "off hook"

Call termination:

* One side goes "on hook"
* Other side confirms with "on hook" too

### Supported E\&M variants

TelcoBridges provides a E\&M-compatible CAS script. You can find general documentation about CASR1 scripts in Toolpack in the following page: [CASr1\_scripting](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/isdn-cas/casr1-scripting/README.md).

The E\&M script provided by TelcoBridges already supports the following variants:

* Delay start
* Wink-start
* Wink-start-ack

Note that since this is a script, other variants may easily be added to this script by TelcoBridges or even by the user, with some knowledge of the LUA programming language.

### Configuration

#### Choosing variant

To specify a script to use E\&M, you MUST specify one of the following:

```
CasR1.Variant = CasR1.VariantTypes.DELAY_START
CasR1.Variant = CasR1.VariantTypes.WINK_START
CasR1.Variant = CasR1.VariantTypes.WINK_START_ACK
```

Depending upon whether you want to use 0, 1 or 2 winks.

#### Choosing tone type

With CAS R1, ANI/DNIS can be sent using either DTMF or MFR1 tones.

To specify the type of tones to use, use the following constant:

```
TONE_USE_DTMF			= 1
```

#### Configuring exchange of ANI/DNIS

* ANI stands for "Automic Number Identification" (or "calling number).
* DNIS stands for "Dialed Number Identification Service" (or "called number").

In the E\&M variants, ANI (calling number) is optional, while DNIS (called number) is most of the time mandatory (though in some cases may be omitted).

**Detection of ANI and/or DNIS**

Configuration of reception/transmission of ANI/DNIS is controlled by the following variables:

```
	ANI = {
		prefix = "",
		suffix = "",
		expected_digits = 0,
		inter_digit_timeout = 0,
	},

	DNIS = {
		prefix = "*",
		suffix = "#",
		expected_digits = 0,
		inter_digit_timeout = 5000,
	},
```

See [CAS MFR1 Mapping](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/isdn-cas/casr1-scripting/README.md#mfr1-mapping) to know valid prefix and suffix values.

Please read detailed information about configuration of ANI/DNIS reception and transmission using the variables above:

* [Options for sending ANI](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/isdn-cas/casr1-scripting/README.md#action-send-ani)
* [Options for receiving ANI](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/isdn-cas/casr1-scripting/README.md#action-wait-ani)

**Enabling/disabling usage of ANI**

To enable detection of ANI, enable one of the 3 detection methods above in the "ANI" configuration (prefix/suffix, expected number of digits, or inter-digit timeout).

If none is used, ANI won't be sent or received by the script.

**Enabling/disabling usage of DNIS**

To enable detection of DNIS, enable one of the 3 detection methods above in the "DNIS" configuration (prefix/suffix, expected number of digits, or inter-digit timeout).

If none is used, DNIS won't be sent or received by the script. Instead of a called number, the default E\&M script will store the trunk number and timeslot number, separated by digit 'A'. Format will be like 01A22 (meaning trunk number 1, timeslot 22)

### Subvariants

Here are the differences between the subvariants:

#### Delay Start

There's no wink before receiving ANI/DNIS. Instead, a fixed delay is inserted after going "off hook" and before sending the first digit. The following script constant defines that delay, and may be modified:

```
	OUTGOING_DELAY_TIMEOUT	= 500
```

#### Wink Start

There's 1 wink before exchanging ANI/DNIS. In that variant, ANI/DNIS tones will only be sent after detecting a Wink from the remote side. A Wink will be sent after detecting a remote "off hook" (new incoming call).

Wink duration can be configured by the following script constant (in milliseconds):

```
	INCOMING_WINK_DURATION 	= 200
```

#### Wink Start ACK

There's 1 wink before receiving ANI/DNIS. There's 1 wink after receiving ANI/DNIS.

### Detailed information about the E\&M script and state machines

For more detailed information about how this script is implemented (various states, and options), please refer to the "e\_m.lua" script provided with Toolpack.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://prosbcdocs.telcobridges.com/telecom-references/protocols/cas-r1-e-and-m.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
