Skip to content

Commit

Permalink
Refactoring: rename fields in set_all_params cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSomeMan committed Oct 17, 2024
1 parent f40a137 commit b72e510
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 47 deletions.
2 changes: 1 addition & 1 deletion CMock
Submodule CMock updated 1 files
+23 −12 scripts/create_makefile.rb
19 changes: 15 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Source, copyright: https://github.com/viva64/pvs-studio-makefile-examples
# commit 82a0f0a, /example-1
# Modified for C on mac, added Doxygen
# Apache License
# Version 2.0, January 2004
# http://www.apache.org/licenses/
Expand Down Expand Up @@ -214,7 +211,7 @@ OFLAGS = -g3
LDFLAGS =
DFLAGS =

INCLUDES += src/
INCLUDES += src
INCLUDES += ./CMock/vendor/unity/src
INCLUDES += ./build/test/mocks
INC_PARAMS = $(foreach d, $(INCLUDES), -I$d)
Expand Down Expand Up @@ -253,6 +250,20 @@ TEST_MAKEFILE_EXT_ADV_MAX = ${BUILD_DIR}_ext_adv_max/MakefileTestSupport

all: clean astyle doxygen sonar

# Specify all tests as dependencies of 'all' (workaround for JetBrains CLion)
# It is needed because on the first scan of Makefile the $(TEST_MAKEFILE) does not exist and it is not included.
all: test_ruuvi_endpoint_3 \
test_ruuvi_endpoint_5 \
test_ruuvi_endpoint_6 \
test_ruuvi_endpoint_8 \
test_ruuvi_endpoint_c5 \
test_ruuvi_endpoint_ca_uart \
test_ruuvi_endpoint_e0 \
test_ruuvi_endpoint_f0 \
test_ruuvi_endpoint_fa \
test_ruuvi_endpoint_ibeacon \
test_ruuvi_endpoints

doxygen: clean
doxygen

