Skip to content

Commit

Permalink
Bluetooth: Mesh: Switch to using Linux Foundation Company ID
Browse files Browse the repository at this point in the history
The Linux Foundation now has an assigned Company Identifier, so switch
to using that.

Signed-off-by: Johan Hedberg <[email protected]>
  • Loading branch information
Johan Hedberg authored and Anas Nashif committed Mar 6, 2018
1 parent 67b321e commit b9588d8
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 28 deletions.
3 changes: 3 additions & 0 deletions include/bluetooth/hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
extern "C" {
#endif

/* Company Identifiers (see Bluetooth Assigned Numbers) */
#define BT_COMP_ID_LF 0x05f1

#define BT_ADDR_LE_PUBLIC 0x00
#define BT_ADDR_LE_RANDOM 0x01
#define BT_ADDR_LE_PUBLIC_ID 0x02
Expand Down
4 changes: 1 addition & 3 deletions samples/bluetooth/mesh/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#include "board.h"

#define CID_INTEL 0x0002

static struct bt_mesh_cfg_srv cfg_srv = {
.relay = BT_MESH_RELAY_DISABLED,
.beacon = BT_MESH_BEACON_ENABLED,
Expand Down Expand Up @@ -135,7 +133,7 @@ static struct bt_mesh_elem elements[] = {
};

static const struct bt_mesh_comp comp = {
.cid = CID_INTEL,
.cid = BT_COMP_ID_LF,
.elem = elements,
.elem_count = ARRAY_SIZE(elements),
};
Expand Down
13 changes: 6 additions & 7 deletions samples/bluetooth/mesh_demo/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@

#include "board.h"

#define CID_INTEL 0x0002
#define MOD_INTEL 0x0000
#define MOD_LF 0x0000

#define GROUP_ADDR 0xc000
#define PUBLISHER_ADDR 0x000f

#define OP_VENDOR_BUTTON BT_MESH_MODEL_OP_3(0x00, CID_INTEL)
#define OP_VENDOR_BUTTON BT_MESH_MODEL_OP_3(0x00, BT_COMP_ID_LF)

static const u8_t net_key[16] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
Expand Down Expand Up @@ -117,15 +116,15 @@ static const struct bt_mesh_model_op vnd_ops[] = {
};

static struct bt_mesh_model vnd_models[] = {
BT_MESH_MODEL_VND(CID_INTEL, MOD_INTEL, vnd_ops, NULL, NULL),
BT_MESH_MODEL_VND(BT_COMP_ID_LF, MOD_LF, vnd_ops, NULL, NULL),
};

static struct bt_mesh_elem elements[] = {
BT_MESH_ELEM(0, root_models, vnd_models),
};

static const struct bt_mesh_comp comp = {
.cid = CID_INTEL,
.cid = BT_COMP_ID_LF,
.elem = elements,
.elem_count = ARRAY_SIZE(elements),
};
Expand All @@ -139,15 +138,15 @@ static void configure(void)

/* Bind to vendor model */
bt_mesh_cfg_mod_app_bind_vnd(net_idx, addr, addr, app_idx,
MOD_INTEL, CID_INTEL, NULL);
MOD_LF, BT_COMP_ID_LF, NULL);

/* Bind to Health model */
bt_mesh_cfg_mod_app_bind(net_idx, addr, addr, app_idx,
BT_MESH_MODEL_ID_HEALTH_SRV, NULL);

/* Add model subscription */
bt_mesh_cfg_mod_sub_add_vnd(net_idx, addr, addr, GROUP_ADDR,
MOD_INTEL, CID_INTEL, NULL);
MOD_LF, BT_COMP_ID_LF, NULL);

