Skip to content

Commit

Permalink
example/mesh_node_demo: fix use ENABLE_GATT_BEARER, set test device uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
mringwal committed Sep 9, 2019
1 parent a3030cc commit 138818a
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions example/mesh_node_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#include "btstack.h"
#include "mesh_node_demo.h"

const char * device_uuid_string = "001BDC0810210B0E0A0C000B0E0A0C00";

// general
#define MESH_BLUEKITCHEN_MODEL_ID_TEST_SERVER 0x0000u

Expand Down Expand Up @@ -179,6 +181,34 @@ static void stdin_process(char cmd){
}
}

static int scan_hex_byte(const char * byte_string){
int upper_nibble = nibble_for_char(*byte_string++);
if (upper_nibble < 0) return -1;
int lower_nibble = nibble_for_char(*byte_string);
if (lower_nibble < 0) return -1;
return (upper_nibble << 4) | lower_nibble;
}

static int btstack_parse_hex(const char * string, uint16_t len, uint8_t * buffer){
int i;
for (i = 0; i < len; i++) {
int single_byte = scan_hex_byte(string);
if (single_byte < 0) return 0;
string += 2;
buffer[i] = (uint8_t)single_byte;
// don't check seperator after last byte
if (i == len - 1) {
return 1;
}
// optional seperator
char separator = *string;
if (separator == ':' && separator == '-' && separator == ' ') {
string++;
}
}
return 1;
}

int btstack_main(void);
int btstack_main(void)
{
Expand All @@ -190,7 +220,7 @@ int btstack_main(void)
// crypto
btstack_crypto_init();

#ifdef ENABLE_GATT_BEARER
#ifdef ENABLE_MESH_GATT_BEARER
// l2cap
l2cap_init();

Expand All @@ -213,7 +243,7 @@ int btstack_main(void)
// mesh
mesh_init();

#ifdef ENABLE_GATT_BEARER
#ifdef ENABLE_MESH_GATT_BEARER
// setup connectable advertisments
bd_addr_t null_addr;
memset(null_addr, 0, 6);
Expand Down Expand Up @@ -252,6 +282,10 @@ int btstack_main(void)
gap_start_scan();
#endif

uint8_t device_uuid[16];
btstack_parse_hex(device_uuid_string, 16, device_uuid);
mesh_node_set_device_uuid(device_uuid);

// turn on!
hci_power_control(HCI_POWER_ON);

Expand Down

0 comments on commit 138818a

Please sign in to comment.