Skip to content

Commit f8c03d7

Browse files
vikrant8052jhedberg
authored andcommitted
samples: mesh: nrf52: added separate update_vnd_led_gpio()
Added sepate function update_vnd_led_gpio(). Signed-off-by: Vikrant More <[email protected]>
1 parent c97e872 commit f8c03d7

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010

1111
void update_led_gpio(void);
1212
void update_light_state(void);
13+
void update_vnd_led_gpio(void);
1314

1415
#endif

samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/main.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ static void light_default_status_init(void)
9393
ctl->duv->target = ctl->duv->current;
9494
}
9595

96+
void update_vnd_led_gpio(void)
97+
{
98+
if (vnd_user_data.current == STATE_ON) {
99+
/* LED2 On */
100+
gpio_pin_write(led_device[1], DT_ALIAS_LED1_GPIOS_PIN, 0);
101+
} else {
102+
/* LED2 Off */
103+
gpio_pin_write(led_device[1], DT_ALIAS_LED1_GPIOS_PIN, 1);
104+
}
105+
}
106+
96107
void update_led_gpio(void)
97108
{
98109
u8_t power, color;

samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/mesh/device_composition.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77

88
#include <drivers/gpio.h>
99

10-
#include "app_gpio.h"
11-
#include "storage.h"
12-
1310
#include "ble_mesh.h"
11+
#include "common.h"
1412
#include "device_composition.h"
1513
#include "state_binding.h"
1614
#include "transition.h"
15+
#include "storage.h"
1716

1817
static struct bt_mesh_cfg_srv cfg_srv = {
1918
.relay = BT_MESH_RELAY_ENABLED,
@@ -1012,13 +1011,7 @@ static void vnd_set_unack(struct bt_mesh_model *model,
10121011

10131012
printk("Vendor model message = %04x\n", state->current);
10141013

1015-
if (state->current == STATE_ON) {
1016-
/* LED2 On */
1017-
gpio_pin_write(led_device[1], DT_ALIAS_LED1_GPIOS_PIN, 0);
1018-
} else {
1019-
/* LED2 Off */
1020-
gpio_pin_write(led_device[1], DT_ALIAS_LED1_GPIOS_PIN, 1);
1021-
}
1014+
update_vnd_led_gpio();
10221015
}
10231016

10241017
static void vnd_set(struct bt_mesh_model *model,

samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/mesh/device_composition.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct light_ctl_state {
9090
struct transition *transition;
9191
};
9292

93+
extern struct vendor_state vnd_user_data;
9394
extern struct light_ctl_state *const ctl;
9495

9596
extern struct bt_mesh_model root_models[];

0 commit comments

Comments
 (0)