#if NODE_ADDR == PUBLISHER_ADDR
{
Expand Down
4 changes: 1 addition & 3 deletions samples/boards/nrf52/mesh/onoff-app/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@

#include <board.h>

#define CID_INTEL 0x0002

/*
* The include must follow the define for it to take effect.
* If it isn't, the domain defaults to "general"
Expand Down Expand Up @@ -281,7 +279,7 @@ static struct bt_mesh_elem elements[] = {
};

static const struct bt_mesh_comp comp = {
.cid = CID_INTEL,
.cid = BT_COMP_ID_LF,
.elem = elements,
.elem_count = ARRAY_SIZE(elements),
};
Expand Down
11 changes: 5 additions & 6 deletions subsys/bluetooth/host/mesh/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "foundation.h"

#define CID_NVAL 0xffff
#define CID_LOCAL 0x0002

/* Default net, app & dev key values, unless otherwise specified */
static const u8_t default_key[16] = {
Expand Down Expand Up @@ -87,7 +86,7 @@ static int fault_get_cur(struct bt_mesh_model *model, u8_t *test_id,
printk("Sending current faults\n");

*test_id = 0x00;
*company_id = CID_LOCAL;
*company_id = BT_COMP_ID_LF;

get_faults(cur_faults, sizeof(cur_faults), faults, fault_count);

Expand All @@ -97,7 +96,7 @@ static int fault_get_cur(struct bt_mesh_model *model, u8_t *test_id,
static int fault_get_reg(struct bt_mesh_model *model, u16_t cid,
u8_t *test_id, u8_t *faults, u8_t *fault_count)
{
if (cid != CID_LOCAL) {
if (cid != BT_COMP_ID_LF) {
printk("Faults requested for unknown Company ID 0x%04x\n", cid);
return -EINVAL;
}
Expand All @@ -113,7 +112,7 @@ static int fault_get_reg(struct bt_mesh_model *model, u16_t cid,

static int fault_clear(struct bt_mesh_model *model, uint16_t cid)
{
if (cid != CID_LOCAL) {
if (cid != BT_COMP_ID_LF) {
return -EINVAL;
}

Expand All @@ -125,7 +124,7 @@ static int fault_clear(struct bt_mesh_model *model, uint16_t cid)
static int fault_test(struct bt_mesh_model *model, uint8_t test_id,
uint16_t cid)
{
if (cid != CID_LOCAL) {
if (cid != BT_COMP_ID_LF) {
return -EINVAL;
}

Expand Down Expand Up @@ -196,7 +195,7 @@ static struct bt_mesh_elem elements[] = {
};

static const struct bt_mesh_comp comp = {
.cid = CID_LOCAL,
.cid = BT_COMP_ID_LF,
.elem = elements,
.elem_count = ARRAY_SIZE(elements),
};
Expand Down
16 changes: 7 additions & 9 deletions tests/bluetooth/mesh/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#include "board.h"

#define CID_INTEL 0x0002

#define MAX_FAULT 24

static bool has_reg_fault = true;
Expand Down Expand Up @@ -51,7 +49,7 @@ static int fault_get_cur(struct bt_mesh_model *model, u8_t *test_id,
printk("fault_get_cur() has_reg_fault %u\n", has_reg_fault);

*test_id = 0x00;
*company_id = CID_INTEL;
*company_id = BT_COMP_ID_LF;
memcpy(faults, reg_faults, sizeof(reg_faults));
*fault_count = sizeof(reg_faults);

Expand All @@ -61,7 +59,7 @@ static int fault_get_cur(struct bt_mesh_model *model, u8_t *test_id,
static int fault_get_reg(struct bt_mesh_model *model, u16_t company_id,
u8_t *test_id, u8_t *faults, u8_t *fault_count)
{
if (company_id != CID_INTEL) {
if (company_id != BT_COMP_ID_LF) {
return -EINVAL;
}

Expand All @@ -83,7 +81,7 @@ static int fault_get_reg(struct bt_mesh_model *model, u16_t company_id,

static int fault_clear(struct bt_mesh_model *model, uint16_t company_id)
{
if (company_id != CID_INTEL) {
if (company_id != BT_COMP_ID_LF) {
return -EINVAL;
}

Expand All @@ -95,7 +93,7 @@ static int fault_clear(struct bt_mesh_model *model, uint16_t company_id)
static int fault_test(struct bt_mesh_model *model, uint8_t test_id,
uint16_t company_id)
{
if (company_id != CID_INTEL) {
if (company_id != BT_COMP_ID_LF) {
return -EINVAL;
}

Expand Down Expand Up @@ -138,16 +136,16 @@ static const struct bt_mesh_model_op vnd_ops[] = {
};

static struct bt_mesh_model vnd_models[] = {
BT_MESH_MODEL_VND(CID_INTEL, 0x1234, vnd_ops, &vnd_pub, NULL),
BT_MESH_MODEL_VND(CID_INTEL, 0x4321, vnd_ops, &vnd_pub2, NULL),
BT_MESH_MODEL_VND(BT_COMP_ID_LF, 0x1234, vnd_ops, &vnd_pub, NULL),
BT_MESH_MODEL_VND(BT_COMP_ID_LF, 0x4321, vnd_ops, &vnd_pub2, NULL),
};

static struct bt_mesh_elem elements[] = {
BT_MESH_ELEM(0, root_models, vnd_models),
};

static const struct bt_mesh_comp comp = {
.cid = CID_INTEL,
.cid = BT_COMP_ID_LF,
.elem = elements,
.elem_count = ARRAY_SIZE(elements),
};
Expand Down

0 comments on commit b9588d8

Please sign in to comment.