Merge branch 'nimble' into nimble-ota
This commit is contained in:
commit
66caada0d2
|
@ -77,9 +77,14 @@ void NimbleController::Init() {
|
||||||
dfuService.Init();
|
dfuService.Init();
|
||||||
int res;
|
int res;
|
||||||
res = ble_hs_util_ensure_addr(0);
|
res = ble_hs_util_ensure_addr(0);
|
||||||
|
ASSERT(res == 0);
|
||||||
res = ble_hs_id_infer_auto(0, &addrType);
|
res = ble_hs_id_infer_auto(0, &addrType);
|
||||||
|
ASSERT(res == 0);
|
||||||
res = ble_svc_gap_device_name_set(deviceName);
|
res = ble_svc_gap_device_name_set(deviceName);
|
||||||
ble_gatts_start();
|
|
||||||
|
ASSERT(res == 0);
|
||||||
|
res = ble_gatts_start();
|
||||||
|
ASSERT(res == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NimbleController::StartAdvertising() {
|
void NimbleController::StartAdvertising() {
|
||||||
|
@ -117,14 +122,14 @@ void NimbleController::StartAdvertising() {
|
||||||
|
|
||||||
int res;
|
int res;
|
||||||
res = ble_gap_adv_set_fields(&fields);
|
res = ble_gap_adv_set_fields(&fields);
|
||||||
assert(res == 0);
|
ASSERT(res == 0);
|
||||||
|
|
||||||
ble_gap_adv_rsp_set_fields(&rsp_fields);
|
res = ble_gap_adv_rsp_set_fields(&rsp_fields);
|
||||||
|
ASSERT(res == 0);
|
||||||
|
|
||||||
ble_gap_adv_start(addrType, NULL, 10000,
|
res = ble_gap_adv_start(addrType, NULL, 10000,
|
||||||
&adv_params, GAPEventCallback, this);
|
&adv_params, GAPEventCallback, this);
|
||||||
|
ASSERT(res == 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int OnAllSvrDisco(uint16_t conn_handle,
|
int OnAllSvrDisco(uint16_t conn_handle,
|
||||||
|
@ -140,7 +145,7 @@ int NimbleController::OnGAPEvent(ble_gap_event *event) {
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case BLE_GAP_EVENT_ADV_COMPLETE:
|
case BLE_GAP_EVENT_ADV_COMPLETE:
|
||||||
NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_ADV_COMPLETE");
|
NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_ADV_COMPLETE");
|
||||||
NRF_LOG_INFO("advertise complete; reason=%d", event->adv_complete.reason);
|
NRF_LOG_INFO("advertise complete; reason=%dn status=%d", event->adv_complete.reason, event->connect.status);
|
||||||
StartAdvertising();
|
StartAdvertising();
|
||||||
break;
|
break;
|
||||||
case BLE_GAP_EVENT_CONNECT: {
|
case BLE_GAP_EVENT_CONNECT: {
|
||||||
|
@ -164,7 +169,7 @@ int NimbleController::OnGAPEvent(ble_gap_event *event) {
|
||||||
break;
|
break;
|
||||||
case BLE_GAP_EVENT_DISCONNECT:
|
case BLE_GAP_EVENT_DISCONNECT:
|
||||||
NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_DISCONNECT");
|
NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_DISCONNECT");
|
||||||
NRF_LOG_INFO("disconnect; reason=%d ", event->disconnect.reason);
|
NRF_LOG_INFO("disconnect; reason=%d", event->disconnect.reason);
|
||||||
|
|
||||||
/* Connection terminated; resume advertising. */
|
/* Connection terminated; resume advertising. */
|
||||||
connectionHandle = BLE_HS_CONN_HANDLE_NONE;
|
connectionHandle = BLE_HS_CONN_HANDLE_NONE;
|
||||||
|
|
|
@ -38,8 +38,8 @@ void SystemTask::Process(void *instance) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTask::Work() {
|
void SystemTask::Work() {
|
||||||
// watchdog.Setup(7);
|
watchdog.Setup(7);
|
||||||
// watchdog.Start();
|
watchdog.Start();
|
||||||
NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::Watchdog::ResetReasonToString(watchdog.ResetReason()));
|
NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::Watchdog::ResetReasonToString(watchdog.ResetReason()));
|
||||||
APP_GPIOTE_INIT(2);
|
APP_GPIOTE_INIT(2);
|
||||||
|
|
||||||
|
|
|
@ -282,8 +282,8 @@ static inline uint32_t
|
||||||
ble_npl_hw_enter_critical(void)
|
ble_npl_hw_enter_critical(void)
|
||||||
{
|
{
|
||||||
//vPortEnterCritical();
|
//vPortEnterCritical();
|
||||||
npl_freertos_hw_enter_critical();
|
|
||||||
return 0;
|
return npl_freertos_hw_enter_critical();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
|
|
@ -184,8 +184,11 @@ void nimble_port_init(void) {
|
||||||
ble_hs_init();
|
ble_hs_init();
|
||||||
ble_store_ram_init();
|
ble_store_ram_init();
|
||||||
|
|
||||||
hal_timer_init(5, NULL);
|
int res;
|
||||||
os_cputime_init(32768);
|
res = hal_timer_init(5, NULL);
|
||||||
|
ASSERT(res == 0);
|
||||||
|
res = os_cputime_init(32768);
|
||||||
|
ASSERT(res == 0);
|
||||||
ble_ll_init();
|
ble_ll_init();
|
||||||
ble_hci_ram_init();
|
ble_hci_ram_init();
|
||||||
nimble_port_freertos_init(BleHost);
|
nimble_port_freertos_init(BleHost);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user