forked from apache/mynewt-nimble
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apps/blestress: extend functionality of blestress
This commit adds new enchancements to blestress app.
- Loading branch information
1 parent
b1ecc2d
commit 5db6719
Showing
14 changed files
with
440 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#include <assert.h> | ||
#include <inttypes.h> | ||
#include <errno.h> | ||
#include <string.h> | ||
#include "os/mynewt.h" | ||
#include "bsp/bsp.h" | ||
#include "hal/hal_gpio.h" | ||
|
||
#include "nimble/ble.h" | ||
#include "nimble/nimble_opt.h" | ||
|
||
#include "console/console.h" | ||
#include "shell/shell.h" | ||
|
||
#include "cmd.h" | ||
|
||
struct os_sem stress_main_sem; | ||
struct os_sem tx_stress_start_sem; | ||
|
||
static int | ||
device_role_rx(int argc, char **argv) | ||
{ | ||
hal_gpio_init_out(LED_2, 1); | ||
hal_gpio_toggle(LED_2); | ||
|
||
console_printf("RX device"); | ||
shell_register_default_module("rx_cmd"); | ||
|
||
console_printf("\033[1;36mRX device\033[0m\n"); | ||
console_printf("Type start_test num=(1-15) to start a specific test " | ||
"case\n"); | ||
|
||
return 0; | ||
} | ||
|
||
static int | ||
device_role_tx(int argc, char **argv) | ||
{ | ||
console_printf("\033[1;36mTX device\033[0m\n"); | ||
|
||
os_sem_release(&tx_stress_start_sem); | ||
|
||
return 0; | ||
} | ||
|
||
#if MYNEWT_VAL(SHELL_CMD_HELP) | ||
static const struct shell_cmd_help tx_stress_help = { | ||
.summary = "TX Device: advertiser", | ||
.usage = NULL, | ||
.params = NULL, | ||
}; | ||
|
||
static const struct shell_cmd_help rx_stress_help = { | ||
.summary = "RX Device: scanner", | ||
.usage = NULL, | ||
.params = NULL, | ||
}; | ||
#endif | ||
|
||
static const struct shell_cmd stress_cmd[] = { | ||
{ | ||
.sc_cmd = "rx", | ||
.sc_cmd_func = device_role_rx, | ||
#if MYNEWT_VAL(SHELL_CMD_HELP) | ||
.help = &rx_stress_help, | ||
#endif | ||
}, | ||
{ | ||
.sc_cmd = "tx", | ||
.sc_cmd_func = device_role_tx, | ||
#if MYNEWT_VAL(SHELL_CMD_HELP) | ||
.help = &tx_stress_help, | ||
#endif | ||
}, | ||
}; | ||
|
||
void | ||
cmd_stress_init(void) | ||
{ | ||
shell_register("blestress", stress_cmd); | ||
shell_register_default_module("blestress"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#ifndef CMD_H | ||
#define CMD_H | ||
|
||
#include <inttypes.h> | ||
#include <parse_arg/parse_arg.h> | ||
#include "host/ble_uuid.h" | ||
|
||
void cmd_stress_init(void); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#include <assert.h> | ||
#include <inttypes.h> | ||
#include <string.h> | ||
#include "os/mynewt.h" | ||
|
||
#include "console/console.h" | ||
#include "shell/shell.h" | ||
|
||
#include "cmd.h" | ||
|
||
int test_case_num; | ||
struct os_sem rx_stress_test_sem; | ||
|
||
static int | ||
start_test_case(int argc, char **argv) | ||
{ | ||
uint8_t test_num; | ||
uint8_t min = 1; | ||
uint8_t max = 15; | ||
uint8_t dflt = 0; | ||
int rc; | ||
|
||
rc = parse_arg_init(argc - 1, argv +1); | ||
if (rc != 0) { | ||
return rc; | ||
} | ||
|
||
test_num = parse_arg_uint8_bounds_dflt("num", min, max, dflt, &rc); | ||
if (rc != 0) { | ||
console_printf("Invalid test number parameter\n"); | ||
return rc; | ||
} | ||
|
||
test_case_num = test_num; | ||
|
||
os_sem_release(&rx_stress_test_sem); | ||
|
||
return 0; | ||
} | ||
|
||
#if MYNEWT_VAL(SHELL_CMD_HELP) | ||
static const struct shell_param stress_test_params[] = { | ||
{"num", "Test case number, usage: =[1-15], default: 0"}, | ||
{NULL, NULL} | ||
}; | ||
|
||
static const struct shell_cmd_help test_help = { | ||
.summary = "\nType start_test num (1-15) as a parameter to " | ||
"start a specific test case.\nNULL parameter or num=0 will run" | ||
" all test cases", | ||
.usage = NULL, | ||
.params = stress_test_params, | ||
}; | ||
#endif | ||
|
||
static const struct shell_cmd rx_cmd[] = { | ||
{ | ||
.sc_cmd = "start_test", | ||
.sc_cmd_func = start_test_case, | ||
#if MYNEWT_VAL(SHELL_CMD_HELP) | ||
.help = &test_help, | ||
#endif | ||
}, | ||
}; | ||
|
||
void | ||
rx_cmd_init(void) | ||
{ | ||
shell_register("rx_cmd", rx_cmd); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#ifndef CMD_RX_H | ||
#define CMD_RX_H | ||
|
||
#include <inttypes.h> | ||
#include "host/ble_uuid.h" | ||
#include "cmd.h" | ||
|
||
void rx_cmd_init(void); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.