Skip to content

Commit

Permalink
Update NimBLE core to esp-nimble @f566133
Browse files Browse the repository at this point in the history
  • Loading branch information
h2zero committed Jan 29, 2023
1 parent 0d9f039 commit ffc5ab7
Show file tree
Hide file tree
Showing 22 changed files with 836 additions and 86 deletions.
196 changes: 194 additions & 2 deletions src/nimble/nimble/host/include/host/ble_gap.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct hci_conn_update;
#define BLE_GAP_SCAN_WIN_MS(t) ((t) * 1000 / BLE_HCI_SCAN_ITVL)
#define BLE_GAP_CONN_ITVL_MS(t) ((t) * 1000 / BLE_HCI_CONN_ITVL)
#define BLE_GAP_SUPERVISION_TIMEOUT_MS(t) ((t) / 10)
#define BLE_GAP_PERIODIC_ITVL_MS(t) ((t) * 1000 / BLE_HCI_PERIODIC_ADV_ITVL)

/** 30 ms. */
#define BLE_GAP_ADV_FAST_INTERVAL1_MIN BLE_GAP_ADV_ITVL_MS(30)
Expand Down Expand Up @@ -135,6 +136,9 @@ struct hci_conn_update;
#define BLE_GAP_EVENT_PERIODIC_SYNC_LOST 22
#define BLE_GAP_EVENT_SCAN_REQ_RCVD 23
#define BLE_GAP_EVENT_PERIODIC_TRANSFER 24
#define BLE_GAP_EVENT_PATHLOSS_THRESHOLD 25
#define BLE_GAP_EVENT_TRANSMIT_POWER 26
#define BLE_GAP_EVENT_SUBRATE_CHANGE 27

/*** Reason codes for the subscribe GAP event. */

Expand Down Expand Up @@ -973,6 +977,82 @@ struct ble_gap_event {
uint8_t adv_clk_accuracy;
} periodic_transfer;
#endif

#if MYNEWT_VAL(BLE_POWER_CONTROL)
/**
* Represents a change in either local transmit power or remote transmit
* power. Valid for the following event types:
* o BLE_GAP_EVENT_PATHLOSS_THRESHOLD
*/

struct {
/** Connection handle */
uint16_t conn_handle;

/** Current Path Loss */
uint8_t current_path_loss;

/** Entered Zone */
uint8_t zone_entered;
} pathloss_threshold;

/**
* Represents crossing of path loss threshold set via LE Set Path Loss
* Reporting Parameter command. Valid for the following event types:
* o BLE_GAP_EVENT_TRANSMIT_POWER
*/

struct {
/** BLE_ERR_SUCCESS on success or error code on failure */
uint8_t status;

/** Connection Handle */
uint16_t conn_handle;

/** Reason indicating why event was sent */
uint8_t reason;

/** Advertising PHY */
uint8_t phy;

/** Transmit power Level */
uint8_t transmit_power_level;

/** Transmit Power Level Flag */
uint8_t transmit_power_level_flag;

/** Delta indicating change in transmit Power Level */
uint8_t delta;
} transmit_power;
#endif

#if MYNEWT_VAL(BLE_CONN_SUBRATING)
/**
* Represents a subrate change event that indicates connection subrate update procedure
* has completed and some parameters have changed Valid for
* the following event types:
* o BLE_GAP_EVENT_SUBRATE_CHANGE
*/
struct {
/** BLE_ERR_SUCCESS on success or error code on failure */
uint8_t status;

/** Connection Handle */
uint16_t conn_handle;

/** Subrate Factor */
uint16_t subrate_factor;

/** Peripheral Latency */
uint16_t periph_latency;

/** Continuation Number */
uint16_t cont_num;

/** Supervision Timeout */
uint16_t supervision_tmo;
} subrate_change;
#endif
};
};