Expand Down
24 changes: 12 additions & 12 deletions src/ruuvi_endpoint_ca_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,12 @@ static re_status_t re_ca_uart_decode_set_all_params (
+ RE_CA_UART_CMD_FLTR_ID_LEN];
payload->params.all_params.bools.fltr_tags.state =
(flags >> RE_CA_UART_ALL_FLTR_TAG_BIT) & 1U;
payload->params.all_params.bools.coded_phy.state =
(flags >> RE_CA_UART_ALL_CODED_PHY_BIT) & 1U;
payload->params.all_params.bools.scan_phy.state =
(flags >> RE_CA_UART_ALL_SCAN_PHY_BIT) & 1U;
payload->params.all_params.bools.ext_payload.state =
(flags >> RE_CA_UART_ALL_EXT_PLD_BIT) & 1U;
payload->params.all_params.bools.use_coded_phy.state =
(flags >> RE_CA_UART_ALL_USE_CODED_PHY_BIT) & 1U;
payload->params.all_params.bools.use_1m_phy.state =
(flags >> RE_CA_UART_ALL_USE_1M_PHY_BIT) & 1U;
payload->params.all_params.bools.use_2m_phy.state =
(flags >> RE_CA_UART_ALL_USE_2M_PHY_BIT) & 1U;
payload->params.all_params.bools.ch_37.state =
(flags >> RE_CA_UART_ALL_CH_37_BIT) & 1U;
payload->params.all_params.bools.ch_38.state =
Expand Down Expand Up @@ -953,12 +953,12 @@ static re_status_t re_ca_uart_encode_set_all_params (uint8_t * const buffer,
buffer[written++] = RE_CA_UART_FIELD_DELIMITER;
buffer[written] = ( ( (payload->params.all_params.bools.fltr_tags.state & 1U)
<< RE_CA_UART_ALL_FLTR_TAG_BIT)
| ( (payload->params.all_params.bools.coded_phy.state & 1U)
<< RE_CA_UART_ALL_CODED_PHY_BIT)
| ( (payload->params.all_params.bools.scan_phy.state & 1U)
<< RE_CA_UART_ALL_SCAN_PHY_BIT)
| ( (payload->params.all_params.bools.ext_payload.state & 1U)
<< RE_CA_UART_ALL_EXT_PLD_BIT)
| ( (payload->params.all_params.bools.use_coded_phy.state & 1U)
<< RE_CA_UART_ALL_USE_CODED_PHY_BIT)
| ( (payload->params.all_params.bools.use_1m_phy.state & 1U)
<< RE_CA_UART_ALL_USE_1M_PHY_BIT)
| ( (payload->params.all_params.bools.use_2m_phy.state & 1U)
<< RE_CA_UART_ALL_USE_2M_PHY_BIT)
| ( (payload->params.all_params.bools.ch_37.state & 1U)
<< RE_CA_UART_ALL_CH_37_BIT)
| ( (payload->params.all_params.bools.ch_38.state & 1U)
Expand Down
24 changes: 12 additions & 12 deletions src/ruuvi_endpoint_ca_uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@
#define RE_CA_UART_ACK_BYTE (1U) //!< Byte of bool params, starting from 0.
#define RE_CA_UART_ACK_BIT (0U) //!< Bit of bool params, starting from 0.

#define RE_CA_UART_FLTR_ID_BYTE (2U) //!< Byte of bool params, starting from 0.
#define RE_CA_UART_ALL_BOOL_BYTE (1U) //!< Byte of bool params, starting from 0.
#define RE_CA_UART_ALL_FLTR_TAG_BIT (0U) //!< Byte of bool params, starting from 0.
#define RE_CA_UART_ALL_CODED_PHY_BIT (1U) //!< Byte of bool params, starting from 0.
#define RE_CA_UART_ALL_SCAN_PHY_BIT (2U) //!< Byte of bool params, starting from 0.
#define RE_CA_UART_ALL_EXT_PLD_BIT (3U) //!< Byte of bool params, starting from 0.
#define RE_CA_UART_ALL_CH_37_BIT (4U) //!< Byte of bool params, starting from 0.
#define RE_CA_UART_ALL_CH_38_BIT (5U) //!< Byte of bool params, starting from 0.
#define RE_CA_UART_ALL_CH_39_BIT (6U) //!< Byte of bool params, starting from 0.
#define RE_CA_UART_FLTR_ID_BYTE (2U) //!< Byte of bool params, starting from 0.
#define RE_CA_UART_ALL_BOOL_BYTE (1U) //!< Byte of bool params, starting from 0.
#define RE_CA_UART_ALL_FLTR_TAG_BIT (0U) //!< Bit of bool params, starting from 0.
#define RE_CA_UART_ALL_USE_CODED_PHY_BIT (1U) //!< Bit of bool params, starting from 0.
#define RE_CA_UART_ALL_USE_1M_PHY_BIT (2U) //!< Bit of bool params, starting from 0.
#define RE_CA_UART_ALL_USE_2M_PHY_BIT (3U) //!< Bit of bool params, starting from 0.
#define RE_CA_UART_ALL_CH_37_BIT (4U) //!< Bit of bool params, starting from 0.
#define RE_CA_UART_ALL_CH_38_BIT (5U) //!< Bit of bool params, starting from 0.
#define RE_CA_UART_ALL_CH_39_BIT (6U) //!< Bit of bool params, starting from 0.

#define RE_CA_UART_STX_ETX_LEN (1U) //!< Length of cmd with bool payload
#define RE_CA_UART_DEVICE_ID_LEN (8U) //!< Length of device id payload
Expand Down Expand Up @@ -315,9 +315,9 @@ typedef struct
typedef struct
{
re_ca_uart_ble_bool_t fltr_tags; //!< Filter tag bool state.
re_ca_uart_ble_bool_t coded_phy; //!< Coded phy bool state.
re_ca_uart_ble_bool_t scan_phy; //!< Scanned phy bool state.
re_ca_uart_ble_bool_t ext_payload; //!< Pyload extension bool state.
re_ca_uart_ble_bool_t use_coded_phy;//!< Use BLE Coded PHY bool state.
re_ca_uart_ble_bool_t use_1m_phy; //!< Use BLE 1M PHY bool state.
re_ca_uart_ble_bool_t use_2m_phy; //!< Use BLE 2M PHY bool state.
re_ca_uart_ble_bool_t ch_37; //!< Channel 37 bool state.
re_ca_uart_ble_bool_t ch_38; //!< Channel 38 bool state.
re_ca_uart_ble_bool_t ch_39; //!< Channel 39 bool state.
Expand Down
36 changes: 18 additions & 18 deletions test/test_ruuvi_endpoint_ca_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ void test_ruuvi_endpoint_ca_uart_set_all_params_encode (void)
re_ca_uart_ble_all_t params = {0};
params.fltr_id.id = 0x101;
params.bools.fltr_tags.state = 1;
params.bools.coded_phy.state = 1;
params.bools.scan_phy.state = 1;
params.bools.ext_payload.state = 1;
params.bools.use_coded_phy.state = 1;
params.bools.use_1m_phy.state = 1;
params.bools.use_2m_phy.state = 1;
params.bools.ch_37.state = 1;
params.bools.ch_38.state = 1;
params.bools.ch_39.state = 1;
Expand Down Expand Up @@ -391,9 +391,9 @@ void test_ruuvi_endpoint_ca_uart_set_all_params_with_max_adv_len_encode (void)
re_ca_uart_ble_all_t params = {0};
params.fltr_id.id = 0x101;
params.bools.fltr_tags.state = 1;
params.bools.coded_phy.state = 1;
params.bools.scan_phy.state = 1;
params.bools.ext_payload.state = 1;
params.bools.use_coded_phy.state = 1;
params.bools.use_1m_phy.state = 1;
params.bools.use_2m_phy.state = 1;
params.bools.ch_37.state = 1;
params.bools.ch_38.state = 1;
params.bools.ch_39.state = 1;
Expand Down Expand Up @@ -431,9 +431,9 @@ void test_ruuvi_endpoint_ca_uart_all_encode_invalid (void)
re_ca_uart_ble_all_t params = {0};
params.fltr_id.id = 0x101;
params.bools.fltr_tags.state = 1;
params.bools.coded_phy.state = 1;
params.bools.scan_phy.state = 1;
params.bools.ext_payload.state = 1;
params.bools.use_coded_phy.state = 1;
params.bools.use_1m_phy.state = 1;
params.bools.use_2m_phy.state = 1;
params.bools.ch_37.state = 1;
params.bools.ch_38.state = 1;
params.bools.ch_39.state = 1;
Expand Down Expand Up @@ -1329,9 +1329,9 @@ void test_ruuvi_endpoint_ca_uart_set_all_params_decode (void)
re_ca_uart_ble_all_t expect_params = {0};
expect_params.fltr_id.id = 0x101;
expect_params.bools.fltr_tags.state = 1;
expect_params.bools.coded_phy.state = 1;
expect_params.bools.scan_phy.state = 1;
expect_params.bools.ext_payload.state = 1;
expect_params.bools.use_coded_phy.state = 1;
expect_params.bools.use_1m_phy.state = 1;
expect_params.bools.use_2m_phy.state = 1;
expect_params.bools.ch_37.state = 1;
expect_params.bools.ch_38.state = 1;
expect_params.bools.ch_39.state = 1;
Expand Down Expand Up @@ -1366,9 +1366,9 @@ void test_ruuvi_endpoint_ca_uart_set_all_params_with_max_adv_len_decode (void)
re_ca_uart_ble_all_t expect_params = {0};
expect_params.fltr_id.id = 0x101;
expect_params.bools.fltr_tags.state = 1;
expect_params.bools.coded_phy.state = 1;
expect_params.bools.scan_phy.state = 1;
expect_params.bools.ext_payload.state = 1;
expect_params.bools.use_coded_phy.state = 1;
expect_params.bools.use_1m_phy.state = 1;
expect_params.bools.use_2m_phy.state = 1;
expect_params.bools.ch_37.state = 1;
expect_params.bools.ch_38.state = 1;
expect_params.bools.ch_39.state = 1;
Expand Down Expand Up @@ -1400,9 +1400,9 @@ void test_ruuvi_endpoint_ca_uart_all_decode_invalid (void)
re_ca_uart_ble_all_t expect_params = {0};
expect_params.fltr_id.id = 0x101;
expect_params.bools.fltr_tags.state = 1;
expect_params.bools.coded_phy.state = 0;
expect_params.bools.scan_phy.state = 0;
expect_params.bools.ext_payload.state = 0;
expect_params.bools.use_coded_phy.state = 0;
expect_params.bools.use_1m_phy.state = 0;
expect_params.bools.use_2m_phy.state = 0;
expect_params.bools.ch_37.state = 0;
expect_params.bools.ch_38.state = 0;
expect_params.bools.ch_39.state = 0;
Expand Down

0 comments on commit b72e510

Please sign in to comment.