Skip to content

Commit 6259b81

Browse files
authored
Merge pull request #198 from JF002/update-nimble-1_3-master
Update to nimble 1.3 master branch
2 parents 16ce5bb + d90b727 commit 6259b81

286 files changed

Lines changed: 31362 additions & 9294 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/components/ble/BatteryInformationService.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <nrf_log.h>
12
#include "BatteryInformationService.h"
23
#include "components/battery/BatteryController.h"
34

src/components/ble/CurrentTimeClient.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "CurrentTimeClient.h"
22
#include <hal/nrf_rtc.h>
3+
#include <nrf_log.h>
34
#include "components/datetime/DateTimeController.h"
45

56
using namespace Pinetime::Controllers;

src/components/ble/CurrentTimeService.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "CurrentTimeService.h"
22
#include <hal/nrf_rtc.h>
3+
#include <nrf_log.h>
34

45
using namespace Pinetime::Controllers;
56

src/heartratetask/HeartRateTask.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ HeartRateTask::HeartRateTask(Drivers::Hrs3300 &heartRateSensor, Controllers::Hea
1414
}
1515

1616
void HeartRateTask::Start() {
17-
if (pdPASS != xTaskCreate(HeartRateTask::Process, "Heartrate", 500, this, 0, &taskHandle))
18-
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
17+
//if (pdPASS != xTaskCreate(HeartRateTask::Process, "Heartrate", 500, this, 0, &taskHandle))
18+
// APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
1919
}
2020

