Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions samples/net/lwm2m_client/src/lwm2m-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#else
#define DT_ALIAS_LED0_GPIOS_CONTROLLER "(fail)"
#define DT_ALIAS_LED0_GPIOS_PIN 0
#define DT_ALIAS_LED0_GPIOS_FLAGS 0
#endif
#endif

#define LED_GPIO_PORT DT_ALIAS_LED0_GPIOS_CONTROLLER
#define LED_GPIO_PIN DT_ALIAS_LED0_GPIOS_PIN
#define LED_GPIO_FLAGS DT_ALIAS_LED0_GPIOS_FLAGS

static u8_t bat_idx = LWM2M_DEVICE_PWR_SRC_TYPE_BAT_INT;
static int bat_mv = 3800;
Expand Down Expand Up @@ -107,7 +109,7 @@ static int led_on_off_cb(u16_t obj_inst_id, u16_t res_id, u16_t res_inst_id,

led_val = *(u8_t *) data;
if (led_val != led_state) {
ret = gpio_pin_write(led_dev, LED_GPIO_PIN, led_val);
ret = gpio_pin_set(led_dev, LED_GPIO_PIN, (int) led_val);
if (ret) {
/*
* We need an extra hook in LWM2M to better handle
Expand Down Expand Up @@ -136,12 +138,8 @@ static int init_led_device(void)
return -ENODEV;
}

ret = gpio_pin_configure(led_dev, LED_GPIO_PIN, GPIO_DIR_OUT);
if (ret) {
return ret;
}

ret = gpio_pin_write(led_dev, LED_GPIO_PIN, 0);
ret = gpio_pin_configure(led_dev, LED_GPIO_PIN, LED_GPIO_FLAGS |
GPIO_OUTPUT_INACTIVE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a style thing (which we do not define) I find it easier to understand when split at the comma rather than within the argument expression:

ret = gpio_pin_configure(led_dev, LED_GPIO_PIN,
                         LED_GPIO_FLAGS | GPIO_OUTPUT_INACTIVE);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually prefer the style where things are split to max line length and then at the bitwise or logical operator boundary myself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK then.

if (ret) {
return ret;
}
Expand Down