<commit_before>/*  Bluetooth Mesh */

/*
 * Copyright (c) 2017 Intel Corporation
 * Copyright (c) 2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */
#include "mesh/mesh.h"
#include "prov.h"
#include "net.h"
#include "proxy.h"
#include "adv.h"
#include "prov_bearer.h"

#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROV)
#define LOG_MODULE_NAME bt_mesh_pb_gatt
#include "log/log.h"

struct prov_link {
	uint16_t conn_handle;
	const struct prov_bearer_cb *cb;
	void *cb_data;
	struct {
		u8_t  id;        /* Transaction ID */
		u8_t  prev_id;   /* Previous Transaction ID */
		u8_t  seg;       /* Bit-field of unreceived segments */
		u8_t  last_seg;  /* Last segment (to check length) */
		u8_t  fcs;       /* Expected FCS value */
		struct os_mbuf *buf;
	} rx;
	struct k_delayed_work prot_timer;
};

static struct prov_link link;

static void reset_state(void)
{
	link.conn_handle = BLE_HS_CONN_HANDLE_NONE;

	k_delayed_work_cancel(&link.prot_timer);
	memset(&link, 0, offsetof(struct prov_link, prot_timer));

	link.rx.buf = bt_mesh_proxy_get_buf();
}

static void protocol_timeout(struct ble_npl_event *work)
{
	const struct prov_bearer_cb *cb = link.cb;

	BT_DBG("Protocol timeout");

	reset_state();

	cb->link_closed(&pb_gatt, link.cb_data,
			PROV_BEARER_LINK_STATUS_TIMEOUT);
}

int bt_mesh_pb_gatt_recv(uint16_t conn_handle, struct os_mbuf *buf)
{<commit_msg>mesh: PB-GATT common link closed<commit_after>/*  Bluetooth Mesh */

/*
 * Copyright (c) 2017 Intel Corporation
 * Copyright (c) 2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */
#include "mesh/mesh.h"
#include "prov.h"
#include "net.h"
#include "proxy.h"
#include "adv.h"
#include "prov_bearer.h"

#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROV)
#define LOG_MODULE_NAME bt_mesh_pb_gatt
#include "log/log.h"

struct prov_link {
	uint16_t conn_handle;
	const struct prov_bearer_cb *cb;
	void *cb_data;
	struct {
		u8_t  id;        /* Transaction ID */
		u8_t  prev_id;   /* Previous Transaction ID */
		u8_t  seg;       /* Bit-field of unreceived segments */
		u8_t  last_seg;  /* Last segment (to check length) */
		u8_t  fcs;       /* Expected FCS value */
		struct os_mbuf *buf;
	} rx;
	struct k_delayed_work prot_timer;
};

static struct prov_link link;

static void reset_state(void)
{
	link.conn_handle = BLE_HS_CONN_HANDLE_NONE;

	k_delayed_work_cancel(&link.prot_timer);
	memset(&link, 0, offsetof(struct prov_link, prot_timer));

	link.rx.buf = bt_mesh_proxy_get_buf();
}

static void link_closed(enum prov_bearer_link_status status)
{
	const struct prov_bearer_cb *cb = link.cb;

	void *cb_data = link.cb_data;

	reset_state();

	cb->link_closed(&pb_gatt, cb_data, status);
}

static void protocol_timeout(struct ble_npl_event *work)
{
	BT_DBG("Protocol timeout");

	link_closed(PROV_BEARER_LINK_STATUS_TIMEOUT);
}

int bt_mesh_pb_gatt_recv(uint16_t conn_handle, struct os_mbuf *buf)
{
{'fraction_non_alphanumeric': 0.11243611584327087, 'fraction_numerical': 0.013628620102214651, 'mean_word_length': 4.50844277673546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '496093', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1145, 'n_words': 253}