Skip to content
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

Merged

Conversation

michal-narajowski
Copy link

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

Copy link
Contributor

@rymanluk rymanluk left a 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

#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)


Copy link
Contributor

Choose a reason for hiding this comment

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

reduntant empty line

#ifndef __BT_MESH_LIGHT_MODEL_H
#define __BT_MESH_LIGHT_MODEL_H

#include "mesh/mesh.h"
Copy link
Contributor

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
@michal-narajowski
Copy link
Author

@rymanluk Thanks, fixed.

@michal-narajowski michal-narajowski merged commit 758de7a into apache:master Mar 21, 2018
@michal-narajowski michal-narajowski deleted the mesh-onoff-level-models branch March 21, 2018 14:01
redradist pushed a commit to redradist/mynewt-nimble that referenced this pull request Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants