Merge branch 'nimble_1_3_0' into develop
This commit is contained in:
commit
f8ffb405a2
|
@ -132,6 +132,7 @@ set(NIMBLE_SRC
|
|||
libs/mynewt-nimble/nimble/host/src/ble_hs_stop.c
|
||||
libs/mynewt-nimble/nimble/host/src/ble_hs_startup.c
|
||||
libs/mynewt-nimble/nimble/host/store/ram/src/ble_store_ram.c
|
||||
libs/mynewt-nimble/nimble/host/src/ble_monitor.c
|
||||
libs/mynewt-nimble/nimble/transport/ram/src/ble_hci_ram.c
|
||||
libs/mynewt-nimble/nimble/controller/src/ble_ll.c
|
||||
libs/mynewt-nimble/nimble/controller/src/ble_ll_rand.c
|
||||
|
|
|
@ -17,8 +17,12 @@ int AlertNotificationCallback(uint16_t conn_handle, uint16_t attr_handle, struct
|
|||
}
|
||||
|
||||
void AlertNotificationService::Init() {
|
||||
ble_gatts_count_cfg(serviceDefinition);
|
||||
ble_gatts_add_svcs(serviceDefinition);
|
||||
int res;
|
||||
res = ble_gatts_count_cfg(serviceDefinition);
|
||||
ASSERT(res == 0);
|
||||
|
||||
res = ble_gatts_add_svcs(serviceDefinition);
|
||||
ASSERT(res == 0);
|
||||
}
|
||||
|
||||
AlertNotificationService::AlertNotificationService ( Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::NotificationManager& notificationManager ) : m_systemTask{systemTask}, m_notificationManager{notificationManager},
|
||||
|
|
|
@ -13,8 +13,12 @@ int CTSCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_acce
|
|||
}
|
||||
|
||||
void CurrentTimeService::Init() {
|
||||
ble_gatts_count_cfg(serviceDefinition);
|
||||
ble_gatts_add_svcs(serviceDefinition);
|
||||
int res;
|
||||
res = ble_gatts_count_cfg(serviceDefinition);
|
||||
ASSERT(res == 0);
|
||||
|
||||
res = ble_gatts_add_svcs(serviceDefinition);
|
||||
ASSERT(res == 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,8 +15,12 @@ int DeviceInformationCallback(uint16_t conn_handle, uint16_t attr_handle, struct
|
|||
}
|
||||
|
||||
void DeviceInformationService::Init() {
|
||||
ble_gatts_count_cfg(serviceDefinition);
|
||||
ble_gatts_add_svcs(serviceDefinition);
|
||||
int res = 0;
|
||||
res = ble_gatts_count_cfg(serviceDefinition);
|
||||
ASSERT(res == 0);
|
||||
|
||||
res = ble_gatts_add_svcs(serviceDefinition);
|
||||
ASSERT(res == 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -74,8 +74,12 @@ DfuService::DfuService(Pinetime::System::SystemTask &systemTask, Pinetime::Contr
|
|||
}
|
||||
|
||||
void DfuService::Init() {
|
||||
ble_gatts_count_cfg(serviceDefinition);
|
||||
ble_gatts_add_svcs(serviceDefinition);
|
||||
int res;
|
||||
res = ble_gatts_count_cfg(serviceDefinition);
|
||||
ASSERT(res == 0);
|
||||
|
||||
res = ble_gatts_add_svcs(serviceDefinition);
|
||||
ASSERT(res == 0);
|
||||
}
|
||||
|
||||
int DfuService::OnServiceData(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt *context) {
|
||||
|
|
|
@ -251,6 +251,14 @@ void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )
|
|||
else
|
||||
#endif
|
||||
{
|
||||
// Fix ERRATA 87 (https://infocenter.nordicsemi.com/index.jsp?topic=%252Fcom.nordic.infocenter.sdk5.v11.0.0%252Findex.html&cp=4_0_0)
|
||||
// Clear FPU interrupt before going to sleep. This prevent unexpected wake-up.
|
||||
#define FPU_EXCEPTION_MASK 0x0000009F
|
||||
/* Clear exceptions and PendingIRQ from the FPU unit */
|
||||
__set_FPSCR(__get_FPSCR() & ~(FPU_EXCEPTION_MASK));
|
||||
(void) __get_FPSCR();
|
||||
NVIC_ClearPendingIRQ(FPU_IRQn);
|
||||
|
||||
/* No SD - we would just block interrupts globally.
|
||||
* BASEPRI cannot be used for that because it would prevent WFE from wake up.
|
||||
*/
|
||||
|
|
|
@ -106,8 +106,8 @@ extern void vPortEnterCritical( void );
|
|||
extern void vPortExitCritical( void );
|
||||
#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortRaiseBASEPRI()
|
||||
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortSetBASEPRI(x)
|
||||
#define portDISABLE_INTERRUPTS() vPortRaiseBASEPRI()
|
||||
#define portENABLE_INTERRUPTS() vPortSetBASEPRI(0)
|
||||
#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" )
|
||||
#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" )
|
||||
#define portENTER_CRITICAL() vPortEnterCritical()
|
||||
#define portEXIT_CRITICAL() vPortExitCritical()
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ void SystemTask::Process(void *instance) {
|
|||
}
|
||||
|
||||
void SystemTask::Work() {
|
||||
watchdog.Setup(7);
|
||||
watchdog.Start();
|
||||
//watchdog.Setup(7);
|
||||
//watchdog.Start();
|
||||
NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::Watchdog::ResetReasonToString(watchdog.ResetReason()));
|
||||
APP_GPIOTE_INIT(2);
|
||||
|
||||
|
|
|
@ -2691,25 +2691,12 @@ cmd_security_unpair(int argc, char **argv)
|
|||
{
|
||||
ble_addr_t peer;
|
||||
int rc;
|
||||
int oldest;
|
||||
|
||||
rc = parse_arg_all(argc - 1, argv + 1);
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = parse_arg_bool_dflt("oldest", 0, &oldest);
|
||||
if (rc != 0) {
|
||||
console_printf("invalid 'oldest' parameter\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (oldest) {
|
||||
rc = ble_gap_unpair_oldest_peer();
|
||||
console_printf("Unpair oldest status: 0x%02x\n", rc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
rc = parse_dev_addr("peer_", cmd_peer_addr_types, &peer);
|
||||
if (rc != 0) {
|
||||
console_printf("invalid 'peer_addr' parameter\n");
|
||||
|
@ -2727,7 +2714,6 @@ cmd_security_unpair(int argc, char **argv)
|
|||
|
||||
#if MYNEWT_VAL(SHELL_CMD_HELP)
|
||||
static const struct shell_param security_unpair_params[] = {
|
||||
{"oldest", "usage: =[true|false], default: false"},
|
||||
{"peer_addr_type", "usage: =[public|random|public_id|random_id], default: public"},
|
||||
{"peer_addr", "usage: =[XX:XX:XX:XX:XX:XX]"},
|
||||
{NULL, NULL}
|
||||
|
|
|
@ -546,9 +546,6 @@ int ble_ll_rand_data_get(uint8_t *buf, uint8_t len);
|
|||
void ble_ll_rand_prand_get(uint8_t *prand);
|
||||
int ble_ll_rand_start(void);
|
||||
|
||||
// TODO added by JF, don't know why I need this?
|
||||
void ble_ll_task(void *arg);
|
||||
|
||||
static inline int
|
||||
ble_ll_get_addr_type(uint8_t txrxflag)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <sdk/components/libraries/log/nrf_log.h>
|
||||
#include "sysinit/sysinit.h"
|
||||
#include "syscfg/syscfg.h"
|
||||
#include "os/os.h"
|
||||
|
|
|
@ -131,7 +131,6 @@ struct ble_ll_adv_sm
|
|||
uint8_t aux_index : 1;
|
||||
uint8_t aux_first_pdu : 1;
|
||||
uint8_t aux_not_scanned : 1;
|
||||
uint8_t aux_dropped : 1;
|
||||
struct ble_mbuf_hdr *rx_ble_hdr;
|
||||
struct os_mbuf **aux_data;
|
||||
struct ble_ll_adv_aux aux[2];
|
||||
|
@ -1270,7 +1269,7 @@ ble_ll_adv_secondary_tx_start_cb(struct ble_ll_sched_item *sch)
|
|||
rc = ble_phy_tx_set_start_time(txstart, sch->remainder);
|
||||
if (rc) {
|
||||
STATS_INC(ble_ll_stats, adv_late_starts);
|
||||
goto adv_aux_dropped;
|
||||
goto adv_tx_done;
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION)
|
||||
|
@ -1305,7 +1304,7 @@ ble_ll_adv_secondary_tx_start_cb(struct ble_ll_sched_item *sch)
|
|||
/* Transmit advertisement */
|
||||
rc = ble_phy_tx(pducb, advsm, end_trans);
|
||||
if (rc) {
|
||||
goto adv_aux_dropped;
|
||||
goto adv_tx_done;
|
||||
}
|
||||
|
||||
/* Enable/disable whitelisting based on filter policy */
|
||||
|
@ -1323,8 +1322,7 @@ ble_ll_adv_secondary_tx_start_cb(struct ble_ll_sched_item *sch)
|
|||
|
||||
return BLE_LL_SCHED_STATE_RUNNING;
|
||||
|
||||
adv_aux_dropped:
|
||||
advsm->aux_dropped = 1;
|
||||
adv_tx_done:
|
||||
ble_ll_adv_tx_done(advsm);
|
||||
return BLE_LL_SCHED_STATE_DONE;
|
||||
}
|
||||
|
@ -1556,7 +1554,6 @@ ble_ll_adv_aux_schedule_first(struct ble_ll_adv_sm *advsm)
|
|||
advsm->aux_index = 0;
|
||||
advsm->aux_first_pdu = 1;
|
||||
advsm->aux_not_scanned = 0;
|
||||
advsm->aux_dropped = 0;
|
||||
|
||||
aux = AUX_CURRENT(advsm);
|
||||
ble_ll_adv_aux_calculate(advsm, aux, 0);
|
||||
|
@ -4839,11 +4836,6 @@ ble_ll_adv_sec_done(struct ble_ll_adv_sm *advsm)
|
|||
/* We don't need RF anymore */
|
||||
ble_ll_rfmgmt_release();
|
||||
|
||||
if (advsm->aux_dropped) {
|
||||
ble_ll_adv_drop_event(advsm);
|
||||
return;
|
||||
}
|
||||
|
||||
if (advsm->aux_not_scanned) {
|
||||
ble_ll_sched_rmv_elem(&aux_next->sch);
|
||||
}
|
||||
|
|
|
@ -617,7 +617,7 @@ ble_ll_scan_add_scan_rsp_adv(uint8_t *addr, uint8_t txadd,
|
|||
static int
|
||||
ble_ll_hci_send_legacy_ext_adv_report(uint8_t evtype,
|
||||
const uint8_t *addr, uint8_t addr_type,
|
||||
int8_t rssi,
|
||||
uint8_t rssi,
|
||||
uint8_t adv_data_len,
|
||||
struct os_mbuf *adv_data,
|
||||
const uint8_t *inita, uint8_t inita_type)
|
||||
|
@ -1991,10 +1991,10 @@ ble_ll_scan_rx_filter(struct ble_mbuf_hdr *hdr, struct ble_ll_scan_addr_data *ad
|
|||
{
|
||||
struct ble_ll_scan_sm *scansm = &g_ble_ll_scan_sm;
|
||||
struct ble_ll_scan_params *scanp = scansm->scanp;
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
|
||||
struct ble_ll_aux_data *aux_data = hdr->rxinfo.user_data;
|
||||
#endif
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
|
||||
struct ble_mbuf_hdr_rxinfo *rxinfo = &hdr->rxinfo;
|
||||
struct ble_ll_resolv_entry *rl = NULL;
|
||||
#endif
|
||||
|
@ -2227,7 +2227,6 @@ ble_ll_scan_rx_isr_on_aux(uint8_t pdu_type, uint8_t *rxbuf,
|
|||
*/
|
||||
if (aux_data->flags & BLE_LL_AUX_IS_MATCHED) {
|
||||
rxinfo->flags |= BLE_MBUF_HDR_F_DEVMATCH;
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
|
||||
rxinfo->rpa_index = aux_data->rpa_index;
|
||||
if (rxinfo->rpa_index >= 0) {
|
||||
rxinfo->flags |= BLE_MBUF_HDR_F_RESOLVED;
|
||||
|
@ -2235,7 +2234,6 @@ ble_ll_scan_rx_isr_on_aux(uint8_t pdu_type, uint8_t *rxbuf,
|
|||
if (aux_data->flags & BLE_LL_AUX_IS_TARGETA_RESOLVED) {
|
||||
rxinfo->flags |= BLE_MBUF_HDR_F_TARGETA_RESOLVED;
|
||||
}
|
||||
#endif
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <sdk/components/libraries/log/nrf_log.h>
|
||||
#include "syscfg/syscfg.h"
|
||||
#include "os/os.h"
|
||||
#include "ble/xcvr.h"
|
||||
|
|
|
@ -1896,20 +1896,6 @@ int ble_gap_unpair(const ble_addr_t *peer_addr);
|
|||
*/
|
||||
int ble_gap_unpair_oldest_peer(void);
|
||||
|
||||
/**
|
||||
* Similar to `ble_gap_unpair_oldest_peer()`, except it makes sure that the
|
||||
* peer received in input parameters is not deleted.
|
||||
*
|
||||
* @param peer_addr Address of the peer (not to be deleted)
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE host HCI return code if the controller
|
||||
* rejected the request;
|
||||
* A BLE host core return code on unexpected
|
||||
* error.
|
||||
*/
|
||||
int ble_gap_unpair_oldest_except(const ble_addr_t *peer_addr);
|
||||
|
||||
#define BLE_GAP_PRIVATE_MODE_NETWORK 0
|
||||
#define BLE_GAP_PRIVATE_MODE_DEVICE 1
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!-- START ENCRYPTED FILE --->
|
||||
<!-- START ENCRYPTED FILE --->
|
||||
M'&/JP\$+#X83?)"[ M2E=\N*7*U 5)JSKT(5#=>@^/#]IP*[GTZ0%0]$F(/$
|
||||
MEK[V7>349??;!JZJNFZ CK=QGD^FOYV^FU>"DK<@0U*##HV\H9&_%["5IK@1
|
||||
MA9F,FJO2P^3:4_]04%-0T%9=^XCMWKF"L$[)%)G>_I 0Q?@:H)&1HX)7VY&.
|
||||
|
@ -1023,4 +1023,4 @@ M<74&Z:0BS4[#$;M2_1""EZVO@$B^"0'V'W:7^@-<RY.=,$D<>]G?*\B>0M(-
|
|||
M6MF1FM+ ?,?3[N*1EI"$AXF#@6P-FU/4\QF?O!&%CE5*6J2'@QDYV?_04-O)
|
||||
M7Z 6N;C7E_4<F/8XVG7AJ7J1LH.IECZ6%G $HMQ2FZX'!S+=;-"'3%ZWD\!W
|
||||
L@U91N$5;H(.IY7/\[ +<DK:=41RCLZB8DY:;7E]*"<<2\\K1C(F(AZJX39
|
||||
<!-- END ENCRYPTED FILE --->
|
||||
<!-- END ENCRYPTED FILE --->
|
||||
|
|
|
@ -286,4 +286,4 @@
|
|||
<item><table>7</table><row>3</row></item>
|
||||
</profile>
|
||||
</pics>
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -1020,7 +1020,7 @@ ble_gap_slave_set_timer(uint32_t ticks_from_now)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if (NIMBLE_BLE_CONNECT || NIMBLE_BLE_SCAN)
|
||||
#if NIMBLE_BLE_CONNECT
|
||||
/**
|
||||
* Called when an error is encountered while the master-connection-fsm is
|
||||
* active.
|
||||
|
@ -1034,22 +1034,12 @@ ble_gap_master_failed(int status)
|
|||
ble_gap_master_connect_failure(status);
|
||||
break;
|
||||
|
||||
#if NIMBLE_BLE_SCAN
|
||||
case BLE_GAP_OP_M_DISC:
|
||||
STATS_INC(ble_gap_stats, initiate_fail);
|
||||
ble_gap_disc_complete();
|
||||
ble_gap_master_reset_state();
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
BLE_HS_DBG_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NIMBLE_BLE_CONNECT
|
||||
static void
|
||||
ble_gap_update_failed(uint16_t conn_handle, int status)
|
||||
{
|
||||
|
@ -1247,46 +1237,6 @@ ble_gap_adv_active_instance(uint8_t instance)
|
|||
return ble_gap_slave[instance].op == BLE_GAP_OP_S_ADV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears advertisement and discovery state. This function is necessary
|
||||
* when the controller loses its active state (e.g. on stack reset).
|
||||
*/
|
||||
void
|
||||
ble_gap_reset_state(int reason)
|
||||
{
|
||||
uint16_t conn_handle;
|
||||
|
||||
while (1) {
|
||||
conn_handle = ble_hs_atomic_first_conn_handle();
|
||||
if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
|
||||
break;
|
||||
}
|
||||
|
||||
ble_gap_conn_broken(conn_handle, reason);
|
||||
}
|
||||
|
||||
#if NIMBLE_BLE_ADVERTISE
|
||||
#if MYNEWT_VAL(BLE_EXT_ADV)
|
||||
uint8_t i;
|
||||
for (i = 0; i < BLE_ADV_INSTANCES; i++) {
|
||||
if (ble_gap_adv_active_instance(i)) {
|
||||
/* Indicate to application that advertising has stopped. */
|
||||
ble_gap_adv_finished(i, reason, 0, 0);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (ble_gap_adv_active_instance(0)) {
|
||||
/* Indicate to application that advertising has stopped. */
|
||||
ble_gap_adv_finished(0, reason, 0, 0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (NIMBLE_BLE_SCAN || NIMBLE_BLE_CONNECT)
|
||||
ble_gap_master_failed(reason);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if NIMBLE_BLE_CONNECT
|
||||
static int
|
||||
ble_gap_accept_master_conn(void)
|
||||
|
@ -1993,6 +1943,7 @@ ble_gap_update_timer(void)
|
|||
ble_hs_unlock();
|
||||
|
||||
if (entry != NULL) {
|
||||
ble_gap_update_notify(conn_handle, BLE_HS_ETIMEOUT);
|
||||
ble_gap_update_entry_free(entry);
|
||||
}
|
||||
} while (entry != NULL);
|
||||
|
@ -5594,7 +5545,7 @@ ble_gap_unpair_oldest_peer(void)
|
|||
}
|
||||
|
||||
if (num_peers == 0) {
|
||||
return BLE_HS_ENOENT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
rc = ble_gap_unpair(&oldest_peer_id_addr);
|
||||
|
@ -5605,36 +5556,6 @@ ble_gap_unpair_oldest_peer(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ble_gap_unpair_oldest_except(const ble_addr_t *peer_addr)
|
||||
{
|
||||
ble_addr_t peer_id_addrs[MYNEWT_VAL(BLE_STORE_MAX_BONDS)];
|
||||
int num_peers;
|
||||
int rc, i;
|
||||
|
||||
rc = ble_store_util_bonded_peers(
|
||||
&peer_id_addrs[0], &num_peers, MYNEWT_VAL(BLE_STORE_MAX_BONDS));
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (num_peers == 0) {
|
||||
return BLE_HS_ENOENT;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_peers; i++) {
|
||||
if (ble_addr_cmp(peer_addr, &peer_id_addrs[i]) != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= num_peers) {
|
||||
return BLE_HS_ENOMEM;
|
||||
}
|
||||
|
||||
return ble_gap_unpair(&peer_id_addrs[i]);
|
||||
}
|
||||
|
||||
void
|
||||
ble_gap_passkey_event(uint16_t conn_handle,
|
||||
struct ble_gap_passkey_params *passkey_params)
|
||||
|
|
|
@ -136,7 +136,6 @@ void ble_gap_preempt(void);
|
|||
void ble_gap_preempt_done(void);
|
||||
|
||||
int ble_gap_terminate_with_conn(struct ble_hs_conn *conn, uint8_t hci_reason);
|
||||
void ble_gap_reset_state(int reason);
|
||||
void ble_gap_conn_broken(uint16_t conn_handle, int reason);
|
||||
int32_t ble_gap_timer(void);
|
||||
|
||||
|
|
|
@ -361,6 +361,7 @@ ble_hs_sync(void)
|
|||
static int
|
||||
ble_hs_reset(void)
|
||||
{
|
||||
uint16_t conn_handle;
|
||||
int rc;
|
||||
|
||||
STATS_INC(ble_hs_stats, reset);
|
||||
|
@ -375,8 +376,14 @@ ble_hs_reset(void)
|
|||
|
||||
ble_hs_clear_rx_queue();
|
||||
|
||||
/* Clear adverising and scanning states. */
|
||||
ble_gap_reset_state(ble_hs_reset_reason);
|
||||
while (1) {
|
||||
conn_handle = ble_hs_atomic_first_conn_handle();
|
||||
if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
|
||||
break;
|
||||
}
|
||||
|
||||
ble_gap_conn_broken(conn_handle, ble_hs_reset_reason);
|
||||
}
|
||||
|
||||
/* Clear configured addresses. */
|
||||
ble_hs_id_reset();
|
||||
|
|
|
@ -327,7 +327,6 @@ ble_hs_conn_find_by_addr(const ble_addr_t *addr)
|
|||
#endif
|
||||
|
||||
struct ble_hs_conn *conn;
|
||||
struct ble_hs_conn_addrs addrs;
|
||||
|
||||
BLE_HS_DBG_ASSERT(ble_hs_locked_by_cur_task());
|
||||
|
||||
|
@ -344,14 +343,6 @@ ble_hs_conn_find_by_addr(const ble_addr_t *addr)
|
|||
if (ble_addr_cmp(&conn->bhc_peer_addr, addr) == 0) {
|
||||
return conn;
|
||||
}
|
||||
if (conn->bhc_peer_addr.type < BLE_OWN_ADDR_RPA_PUBLIC_DEFAULT) {
|
||||
continue;
|
||||
}
|
||||
/*If type 0x02 or 0x03 is used, let's double check if address is good */
|
||||
ble_hs_conn_addrs(conn, &addrs);
|
||||
if (ble_addr_cmp(&addrs.peer_id_addr, addr) == 0) {
|
||||
return conn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ ble_l2cap_coc_create_server(uint16_t psm, uint16_t mtu,
|
|||
|
||||
srv = ble_l2cap_coc_srv_alloc();
|
||||
if (!srv) {
|
||||
return BLE_HS_ENOMEM;
|
||||
return BLE_HS_ENOMEM;
|
||||
}
|
||||
|
||||
srv->psm = psm;
|
||||
|
@ -440,7 +440,6 @@ ble_l2cap_coc_continue_tx(struct ble_l2cap_chan *chan)
|
|||
BLE_HS_LOG(DEBUG, "Sending SDU len=%d\n", OS_MBUF_PKTLEN(tx->sdu));
|
||||
rc = os_mbuf_append(txom, &l, sizeof(uint16_t));
|
||||
if (rc) {
|
||||
rc = BLE_HS_ENOMEM;
|
||||
BLE_HS_LOG(DEBUG, "Could not append data rc=%d", rc);
|
||||
goto failed;
|
||||
}
|
||||
|
@ -453,9 +452,8 @@ ble_l2cap_coc_continue_tx(struct ble_l2cap_chan *chan)
|
|||
rc = os_mbuf_appendfrom(txom, tx->sdu, tx->data_offset,
|
||||
len - sdu_size_offset);
|
||||
if (rc) {
|
||||
rc = BLE_HS_ENOMEM;
|
||||
BLE_HS_LOG(DEBUG, "Could not append data rc=%d", rc);
|
||||
goto failed;
|
||||
goto failed;
|
||||
}
|
||||
|
||||
ble_hs_lock();
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "host/ble_monitor.h"
|
||||
|
||||
#if BLE_MONITOR
|
||||
|
@ -28,13 +29,14 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include <libs/mynewt-nimble/porting/nimble/include/os/os_cputime.h>
|
||||
#include "os/os.h"
|
||||
#include "log/log.h"
|
||||
#if MYNEWT_VAL(BLE_MONITOR_UART)
|
||||
#include "uart/uart.h"
|
||||
#endif
|
||||
#if MYNEWT_VAL(BLE_MONITOR_RTT)
|
||||
#include "rtt/SEGGER_RTT.h"
|
||||
#include "SEGGER_RTT.h"
|
||||
#endif
|
||||
#include "ble_hs_priv.h"
|
||||
#include "ble_monitor_priv.h"
|
||||
|
@ -236,7 +238,7 @@ monitor_write_header(uint16_t opcode, uint16_t len)
|
|||
hdr.flags = 0;
|
||||
|
||||
/* Use uptime for timestamp */
|
||||
ts = os_get_uptime_usec();
|
||||
ts = os_cputime_ticks_to_usecs(os_cputime_get32());
|
||||
|
||||
/*
|
||||
* btsnoop specification states that fields of extended header must be
|
||||
|
@ -266,6 +268,17 @@ btmon_write(FILE *instance, const char *bp, size_t n)
|
|||
return n;
|
||||
}
|
||||
|
||||
struct File_methods
|
||||
{
|
||||
size_t (*write)(FILE* instance, const char *bp, size_t n);
|
||||
size_t (*read)(FILE* instance, char *bp, size_t n);
|
||||
};
|
||||
|
||||
struct File
|
||||
{
|
||||
const struct File_methods *vmt;
|
||||
};
|
||||
|
||||
static FILE *btmon = (FILE *) &(struct File) {
|
||||
.vmt = &(struct File_methods) {
|
||||
.write = btmon_write,
|
||||
|
@ -276,7 +289,7 @@ static FILE *btmon = (FILE *) &(struct File) {
|
|||
static void
|
||||
drops_tmp_cb(struct ble_npl_event *ev)
|
||||
{
|
||||
ble_npl_mutex_pend(&lock, OS_TIMEOUT_NEVER);
|
||||
ble_npl_mutex_pend(&lock, portMAX_DELAY);
|
||||
|
||||
/*
|
||||
* There's no "nop" in btsnoop protocol so we just send empty system note
|
||||
|
@ -345,7 +358,7 @@ ble_monitor_init(void)
|
|||
int
|
||||
ble_monitor_send(uint16_t opcode, const void *data, size_t len)
|
||||
{
|
||||
ble_npl_mutex_pend(&lock, OS_TIMEOUT_NEVER);
|
||||
ble_npl_mutex_pend(&lock, portMAX_DELAY);
|
||||
|
||||
monitor_write_header(opcode, len);
|
||||
monitor_write(data, len);
|
||||
|
@ -367,7 +380,7 @@ ble_monitor_send_om(uint16_t opcode, const struct os_mbuf *om)
|
|||
om_tmp = SLIST_NEXT(om_tmp, om_next);
|
||||
}
|
||||
|
||||
ble_npl_mutex_pend(&lock, OS_TIMEOUT_NEVER);
|
||||
ble_npl_mutex_pend(&lock, portMAX_DELAY);
|
||||
|
||||
monitor_write_header(opcode, length);
|
||||
|
||||
|
@ -429,7 +442,7 @@ ble_monitor_log(int level, const char *fmt, ...)
|
|||
|
||||
ulog.ident_len = sizeof(id);
|
||||
|
||||
ble_npl_mutex_pend(&lock, OS_TIMEOUT_NEVER);
|
||||
ble_npl_mutex_pend(&lock, portMAX_DELAY);
|
||||
|
||||
monitor_write_header(BLE_MONITOR_OPCODE_USER_LOGGING,
|
||||
sizeof(ulog) + sizeof(id) + len + 1);
|
||||
|
|
|
@ -68,6 +68,8 @@ ble_sm_alg_encrypt(const uint8_t *key, const uint8_t *plaintext,
|
|||
|
||||
swap_buf(tmp, plaintext, 16);
|
||||
|
||||
|
||||
|
||||
if (tc_aes_encrypt(enc_data, tmp, &s) == TC_CRYPTO_FAIL) {
|
||||
return BLE_HS_EUNKNOWN;
|
||||
}
|
||||
|
|
|
@ -233,15 +233,13 @@ ble_store_util_status_rr(struct ble_store_status_event *event, void *arg)
|
|||
switch (event->event_code) {
|
||||
case BLE_STORE_EVENT_OVERFLOW:
|
||||
switch (event->overflow.obj_type) {
|
||||
case BLE_STORE_OBJ_TYPE_OUR_SEC:
|
||||
case BLE_STORE_OBJ_TYPE_PEER_SEC:
|
||||
return ble_gap_unpair_oldest_peer();
|
||||
case BLE_STORE_OBJ_TYPE_CCCD:
|
||||
/* Try unpairing oldest peer except current peer */
|
||||
return ble_gap_unpair_oldest_except(&event->overflow.value->cccd.peer_addr);
|
||||
case BLE_STORE_OBJ_TYPE_OUR_SEC:
|
||||
case BLE_STORE_OBJ_TYPE_PEER_SEC:
|
||||
case BLE_STORE_OBJ_TYPE_CCCD:
|
||||
return ble_gap_unpair_oldest_peer();
|
||||
|
||||
default:
|
||||
return BLE_HS_EUNKNOWN;
|
||||
default:
|
||||
return BLE_HS_EUNKNOWN;
|
||||
}
|
||||
|
||||
case BLE_STORE_EVENT_FULL:
|
||||
|
|
|
@ -2049,6 +2049,70 @@ ble_gap_test_util_update_l2cap(struct ble_gap_upd_params *params,
|
|||
peer_addr, 6) == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
ble_gap_test_util_update_no_l2cap_tmo(struct ble_gap_upd_params *params,
|
||||
int master)
|
||||
{
|
||||
struct ble_hs_conn *conn;
|
||||
int rc;
|
||||
|
||||
uint8_t peer_addr[6] = { 1, 2, 3, 4, 5, 6 };
|
||||
|
||||
ble_gap_test_util_init();
|
||||
|
||||
ble_hs_test_util_create_conn(2, peer_addr, ble_gap_test_util_connect_cb,
|
||||
NULL);
|
||||
|
||||
if (!master) {
|
||||
ble_hs_lock();
|
||||
conn = ble_hs_conn_find(2);
|
||||
TEST_ASSERT_FATAL(conn != NULL);
|
||||
conn->bhc_flags &= ~BLE_HS_CONN_F_MASTER;
|
||||
ble_hs_unlock();
|
||||
}
|
||||
|
||||
/* Erase callback info reported during connection establishment; we only
|
||||
* care about updates.
|
||||
*/
|
||||
ble_gap_test_util_reset_cb_info();
|
||||
|
||||
TEST_ASSERT(!ble_gap_master_in_progress());
|
||||
|
||||
rc = ble_hs_test_util_conn_update(2, params, 0);
|
||||
TEST_ASSERT(rc == 0);
|
||||
TEST_ASSERT(!ble_gap_master_in_progress());
|
||||
|
||||
/* Verify tx of connection update command. */
|
||||
ble_gap_test_util_verify_tx_update_conn(params);
|
||||
|
||||
/* Ensure no update event reported. */
|
||||
TEST_ASSERT(ble_gap_test_event.type == 0xff);
|
||||
|
||||
/* Advance 39 seconds; ensure no timeout reported. */
|
||||
os_time_advance(39 * OS_TICKS_PER_SEC);
|
||||
ble_gap_timer();
|
||||
TEST_ASSERT(ble_gap_test_event.type == 0xff);
|
||||
|
||||
/* Advance 40th second; ensure timeout reported. */
|
||||
os_time_advance(1 * OS_TICKS_PER_SEC);
|
||||
|
||||
/* Timeout will result in a terminate HCI command being sent; schedule ack
|
||||
* from controller.
|
||||
*/
|
||||
ble_hs_test_util_hci_ack_set_disconnect(0);
|
||||
|
||||
ble_gap_timer();
|
||||
|
||||
/* Verify terminate was sent. */
|
||||
ble_gap_test_util_verify_tx_disconnect();
|
||||
|
||||
TEST_ASSERT(ble_gap_test_event.type == BLE_GAP_EVENT_CONN_UPDATE);
|
||||
TEST_ASSERT(ble_gap_test_conn_status == BLE_HS_ETIMEOUT);
|
||||
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
|
||||
TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr.val,
|
||||
peer_addr, 6) == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
ble_gap_test_util_update_l2cap_tmo(struct ble_gap_upd_params *params,
|
||||
uint8_t hci_status, uint8_t event_status,
|
||||
|
@ -2918,6 +2982,9 @@ TEST_CASE_SELF(ble_gap_test_case_update_timeout)
|
|||
.max_ce_len = 456,
|
||||
};
|
||||
|
||||
/* No L2CAP. */
|
||||
ble_gap_test_util_update_no_l2cap_tmo(¶ms, 1);
|
||||
|
||||
/* L2CAP - Local unsupported; L2CAP timeout. */
|
||||
ble_gap_test_util_update_l2cap_tmo(¶ms, BLE_ERR_UNKNOWN_HCI_CMD, 0, 0);
|
||||
|
||||
|
|
|
@ -540,7 +540,7 @@ ble_hci_sock_config(void)
|
|||
|
||||
rc = bind(s, (struct sockaddr *)&shci, sizeof(shci));
|
||||
if (rc) {
|
||||
dprintf(1, "bind() failed %d hci%d\n", errno, shci.hci_dev);
|
||||
dprintf(1, "bind() failed %d\n", errno);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -20,6 +20,7 @@
|
|||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <sdk/components/libraries/log/nrf_log.h>
|
||||
#include "nimble/nimble_npl.h"
|
||||
|
||||
static inline bool
|
||||
|
|
|
@ -201,6 +201,7 @@ void nimble_port_init(void) {
|
|||
}
|
||||
|
||||
void nimble_port_ll_task_func(void *args) {
|
||||
extern void ble_ll_task(void *);
|
||||
ble_ll_task(args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12817,7 +12817,7 @@
|
|||
|
||||
// <o> SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Maximum number of upstream buffers.
|
||||
#ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS
|
||||
#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2
|
||||
#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 4
|
||||
#endif
|
||||
|
||||
// <o> SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of downstream buffer.
|
||||
|
|
Loading…
Reference in New Issue
Block a user