Controlling Humpback-DDS can be achieved by sending specific MQTT commands through Mosquitto. The device will listen to all publishes that are under the `Urukul/Control` or `/Urukul/Control` topic. A MQTT message can be published by the following command.
This will send the MQTT message to a local MQTT broker at port 1883, with specified topic and message. The example above can be simplified into:
```shell
publish-mqtt Foo/Bar "baz"
```
## List of Commands
All currently supported commands are listed below.
**Note: The following table only lists the subtopic. To make a full topic, add `Urukul/Control` in front of all subtopics.**
Example: Full topic of Reset command: `Urukul/Control/Reset`.
| Subtopic| Message| Functionality|
| ---| ---| ---|
| `Reset`| | Reset the device|
| `ChannelX/Switch`| `<off/on>`| Turn off/on the RF switch at channel X.|
| `ChannelX/Attenuation`| `<atten> [dB]`| Set attenuation of channel X.|
| `Clock/Source`| `<clk_src>`| Select the clock source of Urukul.|
| `Clock/Frequency`| `<f_clk> [unit]`| Set the clock frequency of the clock source of Urukul.|
| `Clock/Source`| `<clk_div>`| Set the clock division of Urukul.|
| `Clock`| `frequency: <f_clk> [unit], source: <clk_src>, division: <clk_div>`| Setup the clock tree for Urukul.|
| `ChannelX/SystemClock`| `<f_sys_clk> [unit]`| Set the system clock frequency of channel X.|
| `ChannelX/ProfileY/Singletone/Frequency`| `<freq> [unit]`| Setup a single tone profile at channel X, profile Y, with frequency `<freq> [unit]`.|
| `ChannelX/ProfileY/Singletone/Amplitude`| `<ampl>`| Setup a single tone profile at channel X, profile Y, with amplitude factor `<ampl>`.|
| `ChannelX/ProfileY/Singletone/Phase`| `<phase> [deg]`| Setup a single tone profile at channel X, profile Y, with phase `<phase> [deg]`.|
| `ChannelX/ProfileY/Singletone`| `frequency: <freq> [unit], amplitude: <ampl>, phase: <phase>`| Setup a compelte single tone profile at channel X, profile Y.|
| `Profile`| `<pr_num>`| Switch to a DDS profile across all channels.|
## Reset the device
- Topic: `Urukul/Control/Reset`
- Message: (Don't care)
The `Reset` command resets the device. The effects are:
- Turn off all RF switches.
- Set attenuations to be 31.5 dB for all attenuators.
- Set Urukul clock source to be the internal oscillator, with 100MHz.
- Set Urukul clock divider to 4.
- Reset all 4 DDS chips.
### Example
```shell
publish-mqtt Urukul/Control/Reset
```
This resets the device.
## RF Switch
- Topic: `Urukul/Control/Channel<ch_num>/Switch`
- ch_num: The channel number, from 0 to 3.
- Message: `<off/on>`
This command turns off/on an RF switch of a channel.
- atten: Attenuation of the attenuator of the specified channel. The unit dB is optional. Valid attenuation is within [0, 31.5] (inclusive) in decibel.