Expand Down Expand Up @@ -1373,12 +1453,12 @@ struct ble_gap_periodic_adv_params {
/** If include TX power in advertising PDU */
unsigned int include_tx_power:1;

/** Minimum advertising interval in 0.625ms units, if 0 stack use sane
/** Minimum advertising interval in 1.25ms units, if 0 stack use sane
* defaults
*/
uint16_t itvl_min;

/** Maximum advertising interval in 0.625ms units, if 0 stack use sane
/** Maximum advertising interval in 1.25ms units, if 0 stack use sane
* defaults
*/
uint16_t itvl_max;
Expand Down Expand Up @@ -2113,6 +2193,45 @@ int ble_gap_set_prefered_default_le_phy(uint8_t tx_phys_mask,
int ble_gap_set_prefered_le_phy(uint16_t conn_handle, uint8_t tx_phys_mask,
uint8_t rx_phys_mask, uint16_t phy_opts);

#if MYNEWT_VAL(BLE_CONN_SUBRATING)
/**
* Set default subrate
*
* @param subrate_min Min subrate factor allowed in request by a peripheral
* @param subrate_max Max subrate factor allowed in request by a peripheral
* @param max_latency Max peripheral latency allowed in units of
* subrated conn interval.
*
* @param cont_num Min number of underlying conn event to remain active
* after a packet containing PDU with non-zero length field
* is sent or received in request by a peripheral.
*
* @param supervision_timeout Max supervision timeout allowed in request by a peripheral
*/
int ble_gap_set_default_subrate(uint16_t subrate_min, uint16_t subrate_max, uint16_t max_latency,
uint16_t cont_num, uint16_t supervision_timeout);

/**
* Subrate Request
*
* @param conn_handle Connection Handle of the ACL.
* @param subrate_min Min subrate factor to be applied
* @param subrate_max Max subrate factor to be applied
* @param max_latency Max peripheral latency allowed in units of
* subrated conn interval.
*
* @param cont_num Min number of underlying conn event to remain active
* after a packet containing PDU with non-zero length field
* is sent or received in request by a peripheral.
*
* @param supervision_timeout Max supervision timeout allowed for this connection
*/

int
ble_gap_subrate_req(uint16_t conn_handle, uint16_t subrate_min, uint16_t subrate_max,
uint16_t max_latency, uint16_t cont_num,
uint16_t supervision_timeout);
#endif
/**
* Event listener structure
*
Expand Down Expand Up @@ -2152,6 +2271,79 @@ int ble_gap_event_listener_register(struct ble_gap_event_listener *listener,
*/
int ble_gap_event_listener_unregister(struct ble_gap_event_listener *listener);

/**
* Enable Set Path Loss Reporting.
*
* @param conn_handle Connection handle
* @params enable 1: Enable
* 0: Disable
*
* @return 0 on success; nonzero on failure.
*/

int ble_gap_set_path_loss_reporting_enable(uint16_t conn_handle, uint8_t enable);

/**
* Enable Reporting of Transmit Power
*
* @param conn_handle Connection handle
* @params local_enable 1: Enable local transmit power reports
* 0: Disable local transmit power reports
*
* @params remote_enable 1: Enable remote transmit power reports
* 0: Disable remote transmit power reports
*
* @return 0 on success; nonzero on failure.
*/
int ble_gap_set_transmit_power_reporting_enable(uint16_t conn_handle,
uint8_t local_enable,
uint8_t remote_enable);

/**
* LE Enhanced Read Transmit Power Level
*
* @param conn_handle Connection handle
* @params phy Advertising Phy
*
* @params status 0 on success; nonzero on failure.
* @params conn_handle Connection handle
* @params phy Advertising Phy
*
* @params curr_tx_power_level Current trasnmit Power Level
*
* @params mx_tx_power_level Maximum transmit power level
*
* @return 0 on success; nonzero on failure.
*/
int ble_gap_enh_read_transmit_power_level(uint16_t conn_handle, uint8_t phy, uint8_t *out_status, uint8_t *out_phy ,
uint8_t *out_curr_tx_power_level, uint8_t *out_max_tx_power_level);

/**
* Read Remote Transmit Power Level
*
* @param conn_handle Connection handle
* @params phy Advertising Phy
*
* @return 0 on success; nonzero on failure.
*/
int ble_gap_read_remote_transmit_power_level(uint16_t conn_handle, uint8_t phy);

/**
* Set Path Loss Reproting Param
*
* @param conn_handle Connection handle
* @params high_threshold High Threshold value for path loss
* @params high_hysteresis Hysteresis value for high threshold
* @params low_threshold Low Threshold value for path loss
* @params low_hysteresis Hysteresis value for low threshold
* @params min_time_spent Minimum time controller observes the path loss
*
* @return 0 on success; nonzero on failure.
*/
int ble_gap_set_path_loss_reporting_param(uint16_t conn_handle, uint8_t high_threshold,
uint8_t high_hysteresis, uint8_t low_threshold,
uint8_t low_hysteresis, uint16_t min_time_spent);

#ifdef __cplusplus
}
#endif
Expand Down
21 changes: 21 additions & 0 deletions src/nimble/nimble/host/include/host/ble_gatt.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,12 @@ int ble_gattc_write_reliable(uint16_t conn_handle,
*
* @return 0 on success; nonzero on failure.
*/
int ble_gatts_notify_custom(uint16_t conn_handle, uint16_t att_handle,
struct os_mbuf *om);

/**
* Deprecated. Should not be used. Use ble_gatts_notify_custom instead.
*/
int ble_gattc_notify_custom(uint16_t conn_handle, uint16_t att_handle,
struct os_mbuf *om);

Expand All @@ -485,6 +491,11 @@ int ble_gattc_notify_custom(uint16_t conn_handle, uint16_t att_handle,
*
* @return 0 on success; nonzero on failure.
*/
int ble_gatts_notify(uint16_t conn_handle, uint16_t chr_val_handle);

/**
* Deprecated. Should not be used. Use ble_gatts_notify instead.
*/
int ble_gattc_notify(uint16_t conn_handle, uint16_t chr_val_handle);

/**
Expand All @@ -501,6 +512,11 @@ int ble_gattc_notify(uint16_t conn_handle, uint16_t chr_val_handle);
*
* @return 0 on success; nonzero on failure.
*/
int ble_gatts_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle,
struct os_mbuf *txom);
/**
* Deprecated. Should not be used. Use ble_gatts_indicate_custom instead.
*/
int ble_gattc_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle,
struct os_mbuf *txom);

Expand All @@ -516,6 +532,11 @@ int ble_gattc_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle,
*
* @return 0 on success; nonzero on failure.
*/
int ble_gatts_indicate(uint16_t conn_handle, uint16_t chr_val_handle);

/**
* Deprecated. Should not be used. Use ble_gatts_indicate instead.
*/
int ble_gattc_indicate(uint16_t conn_handle, uint16_t chr_val_handle);

int ble_gattc_init(void);
Expand Down
2 changes: 2 additions & 0 deletions src/nimble/nimble/host/include/host/ble_hs.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ extern "C" {
/** Connection handle not present */
#define BLE_HS_CONN_HANDLE_NONE 0xffff

#define BLE_HS_CTRL_DATA_HDR_SZ 0x4

/**
* @brief Bluetooth Host Error Code
* @defgroup bt_host_err Bluetooth Host Error Code
Expand Down
14 changes: 10 additions & 4 deletions src/nimble/nimble/host/include/host/ble_uuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,25 @@ typedef union {

#define BLE_UUID16_INIT(uuid16) \
{ \
.u.type = BLE_UUID_TYPE_16, \
.u = { \
.type = BLE_UUID_TYPE_16, \
}, \
.value = (uuid16), \
}

#define BLE_UUID32_INIT(uuid32) \
{ \
.u.type = BLE_UUID_TYPE_32, \
.u = { \
.type = BLE_UUID_TYPE_32, \
}, \
.value = (uuid32), \
}

#define BLE_UUID128_INIT(uuid128...) \
#define BLE_UUID128_INIT(uuid128 ...) \
{ \
.u.type = BLE_UUID_TYPE_128, \
.u = { \
.type = BLE_UUID_TYPE_128, \
}, \
.value = { uuid128 }, \
}

Expand Down
4 changes: 2 additions & 2 deletions src/nimble/nimble/host/mesh/src/proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ static int proxy_send(uint16_t conn_handle, const void *data, uint16_t len)
if (gatt_svc == MESH_GATT_PROXY) {
om = ble_hs_mbuf_from_flat(data, len);
assert(om);
err = ble_gattc_notify_custom(conn_handle, svc_handles.proxy_data_out_h, om);
err = ble_gatts_notify_custom(conn_handle, svc_handles.proxy_data_out_h, om);
notify_complete();
}
#endif
Expand All @@ -1008,7 +1008,7 @@ static int proxy_send(uint16_t conn_handle, const void *data, uint16_t len)
if (gatt_svc == MESH_GATT_PROV) {
om = ble_hs_mbuf_from_flat(data, len);
assert(om);
err = ble_gattc_notify_custom(conn_handle, svc_handles.prov_data_out_h, om);
err = ble_gatts_notify_custom(conn_handle, svc_handles.prov_data_out_h, om);
notify_complete();
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/nimble/nimble/host/services/ans/src/ble_svc_ans.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ ble_svc_ans_new_alert_notify(uint8_t cat_id, const char * info_str)
memcpy(&ble_svc_ans_new_alert_val[2], info_str, info_str_len);
}
}
return ble_gattc_notify(ble_svc_ans_conn_handle,
return ble_gatts_notify(ble_svc_ans_conn_handle,
ble_svc_ans_new_alert_val_handle);
}

Expand All @@ -407,7 +407,7 @@ ble_svc_ans_unr_alert_notify(uint8_t cat_id)
{
ble_svc_ans_unr_alert_stat[0] = cat_id;
ble_svc_ans_unr_alert_stat[1] = ble_svc_ans_unr_alert_cnt[cat_id];
return ble_gattc_notify(ble_svc_ans_conn_handle,
return ble_gatts_notify(ble_svc_ans_conn_handle,
ble_svc_ans_unr_alert_val_handle);
}

Expand Down
2 changes: 1 addition & 1 deletion src/nimble/nimble/host/src/ble_att_clt.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ ble_att_clt_rx_indicate(uint16_t conn_handle, struct os_mbuf **rxom)
#endif

/* No payload. */
ble_gattc_rx_indicate_rsp(conn_handle);
ble_gatts_rx_indicate_rsp(conn_handle);
return 0;
}

Expand Down
Loading

0 comments on commit ffc5ab7

Please sign in to comment.