This example demonstrates an IEEE802.15.4 Command Line. The IEEE802.15.4 CLI exposes configuration and management APIs via a command line interface.
## How to use example
### Hardware Required
To run this example, a board with IEEE 802.15.4 module (for example ESP32-H2) is required.
### Configure the project
```
idf.py menuconfig
```
The example can run with the default configuration. IEEE802.15.4 Command Line is enabled with UART as the default interface. Additionally, USB JTAG is also supported and can be activated through the menuconfig:
```
Component config → ESP System Settings → Channel for console output → USB Serial/JTAG Controller
```
### Build, Flash, and Run
Build the project and flash it to the board, then run monitor tool to view serial output:
```
idf.py -p PORT build flash monitor
```
Now you'll get an IEEE802.15.4 command line shell.
## IEEE802.15.4 Command List
- [cca](#cca)
- [channel](#channel)
- [coordinator](#coordinator)
- [ed](#ed)
- [esp154](#esp154)
- [extaddr](#extaddr)
- [free](#free)
- [heap](#heap)
- [panid](#panid)
- [pending](#pending)
- [promisc](#promisc)
- [reg](#reg)
- [restart](#restart)
- [rx](#rx)
- [shortaddr](#shortaddr)
- [tx](#tx)
- [txpower](#txpower)
- [version](#version)
- [help](#help)
## IEEE802.15.4 Command Details
Most of the commands are available in both full and abbreviated form.
For example, to enable the receive mode, both `rx -r 1` and `rx --receive=1` are valid
```bash
> rx -r 1
I (4227508) i154cmd: RX Start
> rx --receive=1
I (4249898) i154cmd: RX Start
```
Only abbreviated formats are described below.
### cca
#### cca -g
Get the cca cfg.
```bash
> cca -g
I (2676818) i154cmd: threshold:-60 dB, mode: 1
```
#### cca -m \<mode\>
Set the cca mode.
* 0: carrier
* 1: ED
* 2: carrier or ED
* 3: carrier and ED
```bash
> cca -m 1
I (5047618) i154cmd: set cca mode as: 1
```
#### cca -v \<value\>
Set the cca threshold.
```bash
> cca -v 60
I (4731648) i154cmd: set cca threshold as: 60
```
### channel
#### channel -g
Get the channel number.
```bash
> channel -g
I (67238) i154cmd: current channel: 11
```
#### channel -s \<n\>
Set the channel number.
```bash
> channel -s 21
I (220268) i154cmd: set channel: 21
```
### coordinator
#### coordinator -d
Enable the coordinator.
```bash
> coordinator -d
I (438228) i154cmd: hardware coordinator is disabled
```
#### coordinator -e
Disable the coordinator.
```bash
> coordinator -e
I (453288) i154cmd: hardware coordinator is enabled
```
#### coordinator -g
Get the coordinator.
```bash
> coordinator -g
I (472398) i154cmd: hardware coordinator was enabled
```
### ed
#### ed -d \<duration\>
Configure the duration of energy detection.
```bash
> ed -d 2
I (668548) i154cmd: ed start
I (668548) i154cmd: ed_scan_rss_value: -98 dB
I (472398) i154cmd: hardware coordinator was enabled
```
### esp154
#### esp154 -e
Enable initialize the IEEE 802.15.4 subsystem.
```bash
> esp154 -e
I (87127) i154cmd: initialize the IEEE 802.15.4 subsystem
```
#### esp154 -d
Disable initialize the IEEE 802.15.4 subsystem.
```bash
> esp154 -d
I (97107) i154cmd: deinitialize the IEEE 802.15.4 subsystem
```
### extaddr
#### extaddr \<extaddr\>
Set the device extended address.
```bash
> extaddr 0xaa 0xbb 0xcc 0xdd 0x00 0x11 0x22 0x33
I (704937) i154cmd: set extaddr: 33221100ddccbbaa
```
#### extaddr -g
Get the device extended address.
```bash
> extaddr -g
I (615587) i154cmd: get extaddr: 0807060504030201
```
### free
Get the current size of free heap memory.
```bash
> free
235024
```
### heap
Get minimum size of free heap memory that was available during program execution.
```bash
> heap
min heap size: 231076
```
### panid
#### panid \<panid\>
Set the device Pan ID.
```bash
> panid 0x1234
I (1112117) i154cmd: set panid: 0x1234
```
#### panid -g
Get the device Pan ID.
```bash
> panid -g
I (1128457) i154cmd: current panid: 0x1234
```
### pending
#### pending \<addr\>
Add the address to pending table (2 bytes for short address, 8 bytes for extended address).
```bash
> pending 0x34 0x12
I (1806327) i154cmd: add pending shortaddr: 0x1234
```
#### pending -m \<mode\>
Set the autopending mode.
* 0: disable
* 1: enable
* 2: enhanced
```bash
> pending -m 1
I (1828817) i154cmd: set auto pending mode as: 1
```
#### pending -g
Get the autopending mode.
```bash
> pending -g
I (2007797) i154cmd: get auto pending mode as: 1
```
#### pending -r
Reset the pending address table.
```bash
> pending -r
I (2113377) i154cmd: clear the pending address table
```
#### pending -d <addr>
Delete the address from pending table (2 bytes for short address, 8 bytes for extended address).
```bash
> pending -d 0x34 -d 0x12
I (2322787) i154cmd: delete pending shortaddr: 0x1234
```
### promisc
#### promisc [-edg]
* e: Enable the promiscuous mode.
* d: Disable the promiscuous mode.
* g: Get the promiscuous mode.
```bash
> promisc -e
I (2599357) i154cmd: promiscuous mode is enabled
> promisc -d
I (2600977) i154cmd: promiscuous mode is disabled
> promisc -g
I (2602927) i154cmd: hardware promiscuous mode was disabled