Bluetooth: Mesh: Move common gatt adv to adv.c
Since gatt adv send have common logic between adv_ext.c and adv_legacy.c, so move to adv.c Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
This commit is contained in:
parent
24b41622b4
commit
e922f4fc9f
4 changed files with 29 additions and 37 deletions
|
@ -26,6 +26,7 @@
|
|||
#include "host/ecc.h"
|
||||
#include "prov.h"
|
||||
#include "proxy.h"
|
||||
#include "pb_gatt_srv.h"
|
||||
|
||||
/* Window and Interval are equal for continuous scanning */
|
||||
#define MESH_SCAN_INTERVAL BT_MESH_ADV_SCAN_UNIT(BT_MESH_SCAN_INTERVAL_MS)
|
||||
|
@ -195,6 +196,21 @@ void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
|
|||
#endif /* CONFIG_BT_MESH_RELAY_ADV_SETS */
|
||||
}
|
||||
|
||||
int bt_mesh_adv_gatt_send(void)
|
||||
{
|
||||
if (bt_mesh_is_provisioned()) {
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) {
|
||||
BT_DBG("Proxy Advertising");
|
||||
return bt_mesh_proxy_adv_start();
|
||||
}
|
||||
} else if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
|
||||
BT_DBG("PB-GATT Advertising");
|
||||
return bt_mesh_pb_gatt_adv_start();
|
||||
}
|
||||
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static void bt_mesh_scan_cb(const bt_addr_le_t *addr, int8_t rssi,
|
||||
uint8_t adv_type, struct net_buf_simple *buf)
|
||||
{
|
||||
|
|
|
@ -73,6 +73,8 @@ void bt_mesh_adv_buf_local_ready(void);
|
|||
|
||||
void bt_mesh_adv_buf_relay_ready(void);
|
||||
|
||||
int bt_mesh_adv_gatt_send(void);
|
||||
|
||||
int bt_mesh_adv_gatt_start(const struct bt_le_adv_param *param, int32_t duration,
|
||||
const struct bt_data *ad, size_t ad_len,
|
||||
const struct bt_data *sd, size_t sd_len);
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "adv.h"
|
||||
#include "net.h"
|
||||
#include "proxy.h"
|
||||
#include "pb_gatt_srv.h"
|
||||
|
||||
/* Convert from ms to 0.625ms units */
|
||||
#define ADV_INT_FAST_MS 20
|
||||
|
@ -211,27 +210,6 @@ static int buf_send(struct ext_adv *adv, struct net_buf *buf)
|
|||
return err;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_MESH_GATT_SERVER)
|
||||
static void gatt_server_adv_send(struct ext_adv *adv)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (bt_mesh_is_provisioned()) {
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) {
|
||||
err = bt_mesh_proxy_adv_start();
|
||||
BT_DBG("Proxy Advertising");
|
||||
}
|
||||
} else if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
|
||||
err = bt_mesh_pb_gatt_adv_start();
|
||||
BT_DBG("PB-GATT Advertising");
|
||||
}
|
||||
|
||||
if (!err) {
|
||||
atomic_set_bit(adv->flags, ADV_FLAG_PROXY);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_MESH_GATT_SERVER */
|
||||
|
||||
static void send_pending_adv(struct k_work *work)
|
||||
{
|
||||
struct ext_adv *adv = CONTAINER_OF(work, struct ext_adv, work.work);
|
||||
|
@ -257,9 +235,13 @@ static void send_pending_adv(struct k_work *work)
|
|||
}
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_GATT_SERVER) &&
|
||||
adv == BT_MESH_ADV_EXT_GATT_SEPARATE_INS) {
|
||||
gatt_server_adv_send(adv);
|
||||
if (!IS_ENABLED(CONFIG_BT_MESH_GATT_SERVER) ||
|
||||
adv != BT_MESH_ADV_EXT_GATT_SEPARATE_INS) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bt_mesh_adv_gatt_send()) {
|
||||
atomic_set_bit(adv->flags, ADV_FLAG_PROXY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,7 +250,9 @@ static void send_pending_adv_gatt_handler(struct k_work *work)
|
|||
{
|
||||
struct ext_adv *adv = CONTAINER_OF(work, struct ext_adv, work.work);
|
||||
|
||||
gatt_server_adv_send(adv);
|
||||
if (!bt_mesh_adv_gatt_send()) {
|
||||
atomic_set_bit(adv->flags, ADV_FLAG_PROXY);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE */
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "beacon.h"
|
||||
#include "host/ecc.h"
|
||||
#include "prov.h"
|
||||
#include "proxy.h"
|
||||
#include "pb_gatt_srv.h"
|
||||
|
||||
/* Pre-5.0 controllers enforce a minimum interval of 100ms
|
||||
* whereas 5.0+ controllers can go down to 20ms.
|
||||
|
@ -138,15 +136,7 @@ static void adv_thread(void *p1, void *p2, void *p3)
|
|||
* to bt_mesh_adv_gatt_start:
|
||||
*/
|
||||
adv_timeout = SYS_FOREVER_MS;
|
||||
if (bt_mesh_is_provisioned()) {
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) {
|
||||
(void)bt_mesh_proxy_adv_start();
|
||||
BT_DBG("Proxy Advertising");
|
||||
}
|
||||
} else if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
|
||||
(void)bt_mesh_pb_gatt_adv_start();
|
||||
BT_DBG("PB-GATT Advertising");
|
||||
}
|
||||
(void)bt_mesh_adv_gatt_send();
|
||||
|
||||
buf = bt_mesh_adv_buf_get(SYS_TIMEOUT_MS(adv_timeout));
|
||||
bt_le_adv_stop();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue