feat(ieee802154): Add ieee802154 CLI example

This commit is contained in:
Xu Si Yu 2023-10-11 19:41:20 +08:00
parent a532a648b1
commit 13fa6c7af2
20 changed files with 555 additions and 124 deletions

View File

@ -173,6 +173,7 @@
/examples/cxx/ @esp-idf-codeowners/system /examples/cxx/ @esp-idf-codeowners/system
/examples/ethernet/ @esp-idf-codeowners/network /examples/ethernet/ @esp-idf-codeowners/network
/examples/get-started/ @esp-idf-codeowners/system /examples/get-started/ @esp-idf-codeowners/system
/examples/ieee802154/ @esp-idf-codeowners/ieee802154
/examples/mesh/ @esp-idf-codeowners/wifi /examples/mesh/ @esp-idf-codeowners/wifi
/examples/network/ @esp-idf-codeowners/network @esp-idf-codeowners/wifi /examples/network/ @esp-idf-codeowners/network @esp-idf-codeowners/wifi
/examples/openthread/ @esp-idf-codeowners/ieee802154 /examples/openthread/ @esp-idf-codeowners/ieee802154

View File

@ -1830,19 +1830,6 @@
- <<: *if-dev-push - <<: *if-dev-push
changes: *patterns-target_test-adc changes: *patterns-target_test-adc
.rules:test:component_ut-esp32c6-i154:
rules:
- <<: *if-revert-branch
when: never
- <<: *if-protected
- <<: *if-label-build-only
when: never
- <<: *if-label-component_ut
- <<: *if-label-component_ut_esp32c6
- <<: *if-label-target_test
- <<: *if-dev-push
changes: *patterns-component_ut-i154
.rules:test:component_ut-esp32h2: .rules:test:component_ut-esp32h2:
rules: rules:
- <<: *if-revert-branch - <<: *if-revert-branch

View File

@ -1306,12 +1306,12 @@ pytest_components_esp32c6_adc:
artifacts: false artifacts: false
tags: [ esp32c6, adc ] tags: [ esp32c6, adc ]
pytest_components_esp32c6_i154: pytest_examples_esp32c6_i154:
extends: extends:
- .pytest_components_dir_template - .pytest_examples_dir_template
- .rules:test:component_ut-esp32c6-i154 - .rules:test:example_test-esp32c6
needs: needs:
- job: build_pytest_components_esp32c6 - job: build_pytest_examples_esp32c6
artifacts: false artifacts: false
tags: [ esp32c6, ieee802154 ] tags: [ esp32c6, ieee802154 ]

View File

@ -1,5 +0,0 @@
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
components/ieee802154/test_apps/test_ieee802154:
enable:
- if: IDF_TARGET == "esp32c6"

View File

@ -1,3 +0,0 @@
| Supported Targets | ESP32-C6 |
| ----------------- | -------- |

View File

@ -1,4 +0,0 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET_ESP32C6=y

View File

@ -14,6 +14,7 @@ The examples are grouped into subdirectories by category. Each category director
- `cxx` C++ language utilization examples and experimental components. - `cxx` C++ language utilization examples and experimental components.
- `ethernet` Ethernet network examples. - `ethernet` Ethernet network examples.
- `get-started` Simple examples with minimal functionality. Good start point for beginners. - `get-started` Simple examples with minimal functionality. Good start point for beginners.
- `ieee802154` IEEE802.15.4 examples.
- `mesh` Wi-Fi Mesh examples. - `mesh` Wi-Fi Mesh examples.
- `network` Examples related to general network environment, test & analysis. - `network` Examples related to general network environment, test & analysis.
- `openthread` OpenThread examples. - `openthread` OpenThread examples.

View File

@ -0,0 +1,19 @@
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
.ieee802154_dependencies: &ieee802154_dependencies
depends_components:
- esp_coex
- esp_phy
- ieee802154
depends_filepatterns:
- examples/ieee802154/**/*
- examples/system/console/advanced/components/cmd_system/**/*
examples/ieee802154/ieee802154_cli:
enable:
- if: SOC_IEEE802154_SUPPORTED == 1
disable_test:
- if: IDF_TARGET == "esp32h2"
temporary: true
reason: only test on esp32c6
<<: *ieee802154_dependencies

View File

@ -0,0 +1,9 @@
# IEEE802.15.4 Examples
See the [README.md](../README.md) file in the upper level [examples](../) directory for more information about examples.
## Overview
In this folder, it contains following IEEE802.15.4 examples:
* [ieee802154_cli](ieee802154_cli) is an IEEE802.15.4 Command Line example, the commands it supports are listed in [README.md](./ieee802154_cli//README.md). It runs on an 802.15.4 SoC like ESP32-H2.

View File

@ -6,4 +6,4 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake)
# "Trim" the build. Include the minimal set of components, main, and anything it depends on. # "Trim" the build. Include the minimal set of components, main, and anything it depends on.
set(COMPONENTS main) set(COMPONENTS main)
project(test_ieee802154) project(ieee802154_cli)

View File

@ -0,0 +1,476 @@
| Supported Targets | ESP32-C6 | ESP32-H2 |
| ----------------- | -------- | -------- |
# IEEE802.15.4 Command Line Example
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
```
### reg
#### reg -w \<address\> -v \<value\>
Write the register \<address\> with \<value\>.
```bash
> reg -w 0x0184 -v 0x00
I (103917) i154cmd: write reg 0x184: 0x1234
```
#### reg -r \<address\>
Read the register \<address\>.
```bash
> reg -r 0x0184
I (220967) i154cmd: reg 0x184 value: 0x1234
```
### restart
Restart the program.
### rx
#### rx -r \<mode\>
Configure the radio receive mode.
* 0: disable
* 1: enable
```bash
> rx -r 1
I (121977) i154cmd: RX Start
> rx -r 0
I (127267) i154cmd: radio exit receive mode
```
### shortaddr
#### shortaddr \<shortaddr\>
set the device short address.
```bash
> shortaddr 0x1234
I (543167) i154cmd: set shortaddr: 0x1234
```
#### shortaddr -g
```bash
> shortaddr -g
I (568387) i154cmd: current shortaddr: 0x1234
```
### tx
#### tx \<n\>
Transmit IEEE 802154 MAC frame.
* -C: Set cca trigging tx mode true.
```bash
> tx 0x00 0x11 0x22 0x33 0x44 0x55 0x66 0x77
I (6399947) i154cmd: tx sfd done, Radio state: 4
I (6399957) i154cmd: Tx Done 8 bytes
I (6399957) i154cmd: 00 11 22 33 44 55 66 77
> tx 0x00 0x11 0x22 0x33 0x44 0x55 0x66 0x77 -C
I (6580547) i154cmd: tx sfd done, Radio state: 4
I (6580547) i154cmd: Tx Done 8 bytes
I (6580547) i154cmd: 00 11 22 33 44 55 66 77
```
#### tx -l \<len\>
Transmit IEEE 802154 MAC frame wich has a length=\<len\>.
* -C: Set cca trigging tx mode true.
```bash
> tx -l 10
I (6721867) i154cmd: tx sfd done, Radio state: 4
I (6721867) i154cmd: Tx Done 10 bytes
I (6721867) i154cmd: 00 01 02 03 04 05 06 07
I (6721867) i154cmd: 08 09 00 00 00 00 00 00
> tx -l 10 -C
I (6726067) i154cmd: tx sfd done, Radio state: 4
I (6726067) i154cmd: Tx Done 10 bytes
I (6726067) i154cmd: 00 01 02 03 04 05 06 07
I (6726067) i154cmd: 08 09 00 00 00 00 00 00
```
### txpower
#### txpower -g
Get the txpower.
```bash
> txpower -g
I (7100077) i154cmd: current txpower: 20
```
#### txpower -s \<n\>
Set the txpower.
```bash
> txpower -s 40
I (7116217) i154cmd: set txpower: 40
```
### version
Get version of chip and SDK.
```bash
> version
IDF Version:v5.3-dev-699-gb94f6ef680-dirty
Chip info:
model:ESP32-H2
cores:1
feature:/BLE/External-Flash:2 MB
revision number:1
```
### help
Get the summary of all registered commands.
```bash
> help
cca [-g] [-v <threshold>] [-m <mode>]
cca config
-v, --value=<threshold> cca threshold setting
-m, --mode=<mode> cca mode, 0: carrier; 1: ED; 2: carrier or ED; 3: carrier and ED
-g, --get get the cca cfg
channel [-g] [-s <n>]
get/set the channel number
-g, --get get channel number
-s, --set=<n> set channel number
coordinator [-edg]
enable/disable/get the coordinator
-e, --enable enable the coordinator
-d, --disable disable the coordinator
-g, --get get the coordinator
ed [-d <duration>]
configure the duration
-d, --duration=<duration> configure the duration of energy detection
esp154 [-ed]
enable/disable initialize the IEEE 802.15.4 subsystem
-e, --enable initialize the IEEE 802.15.4 subsystem
-d, --disable deinitialize the IEEE 802.15.4 subsystem
extaddr [-g] [<extaddr>]...
set/get the device extended address
-g, --get get the device extended address
<extaddr> set the device extended address
free
Get the current size of free heap memory
heap
Get minimum size of free heap memory that was available during program
execution
help [<string>]
Print the summary of all registered commands if no arguments are given,
otherwise print summary of given command.
<string> Name of command
log_level <tag|*> <none|error|warn|debug|verbose>
Set log level for all tags or a specific tag.
<tag|*> Log tag to set the level for, or * to set for all tags
<none|error|warn|debug|verbose> Log level to set. Abbreviated words are accepted.
panid [-g] [<panid>]
get/set the device Pan ID
<panid> set the device Pan ID
-g, --get get the device Pan ID
pending [-gr] [-m <mode>] [<addr>]... [-d <addr>]...
configure the pending address table
-m, --mode=<mode> set the autopending mode (0: disable; 1: enable; 2: enhanced)
-g, --get get the autopending mode (0: disable; 1: enable; 2: enhanced)
-r, --reset reset the pending address table
<addr> add the address to pending table (2 bytes for short address, 8 bytes for extended address)
-d, --delete=<addr> delete the address from pending table (2 bytes for short address, 8 bytes for extended address)
promisc [-edg]
enable/disable/get the promiscuous mode
-e, --enable enable the promiscuous mode
-d, --disable disable the promiscuous mode
-g, --get get the promiscuous mode
reg [-r <address>] [-w <address>] [-v <value>]
read/write the register
-r, --read=<address> read the register value
-w, --write=<address> register address to be written
-v, --value=<value> register value to be written
restart
Software reset of the chip
rx [-r <mode>]
enable/disable the receive mode
-r, --receive=<mode> configure the radio receive mode, 0: disable; 1: enable
shortaddr [-g] [<shortaddr>]
get/set the device short address
<shortaddr> set the device short address
-g, --get get the device short address
tx [-C] [-l <len>] [<n>]... [-o <offset>]
transmit IEEE 802154 MAC frame
-l, --length=<len> frame length
-C, --cca_enable set cca trigging tx mode true
<n> transmit raw frame
-o, --offset=<offset> tx buffer offset
txpower [-g] [-s <n>]
get/set the txpower
-g, --get get txpower
-s, --set=<n> set txpower,value range -80dBm~-10dBm
version
Get version of chip and SDK
```
#### help \<command\>
Get the summary of given command.
```bash
> help tx
tx [-C] [-l <len>] [<n>]... [-o <offset>]
transmit IEEE 802154 MAC frame
-l, --length=<len> frame length
-C, --cca_enable set cca trigging tx mode true
<n> transmit raw frame
-o, --offset=<offset> tx buffer offset
```

View File

@ -0,0 +1,3 @@
idf_component_register(SRCS "ieee802154_cmd.c"
INCLUDE_DIRS "."
PRIV_REQUIRES ieee802154 console esp_phy)

View File

@ -18,7 +18,7 @@
#include "soc/ieee802154_reg.h" #include "soc/ieee802154_reg.h"
static uint8_t s_tx_frame[131] = { 0 }; static uint8_t s_tx_frame[131] = { 0 };
static const char* TAG = "i154test"; static const char* TAG = "i154cmd";
static void register_rx(void); static void register_rx(void);
static void register_tx(void); static void register_tx(void);
@ -34,8 +34,6 @@ static void register_pending(void);
static void register_cca(void); static void register_cca(void);
static void register_esp154(void); static void register_esp154(void);
static void register_reg(void); static void register_reg(void);
static void register_free(void);
static void register_restart(void);
void register_ieee802154_cmd(void) void register_ieee802154_cmd(void)
{ {
@ -53,8 +51,6 @@ void register_ieee802154_cmd(void)
register_cca(); register_cca();
register_esp154(); register_esp154();
register_reg(); register_reg();
register_free();
register_restart();
} }
static struct { static struct {
@ -78,8 +74,8 @@ static int process_energy(int argc, char **argv)
ESP_LOGI(TAG, "ed start"); ESP_LOGI(TAG, "ed start");
esp_ieee802154_energy_detect(duration); esp_ieee802154_energy_detect(duration);
} else { } else {
ESP_LOGE(TAG, "no valid arguments"); ESP_LOGE(TAG, "no valid arguments");
return 1; return 1;
} }
} else { } else {
ESP_LOGE(TAG, "no valid arguments"); ESP_LOGE(TAG, "no valid arguments");
@ -364,7 +360,7 @@ static int process_extaddr(int argc, char **argv)
} else if (extaddr_args.get_extaddr->count) { } else if (extaddr_args.get_extaddr->count) {
esp_ieee802154_get_extended_address(extaddr); esp_ieee802154_get_extended_address(extaddr);
ESP_LOGI(TAG, "get extaddr: %02x%02x%02x%02x%02x%02x%02x%02x", extaddr[7], extaddr[6], extaddr[5], extaddr[4], ESP_LOGI(TAG, "get extaddr: %02x%02x%02x%02x%02x%02x%02x%02x", extaddr[7], extaddr[6], extaddr[5], extaddr[4],
extaddr[3], extaddr[2], extaddr[1], extaddr[0]); extaddr[3], extaddr[2], extaddr[1], extaddr[0]);
} else { } else {
ESP_LOGE(TAG, "no valid arguments"); ESP_LOGE(TAG, "no valid arguments");
} }
@ -640,38 +636,6 @@ static void register_esp154()
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd)); ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
} }
/* 'fheap' command check for memory leaks */
static struct {
struct arg_end *end;
} free_args;
static int process_free(int argc, char **argv)
{
int nerrors = arg_parse(argc, argv, (void **) &free_args);
if (nerrors != 0) {
arg_print_errors(stderr, free_args.end, argv[0]);
return 1;
}
esp_get_free_heap_size();
ESP_LOGI(TAG, "heap size: %" PRIu32, esp_get_free_heap_size());
return 0;
}
static void register_free()
{
free_args.end = arg_end(2);
const esp_console_cmd_t cmd = {
.command = "fheap",
.help = "get the size of heap memory",
.hint = NULL,
.func = &process_free,
.argtable = &free_args
};
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
}
/* 'reg' command reads/writes the registers */ /* 'reg' command reads/writes the registers */
static struct { static struct {
struct arg_int *get_reg; struct arg_int *get_reg;
@ -766,7 +730,7 @@ static int process_tx(int argc, char **argv)
if (tx_args.cca_enable->count) { if (tx_args.cca_enable->count) {
cca = true; cca = true;
} }
memcpy(s_tx_frame+offset, tx_frame, sizeof(tx_frame)); memcpy(s_tx_frame + offset, tx_frame, sizeof(tx_frame));
esp_ieee802154_transmit(s_tx_frame, cca); esp_ieee802154_transmit(s_tx_frame, cca);
return 0; return 0;
} }
@ -841,51 +805,30 @@ static void register_rx(void)
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd)); ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
} }
/* 'restart' command restarts the program */ static void esp_ieee802154_frame_print(const uint8_t *frame)
static int restart(int argc, char **argv)
{ {
ESP_EARLY_LOGI(TAG, "Restarting"); for (uint8_t idx = 1; idx < frame[0]; idx += 8) {
esp_restart(); ESP_EARLY_LOGI(TAG, "%02x %02x %02x %02x %02x %02x %02x %02x",
} frame[idx], frame[idx + 1], frame[idx + 2], frame[idx + 3],
frame[idx + 4], frame[idx + 5], frame[idx + 6], frame[idx + 7]);
static void register_restart(void) }
{
const esp_console_cmd_t cmd = {
.command = "restart",
.help = "Restart the program",
.hint = NULL,
.func = &restart
};
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
} }
void esp_ieee802154_transmit_done(const uint8_t *frame, const uint8_t *ack, esp_ieee802154_frame_info_t *ack_frame_info) void esp_ieee802154_transmit_done(const uint8_t *frame, const uint8_t *ack, esp_ieee802154_frame_info_t *ack_frame_info)
{ {
ESP_EARLY_LOGI(TAG, "Tx Done %d bytes", frame[0]); ESP_EARLY_LOGI(TAG, "Tx Done %d bytes", frame[0]);
for(uint8_t idx = 1; idx < frame[0]; idx+=8) { esp_ieee802154_frame_print(frame);
ESP_EARLY_LOGI(TAG, "%02x %02x %02x %02x %02x %02x %02x %02x",
frame[idx], frame[idx+1], frame[idx+2], frame[idx+3],
frame[idx+4], frame[idx+5], frame[idx+6], frame[idx+7]);
}
if (ack != NULL) { if (ack != NULL) {
ESP_EARLY_LOGI(TAG, "Rx ack %d bytes", ack[0]); ESP_EARLY_LOGI(TAG, "Rx ack %d bytes", ack[0]);
for(uint8_t idx = 1; idx < ack[0]; idx+=8) { esp_ieee802154_frame_print(ack);
ESP_EARLY_LOGI(TAG, "%02x %02x %02x %02x %02x %02x %02x %02x",
ack[idx], ack[idx+1], ack[idx+2], ack[idx+3],
ack[idx+4], ack[idx+5], ack[idx+6], ack[idx+7]);
}
} }
} }
void esp_ieee802154_receive_done(uint8_t *frame, esp_ieee802154_frame_info_t *frame_info) void esp_ieee802154_receive_done(uint8_t *frame, esp_ieee802154_frame_info_t *frame_info)
{ {
ESP_EARLY_LOGI(TAG, "Rx Done %d bytes", frame[0]); ESP_EARLY_LOGI(TAG, "Rx Done %d bytes", frame[0]);
for(uint8_t idx = 1; idx < frame[0]; idx+=8) { esp_ieee802154_frame_print(frame);
ESP_EARLY_LOGI(TAG, "%02x %02x %02x %02x %02x %02x %02x %02x",
frame[idx], frame[idx+1], frame[idx+2], frame[idx+3],
frame[idx+4], frame[idx+5], frame[idx+6], frame[idx+7]);
}
} }
void esp_ieee802154_energy_detect_done(int8_t power) void esp_ieee802154_energy_detect_done(int8_t power)

View File

@ -1,5 +1,4 @@
set(srcs "test_app_main.c" set(srcs "esp_ieee802154_cli.c")
"src/ieee802154_cmd.c")
set(include "." set(include "."
"include") "include")
@ -7,6 +6,5 @@ set(include "."
# In order for the cases defined by `TEST_CASE` to be linked into the final elf, # In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE # the component can be registered as WHOLE_ARCHIVE
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
INCLUDE_DIRS include PRIV_REQUIRES ieee802154 console fatfs nvs_flash esp_phy cmd_ieee802154 cmd_system
PRIV_REQUIRES ieee802154 console fatfs nvs_flash esp_phy
WHOLE_ARCHIVE) WHOLE_ARCHIVE)

View File

@ -5,6 +5,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "ieee802154_cmd.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_log.h" #include "esp_log.h"
#include "esp_console.h" #include "esp_console.h"
@ -14,7 +15,7 @@
#include "nvs_flash.h" #include "nvs_flash.h"
#include "esp_ieee802154.h" #include "esp_ieee802154.h"
#include "esp_phy_init.h" #include "esp_phy_init.h"
#include "ieee802154_cmd.h" #include "cmd_system.h"
#define PROMPT_STR "ieee802154" #define PROMPT_STR "ieee802154"
@ -22,7 +23,7 @@ static void initialize_nvs(void)
{ {
esp_err_t err = nvs_flash_init(); esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) { if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK( nvs_flash_erase() ); ESP_ERROR_CHECK(nvs_flash_erase());
err = nvs_flash_init(); err = nvs_flash_init();
} }
ESP_ERROR_CHECK(err); ESP_ERROR_CHECK(err);
@ -44,6 +45,7 @@ void app_main(void)
/* Register commands */ /* Register commands */
esp_console_register_help_command(); esp_console_register_help_command();
register_ieee802154_cmd(); register_ieee802154_cmd();
register_system_common();
esp_console_dev_uart_config_t hw_config = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT(); esp_console_dev_uart_config_t hw_config = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_console_new_repl_uart(&hw_config, &repl_config, &repl)); ESP_ERROR_CHECK(esp_console_new_repl_uart(&hw_config, &repl_config, &repl));

View File

@ -0,0 +1,4 @@
## IDF Component Manager Manifest File
dependencies:
cmd_system:
path: ${IDF_PATH}/examples/system/console/advanced/components/cmd_system

View File

@ -148,7 +148,7 @@ def test_based_txrx(dut: Tuple[IdfDut, IdfDut]) -> None:
@pytest.mark.esp32c6 @pytest.mark.esp32c6
@pytest.mark.generic @pytest.mark.ieee802154
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config', ['release',], 'config', ['release',],
indirect=True indirect=True
@ -162,7 +162,7 @@ def test_based_energy(dut: IdfDut) -> None:
@pytest.mark.esp32c6 @pytest.mark.esp32c6
@pytest.mark.generic @pytest.mark.ieee802154
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config', ['release',], 'config', ['release',],
indirect=True indirect=True
@ -177,7 +177,7 @@ def test_based_channel(dut: IdfDut) -> None:
@pytest.mark.esp32c6 @pytest.mark.esp32c6
@pytest.mark.generic @pytest.mark.ieee802154
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config', ['release',], 'config', ['release',],
indirect=True indirect=True
@ -192,7 +192,7 @@ def test_based_txpower(dut: IdfDut) -> None:
@pytest.mark.esp32c6 @pytest.mark.esp32c6
@pytest.mark.generic @pytest.mark.ieee802154
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config', ['release',], 'config', ['release',],
indirect=True indirect=True
@ -211,7 +211,7 @@ def test_based_promiscuous(dut: IdfDut) -> None:
@pytest.mark.esp32c6 @pytest.mark.esp32c6
@pytest.mark.generic @pytest.mark.ieee802154
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config', ['release',], 'config', ['release',],
indirect=True indirect=True
@ -226,7 +226,7 @@ def test_based_panid(dut: IdfDut) -> None:
@pytest.mark.esp32c6 @pytest.mark.esp32c6
@pytest.mark.generic @pytest.mark.ieee802154
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config', ['release',], 'config', ['release',],
indirect=True indirect=True
@ -241,7 +241,7 @@ def test_based_shortaddr(dut: IdfDut) -> None:
@pytest.mark.esp32c6 @pytest.mark.esp32c6
@pytest.mark.generic @pytest.mark.ieee802154
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config', ['release',], 'config', ['release',],
indirect=True indirect=True
@ -256,7 +256,7 @@ def test_based_extaddr(dut: IdfDut) -> None:
@pytest.mark.esp32c6 @pytest.mark.esp32c6
@pytest.mark.generic @pytest.mark.ieee802154
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config', ['release',], 'config', ['release',],
indirect=True indirect=True
@ -275,7 +275,7 @@ def test_based_coordinator(dut: IdfDut) -> None:
@pytest.mark.esp32c6 @pytest.mark.esp32c6
@pytest.mark.generic @pytest.mark.ieee802154
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config', ['release',], 'config', ['release',],
indirect=True indirect=True
@ -296,7 +296,7 @@ def test_based_pending(dut: IdfDut) -> None:
@pytest.mark.esp32c6 @pytest.mark.esp32c6
@pytest.mark.generic @pytest.mark.ieee802154
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config', ['release',], 'config', ['release',],
indirect=True indirect=True
@ -580,7 +580,7 @@ def test_based_transmit_failed(dut: IdfDut) -> None:
@pytest.mark.esp32c6 @pytest.mark.esp32c6
@pytest.mark.generic @pytest.mark.ieee802154
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config', ['release',], 'config', ['release',],
indirect=True indirect=True
@ -588,15 +588,15 @@ def test_based_transmit_failed(dut: IdfDut) -> None:
def test_based_initialize(dut: IdfDut) -> None: def test_based_initialize(dut: IdfDut) -> None:
transmit = dut transmit = dut
transmit.expect('ieee802154>', timeout=10) transmit.expect('ieee802154>', timeout=10)
transmit.write('fheap') transmit.write('heap')
fst_data = transmit.expect(r'heap size: [0-9]+', timeout=10)[0].decode() fst_data = transmit.expect(r'min heap size: [0-9]+', timeout=10)[0].decode()
fst_size = re.findall(r'heap size: ([0-9]+)', fst_data) fst_size = re.findall(r'min heap size: ([0-9]+)', fst_data)
transmit.write('esp154 -e') transmit.write('esp154 -e')
transmit.expect('initialize the IEEE 802.15.4 subsystem', timeout=10) transmit.expect('initialize the IEEE 802.15.4 subsystem', timeout=10)
transmit.write('esp154 -d') transmit.write('esp154 -d')
transmit.expect('deinitialize the IEEE 802.15.4 subsystem', timeout=10) transmit.expect('deinitialize the IEEE 802.15.4 subsystem', timeout=10)
transmit.write('fheap') transmit.write('heap')
scd_data = transmit.expect(r'heap size: [0-9]+', timeout=10)[0].decode() scd_data = transmit.expect(r'min heap size: [0-9]+', timeout=10)[0].decode()
scd_size = re.findall(r'heap size: ([0-9]+)', scd_data) scd_size = re.findall(r'min heap size: ([0-9]+)', scd_data)
print('first heap size: ', int(fst_size[0])) print('first heap size: ', int(fst_size[0]))
print('second heap size: ', int(scd_size[0])) print('second heap size: ', int(scd_size[0]))