# Command and Control (CaC) Tool

The [Command and Control (CaC) Tool](https://casttool.appspot.com/cactool/) is
a functional web sender for developers to test and debug a Web Receiver application.

Developers can use the CaC Tool to:

- Launch a Web Receiver app on a Cast-enabled device and send a load request to start media playback.
- Simulate [voice commands](https://developers.google.com/cast/docs/caf_receiver/core_features#voice_commands) sent by Google Assistant to the Web Receiver.
- Capture logs from [Cast Debug Logger](https://developers.google.com/cast/docs/debugging/cast_debug_logger) and control the Web Receiver debug overlay.

## Launch Web Receiver app

There are two ways to launch your Web Receiver with the CaC Tool:

1. To start a new Cast session:

   1. Open the CaC Tool, enter your Web Receiver App ID and click the **SET APP ID** button.
   2. Click on the Cast button and select a device to launch the Web Receiver
      on a remote Cast-enabled device.

      ![](https://developers.google.com/static/cast/images/cac_tool/cac_set_appid.png)
2. To join an existing Cast session:

   1. Get the running Cast session ID by using the following codes:

      From the Web Receiver side, use the following method to get session ID in
      the [Chrome Remote Debugger](https://developers.google.com/cast/docs/debugging/remote_debugger) console:

          cast.framework.CastReceiverContext.getInstance().getApplicationData().sessionId;

      Or to get the session ID from a connected Web Sender, use the following
      method:

          cast.framework.CastContext.getInstance().getCurrentSession().getSessionId();

   2. Enter the session ID in the CaC Tool and click the **RESUME** button.

      ![](https://developers.google.com/static/cast/images/cac_tool/cac_resume_session.png)

When the CaC Tool is connected to the Web Receiver app, the Cast button appears
with a filled frame shape. The Web Receiver app ID and session ID are also
displayed at the top of the tool.

![](https://developers.google.com/static/cast/images/cac_tool/cac_connected.png)

## Load media

Load media from either your sender app or the CaC Tool.

![](https://developers.google.com/static/cast/images/cac_tool/cac_load_media.png)

### Sender app

To start media playback on your Web Receiver, cast your sender app to the
same Cast-enabled device and send a load request from your sender app to the
Web Receiver.

> [!NOTE]
> **Note:** Make sure the sender app is using the same Web Receiver application ID as the one in the CaC Tool.

### CaC Tool

The CaC Tool also provides multiple ways to send a load request to the Web
Receiver app:

#### Load by entity (voice casting)

When users initiate media playback through Google Assistant, Google Assistant
uses Command and Control (CaC) messages to send user credentials and entity to
your Web Receiver.

The CaC Tool simulates voice casting and sends a load request with `credentials`
and `entity`.

#### Load by content

The CaC Tool can also simulate your app sending a load request with `Content ID`
or `Content Url`.

> [!NOTE]
> **Note:** We suggest you use `entity` in your implementation for both your sender and Web Receiver apps. For more information, see [Tip: Loading media using contentId, contentUrl and entity](https://developers.google.com/cast/docs/caf_receiver/core_features#tip_loading_media_using_contentid_contenturl_and_entity).

When a media playback starts, the CaC Tool receives Media Status messages from
your Web Receiver app and displays them on the **MEDIA STATUS** tab.

![](https://developers.google.com/static/cast/images/cac_tool/cac_media_status.png)

#### Custom Load Request

If you would like to test your receiver using your own `Load Request` objects, use
the **Custom Load Request** field under the **LOAD MEDIA** tab. First, select
the type of request from the **Select Request Type** radio buttons and then copy-paste
or build your own JSON object.

> [!NOTE]
> **Note:** The editor supports the use of `Tab` key for indentation and formatting.

## Test voice commands

The CaC Tool also simulates
[voice commands](https://developers.google.com/cast/docs/caf_receiver/core_features#voice_commands) sent by
Google Assistant to your Web Receiver app. You can test if the media commands
that your app supported are working properly. Non-supported media commands must
be handled with appropriate
[error type and error reasons](https://developers.google.com/cast/docs/caf_receiver/core_features#error_handling).

![](https://developers.google.com/static/cast/images/cac_tool/cac_media_commands.png)

## Inspect and control Cast Debug Logger

If your Web Receiver app enables
[Cast Debug Logger](https://developers.google.com/cast/docs/debugging/cast_debug_logger), the CaC Tool
captures the log messages and controls the Web Receiver debug overlay.

Use the following buttons to control the Web Receiver and log messages:

- Web Receiver App ID
  - **Clear Cache and Stop Web Receiver** - Reload the Web Receiver app and stop casting
- Web Receiver Debug Overlay
  - **Show** - Toggle the debug overlay on the Web Receiver
  - **Clear** - Clear log messages on the Web Receiver debug overlay
- Log Message Controls
  - **Insert Message** - Insert comments or dividers to the log area
  - **Download Log** - Save log messages
  - **Clear Log** - Clear log messages on the log area
- Log Messages
  - **Custom Tags** - Click the checkbox to filter log messages

![](https://developers.google.com/static/cast/images/cac_tool/cac_debug_overlay.png)

Following tags might appear under the **Custom Tags**. These are added by the
CaC Tool to show and filter important logs or messages pertaining to the
debugging session:

- **MEDIA** - Messages successfully sent over the Media namespace
- **MEDIA-ERROR** - Error occurred while sending, or in response to messages sent over the Media namespace
- **CAC** - Messages successfully sent over the CAC namespace
- **CAC-ERROR** - Error occurred while sending, or in response to messages sent over the CAC namespace
- **PLAYING** - Log displaying the result when the **What's Playing** button is clicked in the CaC Tool
- **USER** - Log displaying custom message entered by User with **Insert Message** button in CaC Tool

## Test Cast Connect

To test Cast Connect, perform the following steps before establishing a session:

1. Enter the Receiver App ID associated with your Cast Connect-enabled receiver and click **Set App ID**.
2. Click on **Show Android TV Options** button.
3. Check **androidReceiverCompatible** checkbox. If your receiver doesn't require `Launch Credentials` to be set, or you want to test what happens in case it is not set, you can stop here and continue to Step 5.
4. (Optional) Enter the `Launch Credentials` and click on the **Set Launch
   Credentials** button in order to set the launch credentials for the Cast Connect session.
5. Start a cast session by clicking on the Cast icon in the header or through the Cast menu in your Chrome browser.

![](https://developers.google.com/static/cast/images/cac_tool/cac_android_receiver_options.png)

Your Android TV application should now launch on your device.

> [!NOTE]
> **Note:** CaC Tool is unable to fetch any logs from your Android TV device. In order to debug your Android TV app and see any relevant logs, use `adb` through your terminal or Android Studio, as you normally would in order to access the logs and debug your app.