2121
void HeartRateTask::Process(void *instance) {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!--
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
-->
21+
22+
# Sample applications
23+
24+
## advertiser
25+
26+
This is the simplest example of advertising. Application sets NRPA, configures
27+
advertisement parameters: general discoverable and not connectable and fills
28+
advertisement fields. Transmited data contains only flags, tx power level and
29+
device name, which fits in 31B limit of single package. With this data set,
30+
device advertises for 10 seconds, terminates advertisement and repeats process
31+
again infinitely.
32+
33+
## scanner
34+
35+
This application shows how to perform simple scan. Device performs discovery
36+
procedure, during which receives advertising reports (if any devices are
37+
advertising nearby). These reports are being parsed and results are printed to
38+
serial port. Applicaton starts new discovery every second.
39+
40+
## peripheral
41+
42+
Peripheral application is based on advertiser, but has added capability of
43+
connecting with other devices. As peripheral, device doesn't initiate any
44+
connection by itself; instead, advertises infinitely and accepts any connection
45+
request it receives. Because we cannot use any 16 or 32 bit UUIDs, as these are
46+
reserved by Bluetooth SIG, we are forced to use 128-bit one. Including such
47+
long UUID in advertising data consumes large part of available payload, so this
48+
data is split in advertising data and response data.
49+
50+
## central
51+
52+
This application works in pair with peripheral. It's based on scanner
53+
application - the difference is, that if there was detected device with UUID
54+
fitting to the one predefined in central application, connection is initiated.

src/libs/mynewt-nimble/apps/blemesh/src/main.c

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,6 @@ static int recent_test_id = STANDARD_TEST_ID;
4242

4343
static bool has_reg_fault = true;
4444

45-
static struct bt_mesh_cfg_srv cfg_srv = {
46-
.relay = BT_MESH_RELAY_DISABLED,
47-
.beacon = BT_MESH_BEACON_ENABLED,
48-
#if MYNEWT_VAL(BLE_MESH_FRIEND)
49-
.frnd = BT_MESH_FRIEND_ENABLED,
50-
#else
51-
.gatt_proxy = BT_MESH_GATT_PROXY_NOT_SUPPORTED,
52-
#endif
53-
#if MYNEWT_VAL(BLE_MESH_GATT_PROXY)
54-
.gatt_proxy = BT_MESH_GATT_PROXY_ENABLED,
55-
#else
56-
.gatt_proxy = BT_MESH_GATT_PROXY_NOT_SUPPORTED,
57-
#endif
58-
.default_ttl = 7,
59-
60-
/* 3 transmissions with 20ms interval */
61-
.net_transmit = BT_MESH_TRANSMIT(2, 20),
62-
.relay_retransmit = BT_MESH_TRANSMIT(2, 20),
63-
};
64-
6545
static int
6646
fault_get_cur(struct bt_mesh_model *model,
6747
uint8_t *test_id,
@@ -327,7 +307,7 @@ static const struct bt_mesh_model_op gen_level_op[] = {
327307
};
328308

329309
static struct bt_mesh_model root_models[] = {
330-
BT_MESH_MODEL_CFG_SRV(&cfg_srv),
310+
BT_MESH_MODEL_CFG_SRV,
331311
BT_MESH_MODEL_HEALTH_SRV(&health_srv, &health_pub),
332312
BT_MESH_MODEL(BT_MESH_MODEL_ID_GEN_ONOFF_SRV, gen_onoff_op,
333313
&gen_onoff_pub, NULL),
@@ -385,7 +365,7 @@ static int output_number(bt_mesh_output_action_t action, uint32_t number)
385365
return 0;
386366
}
387367

388-
static void prov_complete(u16_t net_idx, u16_t addr)
368+
static void prov_complete(uint16_t net_idx, uint16_t addr)
389369
{
390370
console_printf("Local node provisioned, primary address 0x%04x\n", addr);
391371
}

src/libs/mynewt-nimble/apps/blemesh_light/src/light_model.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ static uint16_t top_val;
4848
static uint32_t neopixel[WS2812_NUM_LED];
4949
#endif
5050

51-
static u8_t gen_onoff_state;
52-
static s16_t gen_level_state;
51+
static uint8_t gen_onoff_state;
52+
static int16_t gen_level_state;
5353

54-
static void light_set_lightness(u8_t percentage)
54+
static void light_set_lightness(uint8_t percentage)
5555
{
5656
#if (!MYNEWT_VAL(USE_NEOPIXEL))
5757
int rc;
@@ -76,10 +76,10 @@ static void light_set_lightness(u8_t percentage)
7676
#endif
7777
#else
7878
int i;
79-
u32_t lightness;
80-
u8_t max_lightness = 0x1f;
79+
uint32_t lightness;
80+
uint8_t max_lightness = 0x1f;
8181

82-
lightness = (u8_t) (percentage * max_lightness / 100);
82+
lightness = (uint8_t) (percentage * max_lightness / 100);
8383

8484
for (i = 0; i < WS2812_NUM_LED; i++) {
8585
neopixel[i] = (lightness | lightness << 8 | lightness << 16);
@@ -90,7 +90,7 @@ static void light_set_lightness(u8_t percentage)
9090

9191
static void update_light_state(void)
9292
{
93-
u16_t level = (u16_t)gen_level_state;
93+
uint16_t level = (uint16_t)gen_level_state;
9494
int percent = 100 * level / 0xffff;
9595

9696
if (gen_onoff_state == 0) {
@@ -99,44 +99,44 @@ static void update_light_state(void)
9999
light_set_lightness((uint8_t) percent);
100100
}
101101

102-
int light_model_gen_onoff_get(struct bt_mesh_model *model, u8_t *state)
102+
int light_model_gen_onoff_get(struct bt_mesh_model *model, uint8_t *state)
103103
{
104104
*state = gen_onoff_state;
105105
return 0;
106106
}
107107

108-
int light_model_gen_onoff_set(struct bt_mesh_model *model, u8_t state)
108+
int light_model_gen_onoff_set(struct bt_mesh_model *model, uint8_t state)
109109
{
110110
gen_onoff_state = state;
111111
update_light_state();
112112
return 0;
113113
}
114114

115-
int light_model_gen_level_get(struct bt_mesh_model *model, s16_t *level)
115+
int light_model_gen_level_get(struct bt_mesh_model *model, int16_t *level)
116116
{
117117
*level = gen_level_state;
118118
return 0;
119119
}
120120

121-
int light_model_gen_level_set(struct bt_mesh_model *model, s16_t level)
121+
int light_model_gen_level_set(struct bt_mesh_model *model, int16_t level)
122122
{
123123
gen_level_state = level;
124-
if ((u16_t)gen_level_state > 0x0000) {
124+
if ((uint16_t)gen_level_state > 0x0000) {
125125
gen_onoff_state = 1;
126126
}
127-
if ((u16_t)gen_level_state == 0x0000) {
127+
if ((uint16_t)gen_level_state == 0x0000) {
128128
gen_onoff_state = 0;
129129
}
130130
update_light_state();
131131
return 0;
132132
}
133133

134-
int light_model_light_lightness_get(struct bt_mesh_model *model, s16_t *lightness)
134+
int light_model_light_lightness_get(struct bt_mesh_model *model, int16_t *lightness)
135135
{
136136
return light_model_gen_level_get(model, lightness);
137137
}
138138

139-
int light_model_light_lightness_set(struct bt_mesh_model *model, s16_t lightness)
139+
int light_model_light_lightness_set(struct bt_mesh_model *model, int16_t lightness)
140140
{
141141
return light_model_gen_level_set(model, lightness);
142142
}

src/libs/mynewt-nimble/apps/blemesh_light/src/light_model.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
#include "syscfg/syscfg.h"
2727
#include "mesh/mesh.h"
2828

29-
int light_model_gen_onoff_get(struct bt_mesh_model *model, u8_t *state);
30-
int light_model_gen_onoff_set(struct bt_mesh_model *model, u8_t state);
31-
int light_model_gen_level_get(struct bt_mesh_model *model, s16_t *level);
32-
int light_model_gen_level_set(struct bt_mesh_model *model, s16_t level);
33-
int light_model_light_lightness_get(struct bt_mesh_model *model, s16_t *lightness);
34-
int light_model_light_lightness_set(struct bt_mesh_model *model, s16_t lightness);
29+
int light_model_gen_onoff_get(struct bt_mesh_model *model, uint8_t *state);
30+
int light_model_gen_onoff_set(struct bt_mesh_model *model, uint8_t state);
31+
int light_model_gen_level_get(struct bt_mesh_model *model, int16_t *level);
32+
int light_model_gen_level_set(struct bt_mesh_model *model, int16_t level);
33+
int light_model_light_lightness_get(struct bt_mesh_model *model, int16_t *lightness);
34+
int light_model_light_lightness_set(struct bt_mesh_model *model, int16_t lightness);
3535
int light_model_init(void);
3636

3737
#endif

src/libs/mynewt-nimble/apps/blemesh_light/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
#include "light_model.h"
3232

3333

34-
static void model_bound_cb(u16_t addr, struct bt_mesh_model *model,
35-
u16_t key_idx)
34+
static void model_bound_cb(uint16_t addr, struct bt_mesh_model *model,
35+
uint16_t key_idx)
3636
{
3737
int rc;
3838

src/libs/mynewt-nimble/apps/blemesh_models_example_1/src/main.c

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -84,30 +84,6 @@ static void gen_onoff_status(struct bt_mesh_model *model,
8484
struct bt_mesh_msg_ctx *ctx,
8585
struct os_mbuf *buf);
8686

87-
/*
88-
* Server Configuration Declaration
89-
*/
90-
91-
static struct bt_mesh_cfg_srv cfg_srv = {
92-
.relay = BT_MESH_RELAY_DISABLED,
93-
.beacon = BT_MESH_BEACON_ENABLED,
94-
#if defined(CONFIG_BT_MESH_FRIEND)
95-
.frnd = BT_MESH_FRIEND_ENABLED,
96-
#else
97-
.frnd = BT_MESH_FRIEND_NOT_SUPPORTED,
98-
#endif
99-
#if defined(CONFIG_BT_MESH_GATT_PROXY)
100-
.gatt_proxy = BT_MESH_GATT_PROXY_ENABLED,
101-
#else
102-
.gatt_proxy = BT_MESH_GATT_PROXY_NOT_SUPPORTED,
103-
#endif
104-
.default_ttl = 7,
105-
106-
/* 3 transmissions with 20ms interval */
107-
.net_transmit = BT_MESH_TRANSMIT(2, 20),
108-
.relay_retransmit = BT_MESH_TRANSMIT(2, 20),
109-
};
110-
11187
/*
11288
* Client Configuration Declaration
11389
*/
@@ -213,9 +189,9 @@ static const struct bt_mesh_model_op gen_onoff_cli_op[] = {
213189
};
214190

215191
struct onoff_state {
216-
u8_t current;
217-
u8_t previous;
218-
u8_t led_gpio_pin;
192+
uint8_t current;
193+
uint8_t previous;
194+
uint8_t led_gpio_pin;
219195
};
220196

221197
/*
@@ -238,7 +214,7 @@ static struct onoff_state onoff_state_arr[] = {
238214
*/
239215

240216
static struct bt_mesh_model root_models[] = {
241-
BT_MESH_MODEL_CFG_SRV(&cfg_srv),
217+
BT_MESH_MODEL_CFG_SRV,
242218
BT_MESH_MODEL_CFG_CLI(&cfg_cli),
243219
BT_MESH_MODEL_HEALTH_SRV(&health_srv, &health_pub),
244220
BT_MESH_MODEL(BT_MESH_MODEL_ID_GEN_ONOFF_SRV, gen_onoff_srv_op,
@@ -320,20 +296,20 @@ static const struct bt_mesh_comp comp = {
320296
};
321297

322298
struct sw {
323-
u8_t sw_num;
324-
u8_t onoff_state;
299+
uint8_t sw_num;
300+
uint8_t onoff_state;
325301
struct os_callout button_work;
326302
struct os_callout button_timer;
327303
};
328304

329305

330-
static u8_t button_press_cnt;
306+
static uint8_t button_press_cnt;
331307
static struct sw sw;
332308

333-
static u8_t trans_id;
334-
static u32_t time, last_time;
335-
static u16_t primary_addr;
336-
static u16_t primary_net_idx;
309+
static uint8_t trans_id;
310+
static uint32_t time, last_time;
311+
static uint16_t primary_addr;
312+
static uint16_t primary_net_idx;
337313

338314
/*
339315
* Generic OnOff Model Server Message Handlers
@@ -416,15 +392,15 @@ static void gen_onoff_status(struct bt_mesh_model *model,
416392
struct bt_mesh_msg_ctx *ctx,
417393
struct os_mbuf *buf)
418394
{
419-
u8_t state;
395+
uint8_t state;
420396

421397
state = net_buf_simple_pull_u8(buf);
422398

423399
BT_INFO("Node 0x%04x OnOff status from 0x%04x with state 0x%02x",
424400
bt_mesh_model_elem(model)->addr, ctx->addr, state);
425401
}
426402

427-
static int output_number(bt_mesh_output_action_t action, u32_t number)
403+
static int output_number(bt_mesh_output_action_t action, uint32_t number)
428404
{
429405
BT_INFO("OOB Number %u", number);
430406
return 0;
@@ -436,7 +412,7 @@ static int output_string(const char *str)
436412
return 0;
437413
}
438414

439-
static void prov_complete(u16_t net_idx, u16_t addr)
415+
static void prov_complete(uint16_t net_idx, uint16_t addr)
440416
{
441417
BT_INFO("provisioning complete for net_idx 0x%04x addr 0x%04x",
442418
net_idx, addr);
@@ -449,7 +425,7 @@ static void prov_reset(void)
449425
bt_mesh_prov_enable(BT_MESH_PROV_ADV | BT_MESH_PROV_GATT);
450426
}
451427

452-
static u8_t dev_uuid[16] = MYNEWT_VAL(BLE_MESH_DEV_UUID);
428+
static uint8_t dev_uuid[16] = MYNEWT_VAL(BLE_MESH_DEV_UUID);
453429

454430
#define BUTTON_DEBOUNCE_DELAY_MS 250
455431

@@ -528,7 +504,7 @@ static void button_pressed_worker(struct os_event *work)
528504
struct bt_mesh_model *mod_cli, *mod_srv;
529505
struct bt_mesh_model_pub *pub_cli, *pub_srv;
530506
struct sw *sw = work->ev_arg;
531-
u8_t sw_idx = sw->sw_num;
507+
uint8_t sw_idx = sw->sw_num;
532508
int err;
533509

534510
mod_cli = mod_cli_sw[sw_idx];
@@ -599,7 +575,7 @@ static const struct bt_mesh_prov prov = {
599575
.reset = prov_reset,
600576
};
601577

602-
void init_led(u8_t dev)
578+
void init_led(uint8_t dev)
603579
{
604580
hal_gpio_init_out(onoff_state_arr[dev].led_gpio_pin, 1);
605581
}

0 commit comments

Comments
 (0)