-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mesh: Add example implementation of generic onoff and level models #11
mesh: Add example implementation of generic onoff and level models #11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Only 2 minor comments
nimble/host/mesh/src/mesh_priv.h
Outdated
#define OP_GEN_MOVE_SET BT_MESH_MODEL_OP_2(0x82, 0x0b) | ||
#define OP_GEN_MOVE_SET_UNACK BT_MESH_MODEL_OP_2(0x82, 0x0c) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reduntant empty line
nimble/host/mesh/src/light_model.h
Outdated
#ifndef __BT_MESH_LIGHT_MODEL_H | ||
#define __BT_MESH_LIGHT_MODEL_H | ||
|
||
#include "mesh/mesh.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we need #include "syscfg/syscfg.h" ?
This patch adds simple implementation of these two models with support for both client and server. There is also an example light model that simulates a light bulb and controls 4 LEDs through 4 PWMs. To use these features set BLE_MESH_SHELL_MODELS: 1 and you should enable pwm0, pwm1, pwm2 and pwm3 devices. On nrf52840 you should specify PWM_0: 1, PWM_1: 1, PWM_2: 1, PWM_3: 1, to achieve this. Here are the commands used to control the server from client (mesh-shell will communicate through local interface by default): `init` - to initialize mesh `provision 0 0x0001` - provision mesh with fixed keys, 0x0001 is a unicast address of a node `app-key-add 0 0 0` - add app key with netkey_idx=0 appkey_idx=0 and value=0 `mod-app-bind 0x0001 0x0000 0x1000` - bind appkey with generic onoff server model `mod-app-bind 0x0001 0x0000 0x1001` - bind appkey with generic onoff client model `mod-app-bind 0x0001 0x0000 0x1002` - bind appkey with generic level server model `mod-app-bind 0x0001 0x0000 0x1003` - bind appkey with generic level client model `gen-level-set 50` - set diode lightness to 50% `gen-level-get` - get state of level model `gen-onoff-set 0` - set state of onoff model to off `gen-onoff-get` - get state of onoff model
278d9cf
to
60d1cd7
Compare
@rymanluk Thanks, fixed. |
This patch adds simple implementation of these two models
with support for both client and server. There is also an example
light model that simulates a light bulb and controls 4 LEDs through
4 PWMs.
To use these features set BLE_MESH_SHELL_MODELS: 1 and you should
enable pwm0, pwm1, pwm2 and pwm3 devices. On nrf52840 you should
specify PWM_0: 1, PWM_1: 1, PWM_2: 1, PWM_3: 1, to achieve this.
Here are the commands used to control the server from client (mesh-shell
will communicate through local interface by default):
init
- to initialize meshprovision 0 0x0001
- provision mesh with fixed keys, 0x0001 is a unicast addressof a node
app-key-add 0 0 0
- add app key with netkey_idx=0 appkey_idx=0 and value=0mod-app-bind 0x0001 0x0000 0x1000
- bind appkey with generic onoff server modelmod-app-bind 0x0001 0x0000 0x1001
- bind appkey with generic onoff client modelmod-app-bind 0x0001 0x0000 0x1002
- bind appkey with generic level server modelmod-app-bind 0x0001 0x0000 0x1003
- bind appkey with generic level clientmodel
gen-level-set 50
- set diode lightness to 50%gen-level-get
- get state of level modelgen-onoff-set 0
- set state of onoff model to offgen-onoff-get
- get state of onoff model