<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Error with peripheral_uart_coded.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83912/error-with-peripheral_uart_coded</link><description>Hi, 
 Referring to the case, 
 https://devzone.nordicsemi.com/f/nordic-q-a/72660/nrf-connect-sdk-v-1-5-0-how-where-to-change-phy-and-tx-power-for-long-range-application 
 I used the peripheral_uart_coded.rar code, but when tried to flash it on the nRF5340</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 01 Feb 2022 09:12:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83912/error-with-peripheral_uart_coded" /><item><title>RE: Error with peripheral_uart_coded.</title><link>https://devzone.nordicsemi.com/thread/350594?ContentTypeID=1</link><pubDate>Tue, 01 Feb 2022 09:12:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8af41533-4aaa-44a1-8758-0cf78677d94d</guid><dc:creator>Alexander Thorstensen</dc:creator><description>&lt;p&gt;We got the desired result by writing the radio high voltage bit from cpunet before we enable bluetooth, similar to what is beeing done here:&lt;br /&gt;&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/58819/nrf5340-vreqctrl-for-additional-3-db-tx-power"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/58819/nrf5340-vreqctrl-for-additional-3-db-tx-power&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I am not sure if this is how + 3dB was intended to be activated, but it did the trick for us.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error with peripheral_uart_coded.</title><link>https://devzone.nordicsemi.com/thread/350576?ContentTypeID=1</link><pubDate>Tue, 01 Feb 2022 08:43:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34f7db66-7e42-4cf2-8818-9682b1ef86df</guid><dc:creator>KarthikKumar</dc:creator><description>&lt;p&gt;Hi Alexander,&lt;/p&gt;
&lt;p&gt;So how can that be corrected?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error with peripheral_uart_coded.</title><link>https://devzone.nordicsemi.com/thread/350486?ContentTypeID=1</link><pubDate>Mon, 31 Jan 2022 15:18:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a67ded2f-650b-4016-856a-ff1dfaa299a6</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I can confirm that I am also able to reproduce the issue, but I am still working on finding a solution. It only seems to be an issue on nRF5340 DK, as when trying the same application on a nRF52840 DK the TX power was changed from 0 to 3. Additionally, I tested the&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/zephyr/samples/bluetooth/hci_pwr_ctrl/README.html"&gt;HCI Power Control&lt;/a&gt;&amp;nbsp;sample in Zephyr, which the&amp;nbsp;set_tx_power() function is originally from, and the TX power is changed successfully on nRF5340 DK using that sample.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error with peripheral_uart_coded.</title><link>https://devzone.nordicsemi.com/thread/350372?ContentTypeID=1</link><pubDate>Mon, 31 Jan 2022 09:26:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70a49955-586b-4a89-9e85-07fcdab1783e</guid><dc:creator>Alexander Thorstensen</dc:creator><description>&lt;p&gt;I am using an idential implementation of set_tx_power, and I get the same result. Whenever I request +3 dB I get the Actual tx Power: 0 response.&lt;br /&gt;&lt;br /&gt; I spent some time digging and I suspect the request to set +3dB is reduced to a 0 dB request by a call to hal_radio_tx_power_floor() from deep down in the guts of the bluetooth driver / subsystem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error with peripheral_uart_coded.</title><link>https://devzone.nordicsemi.com/thread/349297?ContentTypeID=1</link><pubDate>Mon, 24 Jan 2022 14:18:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e815ffcd-55f0-46c8-9ac4-062d02261a80</guid><dc:creator>KarthikKumar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Irrespective of I change values its always 0. But I wNted to set it the the maximum TX_power of nRF5340 which is 3dB.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;int8_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;tx_power&lt;/span&gt;&lt;span&gt; = &lt;/span&gt;&lt;span&gt;0x03&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;set_tx_power&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;BT_HCI_VS_LL_HANDLE_TYPE_ADV&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;tx_power&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1643033882677v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Karthik Kumar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error with peripheral_uart_coded.</title><link>https://devzone.nordicsemi.com/thread/349288?ContentTypeID=1</link><pubDate>Mon, 24 Jan 2022 14:04:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:514f70be-ee48-42e8-a6fb-0fdf37fcec3b</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;In the peripheral code you set the variable tx_power to 0 in main():&lt;/p&gt;
&lt;p&gt;&lt;code&gt;int8_t tx_power = 0;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;And then&amp;nbsp;call&amp;nbsp;&lt;span&gt;set_tx_power() with tx_power as a parameter:&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;set_tx_power&lt;/span&gt;&lt;span&gt;(BT_HCI_VS_LL_HANDLE_TYPE_ADV,&lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;,tx_power);&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;So you are setting the tx power to 0 here.&lt;/p&gt;
&lt;p&gt;If this is not the case and you are actually calling&amp;nbsp;&lt;span&gt;set_tx_power() with&amp;nbsp;tx_power as something other than zero, can you tell me how you&amp;nbsp;can see that the TX power is set to 0? Do you have any logs from the device to share?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Marte&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error with peripheral_uart_coded.</title><link>https://devzone.nordicsemi.com/thread/349240?ContentTypeID=1</link><pubDate>Mon, 24 Jan 2022 12:25:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad9ec713-01e6-4b8f-b096-aa7cca2bb5d1</guid><dc:creator>KarthikKumar</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m setting the tx_power using the function,&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;strong&gt;static void set_tx_power(uint8_t handle_type, uint16_t handle, int8_t tx_pwr_lvl)&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;Later I&amp;#39;m trying to call this function in my main programme.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Peripheral code.&lt;/div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="text"&gt;/******************************************* TX Power*********************************************************************/
static void set_tx_power(uint8_t handle_type, uint16_t handle, int8_t tx_pwr_lvl)
{
	struct bt_hci_cp_vs_write_tx_power_level *cp;
	struct bt_hci_rp_vs_write_tx_power_level *rp;
	struct net_buf *buf, *rsp = NULL;
	int err;

	buf = bt_hci_cmd_create(BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL,
				sizeof(*cp));
	if (!buf) {
		printk(&amp;quot;Unable to allocate command buffer\n&amp;quot;);
		return;
	}

	cp = net_buf_add(buf, sizeof(*cp));
	cp-&amp;gt;handle = sys_cpu_to_le16(handle);
	cp-&amp;gt;handle_type = handle_type;
	cp-&amp;gt;tx_power_level = tx_pwr_lvl;

	err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL,
				   buf, &amp;amp;rsp);
	if (err) {
		uint8_t reason = rsp ?
			((struct bt_hci_rp_vs_write_tx_power_level *)
			  rsp-&amp;gt;data)-&amp;gt;status : 0;
		printk(&amp;quot;Set Tx power err: %d reason 0x%02x\n&amp;quot;, err, reason);
		return;
	}

	rp = (void *)rsp-&amp;gt;data;
	printk(&amp;quot;Actual Tx Power: %d\n&amp;quot;, rp-&amp;gt;selected_tx_power);

	net_buf_unref(rsp);
}

void main(void)
{
        int8_t tx_power = 0;
	int blink_status = 0;
	int err = 0;

	configure_gpio();

	err = uart_init();
	if (err) {
		error();
	}

	bt_conn_cb_register(&amp;amp;conn_callbacks);

	if (IS_ENABLED(CONFIG_BT_NUS_SECURITY_ENABLED)) {
		bt_conn_auth_cb_register(&amp;amp;conn_auth_callbacks);
	}

	err = bt_enable(NULL);
	if (err) {
		error();
	}
  
        set_tx_power(BT_HCI_VS_LL_HANDLE_TYPE_ADV,0,tx_power);

	LOG_INF(&amp;quot;Bluetooth initialized&amp;quot;);

	k_sem_give(&amp;amp;ble_init_ok);

	if (IS_ENABLED(CONFIG_SETTINGS)) {
		settings_load();
	}

	err = bt_nus_init(&amp;amp;nus_cb);
	if (err) {
		LOG_ERR(&amp;quot;Failed to initialize UART service (err: %d)&amp;quot;, err);
		return;
	}
        
    bt_ready();

	printk(&amp;quot;Starting Nordic UART service example c&amp;#39;est moi\n&amp;quot;);

	for (;;) {
		dk_set_led(RUN_STATUS_LED, (++blink_status) % 2);
		k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));

		/*ran_data();*/
		const uint8_t sensor_data =&amp;#39;d&amp;#39;;
		uint16_t length = 1;
		//uint32_t sd_ble_gap_rssi_start	( sd, NULL, NULL)
		//uint8_tsdc_hci_cmd_sp_read_rssi(constsdc_hci_cmd_sp_read_rssi_t*p_params, sdc_hci_cmd_sp_read_rssi_return_t*p_return);

		if (bt_nus_send(NULL, &amp;amp;sensor_data, length)) {
			
			LOG_WRN(&amp;quot;Failed to send data over BLE connection&amp;quot;);
			printk(&amp;quot;Failed to send data over BLE connectionl\n&amp;quot;);
		}
	}
}

void ble_write_thread(void)
{
	/* Don&amp;#39;t go any further until BLE is initialized */
	k_sem_take(&amp;amp;ble_init_ok, K_FOREVER);

	for (;;) {
		/* Wait indefinitely for data to be sent over bluetooth */
		struct uart_data_t *buf = k_fifo_get(&amp;amp;fifo_uart_rx_data,
						     K_FOREVER);

		//struct uart_user_data *buf ; 

		const uint8_t sensor_data =&amp;#39;d&amp;#39;;
		 uint16_t length = 1;
		 

		if (bt_nus_send(NULL, &amp;amp;sensor_data, length)) {
			LOG_WRN(&amp;quot;Failed to send data over BLE connection&amp;quot;);
			printk(&amp;quot;Failed to send data over BLE connectionl\n&amp;quot;);
		}

		k_free(buf);
	}
}

K_THREAD_DEFINE(ble_write_thread_id, STACKSIZE, ble_write_thread, NULL, NULL,
		NULL, PRIORITY, 0, 0);&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Also in counter part tried to modify central_uart into central_uart_coded_PHY, But unfortunately not able to make the connection with the peripheral_uart_coded. Can you also please help with this.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2018 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

/** @file
 *  @brief Nordic UART Service Client sample
 */
/****************************Coded PHY********************************/
#include &amp;lt;zephyr/types.h&amp;gt;
#include &amp;lt;stddef.h&amp;gt;

/*********************************************************************/
#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;sys/byteorder.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;

#include &amp;lt;bluetooth/bluetooth.h&amp;gt;
#include &amp;lt;bluetooth/hci.h&amp;gt;
#include &amp;lt;bluetooth/conn.h&amp;gt;
#include &amp;lt;bluetooth/uuid.h&amp;gt;
#include &amp;lt;bluetooth/gatt.h&amp;gt;

#include &amp;lt;bluetooth/services/nus.h&amp;gt;
#include &amp;lt;bluetooth/services/nus_client.h&amp;gt;
#include &amp;lt;bluetooth/gatt_dm.h&amp;gt;
#include &amp;lt;bluetooth/scan.h&amp;gt;

#include &amp;lt;settings/settings.h&amp;gt;

#include &amp;lt;drivers/uart.h&amp;gt;

#include &amp;lt;logging/log.h&amp;gt;

#define LOG_MODULE_NAME central_uart
LOG_MODULE_REGISTER(LOG_MODULE_NAME);

/* UART payload buffer element size. */
#define UART_BUF_SIZE 20

#define KEY_PASSKEY_ACCEPT DK_BTN1_MSK
#define KEY_PASSKEY_REJECT DK_BTN2_MSK

#define NUS_WRITE_TIMEOUT K_MSEC(150)
#define UART_WAIT_FOR_BUF_DELAY K_MSEC(50)
#define UART_RX_TIMEOUT 50

static const struct device *uart;
static struct k_work_delayable uart_work;

K_SEM_DEFINE(nus_write_sem, 0, 1);

struct uart_data_t {
	void *fifo_reserved;
	uint8_t  data[UART_BUF_SIZE];
	uint16_t len;
};

static K_FIFO_DEFINE(fifo_uart_tx_data);
static K_FIFO_DEFINE(fifo_uart_rx_data);

static struct bt_conn *default_conn;
static struct bt_nus_client nus_client;

static void ble_data_sent(struct bt_nus_client *nus, uint8_t err,
					const uint8_t *const data, uint16_t len)
{
	ARG_UNUSED(nus);

	struct uart_data_t *buf;

	/* Retrieve buffer context. */
	buf = CONTAINER_OF(data, struct uart_data_t, data);
	k_free(buf);

	k_sem_give(&amp;amp;nus_write_sem);

	if (err) {
		LOG_WRN(&amp;quot;ATT error code: 0x%02X&amp;quot;, err);
	}
}

/****************************************Reading RSSI Value*************************************/
static void read_conn_rssi(uint16_t handle, int8_t *rssi)
{
	struct net_buf *buf, *rsp = NULL;
	struct bt_hci_cp_read_rssi *cp;
	struct bt_hci_rp_read_rssi *rp;

	int err;

	buf = bt_hci_cmd_create(BT_HCI_OP_READ_RSSI, sizeof(*cp));
	if (!buf) {
		printk(&amp;quot;Unable to allocate command buffer\n&amp;quot;);
		return;
	}

	cp = net_buf_add(buf, sizeof(*cp));
	cp-&amp;gt;handle = sys_cpu_to_le16(handle);

	err = bt_hci_cmd_send_sync(BT_HCI_OP_READ_RSSI, buf, &amp;amp;rsp);
	if (err) {
		uint8_t reason = rsp ?
			((struct bt_hci_rp_read_rssi *)rsp-&amp;gt;data)-&amp;gt;status : 0;
		printk(&amp;quot;Read RSSI err: %d reason 0x%02x\n&amp;quot;, err, reason);
		return;
	}

	rp = (void *)rsp-&amp;gt;data;
	*rssi = rp-&amp;gt;rssi;

	net_buf_unref(rsp);
}

/*****************************************TX Power**************************************************/

static void set_tx_power(uint8_t handle_type, uint16_t handle, int8_t tx_pwr_lvl)
{
	struct bt_hci_cp_vs_write_tx_power_level *cp;
	struct bt_hci_rp_vs_write_tx_power_level *rp;
	struct net_buf *buf, *rsp = NULL;
	int err;

	buf = bt_hci_cmd_create(BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL,
				sizeof(*cp));
	if (!buf) {
		printk(&amp;quot;Unable to allocate command buffer\n&amp;quot;);
		return;
	}

	cp = net_buf_add(buf, sizeof(*cp));
	cp-&amp;gt;handle = sys_cpu_to_le16(handle);
	cp-&amp;gt;handle_type = handle_type;
	cp-&amp;gt;tx_power_level = tx_pwr_lvl;

	err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL,
				   buf, &amp;amp;rsp);
	if (err) {
		uint8_t reason = rsp ?
			((struct bt_hci_rp_vs_write_tx_power_level *)
			  rsp-&amp;gt;data)-&amp;gt;status : 0;
		printk(&amp;quot;Set Tx power err: %d reason 0x%02x\n&amp;quot;, err, reason);
		return;
	}

	rp = (void *)rsp-&amp;gt;data;
	printk(&amp;quot;Actual Tx Power: %d\n&amp;quot;, rp-&amp;gt;selected_tx_power);

	net_buf_unref(rsp);
}


/****************************************Receving Data Via BLE*************************************/

static uint8_t ble_data_received(struct bt_nus_client *nus,
						const uint8_t *data, uint16_t len)
{
	ARG_UNUSED(nus);

	int err;
	int8_t rssi = 0xFF;

	for (uint16_t pos = 0; pos != len;) {
		struct uart_data_t *tx = k_malloc(sizeof(*tx));

		if (!tx) {
			LOG_WRN(&amp;quot;Not able to allocate UART send data buffer&amp;quot;);
			printk(&amp;quot;Not able to allocate UART send data buffer\n&amp;quot;);
			return BT_GATT_ITER_CONTINUE;
		}

		/* Keep the last byte of TX buffer for potential LF char. */
		size_t tx_data_size = sizeof(tx-&amp;gt;data) - 1;

		if ((len - pos) &amp;gt; tx_data_size) {
			tx-&amp;gt;len = tx_data_size;
		} else {
			tx-&amp;gt;len = (len - pos);
		}

		memcpy(tx-&amp;gt;data, &amp;amp;data[pos], tx-&amp;gt;len);

		pos += tx-&amp;gt;len;

		/* Append the LF character when the CR character triggered
		 * transmission from the peer.
		 */
		if ((pos == len) &amp;amp;&amp;amp; (data[len - 1] == &amp;#39;\r&amp;#39;)) {
			tx-&amp;gt;data[tx-&amp;gt;len] = &amp;#39;\n&amp;#39;;
			tx-&amp;gt;len++;
		}
		/* modifications*/
		printk(&amp;quot;\n&amp;quot;);
		//int counter_start(const struct device *dev);
		//int counter_get_value(const struct device *dev, uint32_t *ticks)
		//typedef uint32_t(* nrf_log_timestamp_func_t)(void);
		err = uart_tx(uart, tx-&amp;gt;data, tx-&amp;gt;len, SYS_FOREVER_MS);
		read_conn_rssi(NULL, &amp;amp;rssi);
		printk(&amp;quot;   RSSI: %d&amp;quot;,rssi);
	
		if (err) {
			k_fifo_put(&amp;amp;fifo_uart_tx_data, tx);
		}
	}

	return BT_GATT_ITER_CONTINUE;
}


static void uart_cb(const struct device *dev, struct uart_event *evt, void *user_data)
{
	ARG_UNUSED(dev);

	static uint8_t *current_buf;
	static size_t aborted_len;
	static bool buf_release;
	struct uart_data_t *buf;
	static uint8_t *aborted_buf;

	switch (evt-&amp;gt;type) {
	case UART_TX_DONE:
		if ((evt-&amp;gt;data.tx.len == 0) ||
		    (!evt-&amp;gt;data.tx.buf)) {
			return;
		}

		if (aborted_buf) {
			buf = CONTAINER_OF(aborted_buf, struct uart_data_t,
					   data);
			aborted_buf = NULL;
			aborted_len = 0;
		} else {
			buf = CONTAINER_OF(evt-&amp;gt;data.tx.buf,
					   struct uart_data_t,
					   data);
		}

		k_free(buf);

		buf = k_fifo_get(&amp;amp;fifo_uart_tx_data, K_NO_WAIT);
		if (!buf) {
			return;
		}

		if (uart_tx(uart, buf-&amp;gt;data, buf-&amp;gt;len, SYS_FOREVER_MS)) {
			LOG_WRN(&amp;quot;Failed to send data over UART&amp;quot;);
		}

		break;

	case UART_RX_RDY:
		buf = CONTAINER_OF(evt-&amp;gt;data.rx.buf, struct uart_data_t, data);
		buf-&amp;gt;len += evt-&amp;gt;data.rx.len;
		buf_release = false;

		if (buf-&amp;gt;len == UART_BUF_SIZE) {
			k_fifo_put(&amp;amp;fifo_uart_rx_data, buf);
		} else if ((evt-&amp;gt;data.rx.buf[buf-&amp;gt;len - 1] == &amp;#39;\n&amp;#39;) ||
			  (evt-&amp;gt;data.rx.buf[buf-&amp;gt;len - 1] == &amp;#39;\r&amp;#39;)) {
			k_fifo_put(&amp;amp;fifo_uart_rx_data, buf);
			current_buf = evt-&amp;gt;data.rx.buf;
			buf_release = true;
			uart_rx_disable(uart);
		}

		break;

	case UART_RX_DISABLED:
		buf = k_malloc(sizeof(*buf));
		if (buf) {
			buf-&amp;gt;len = 0;
		} else {
			LOG_WRN(&amp;quot;Not able to allocate UART receive buffer&amp;quot;);
			k_work_reschedule(&amp;amp;uart_work, UART_WAIT_FOR_BUF_DELAY);
			return;
		}

		uart_rx_enable(uart, buf-&amp;gt;data, sizeof(buf-&amp;gt;data),
			       UART_RX_TIMEOUT);

		break;

	case UART_RX_BUF_REQUEST:
		buf = k_malloc(sizeof(*buf));
		if (buf) {
			buf-&amp;gt;len = 0;
			uart_rx_buf_rsp(uart, buf-&amp;gt;data, sizeof(buf-&amp;gt;data));
		} else {
			LOG_WRN(&amp;quot;Not able to allocate UART receive buffer&amp;quot;);
		}

		break;

	case UART_RX_BUF_RELEASED:
		buf = CONTAINER_OF(evt-&amp;gt;data.rx_buf.buf, struct uart_data_t,
				   data);
		if (buf_release &amp;amp;&amp;amp; (current_buf != evt-&amp;gt;data.rx_buf.buf)) {
			k_free(buf);
			buf_release = false;
			current_buf = NULL;
		}

		break;

	case UART_TX_ABORTED:
			if (!aborted_buf) {
				aborted_buf = (uint8_t *)evt-&amp;gt;data.tx.buf;
			}

			aborted_len += evt-&amp;gt;data.tx.len;
			buf = CONTAINER_OF(aborted_buf, struct uart_data_t,
					   data);

			uart_tx(uart, &amp;amp;buf-&amp;gt;data[aborted_len],
				buf-&amp;gt;len - aborted_len, SYS_FOREVER_MS);

		break;

	default:
		break;
	}
}

static void uart_work_handler(struct k_work *item)
{
	struct uart_data_t *buf;

	buf = k_malloc(sizeof(*buf));
	if (buf) {
		buf-&amp;gt;len = 0;
	} else {
		LOG_WRN(&amp;quot;Not able to allocate UART receive buffer&amp;quot;);
		k_work_reschedule(&amp;amp;uart_work, UART_WAIT_FOR_BUF_DELAY);
		return;
	}

	uart_rx_enable(uart, buf-&amp;gt;data, sizeof(buf-&amp;gt;data), UART_RX_TIMEOUT);
}

static int uart_init(void)
{
	int err;
	struct uart_data_t *rx;

	uart = device_get_binding(DT_LABEL(DT_NODELABEL(uart0)));
	if (!uart) {
		LOG_ERR(&amp;quot;UART binding failed&amp;quot;);
		return -ENXIO;
	}

	rx = k_malloc(sizeof(*rx));
	if (rx) {
		rx-&amp;gt;len = 0;
	} else {
		return -ENOMEM;
	}

	k_work_init_delayable(&amp;amp;uart_work, uart_work_handler);

	err = uart_callback_set(uart, uart_cb, NULL);
	if (err) {
		return err;
	}

	return uart_rx_enable(uart, rx-&amp;gt;data, sizeof(rx-&amp;gt;data),
			      UART_RX_TIMEOUT);
}

static void discovery_complete(struct bt_gatt_dm *dm,
			       void *context)
{
	struct bt_nus_client *nus = context;
	LOG_INF(&amp;quot;Service discovery completed&amp;quot;);

	bt_gatt_dm_data_print(dm);

	bt_nus_handles_assign(dm, nus);
	bt_nus_subscribe_receive(nus);

	bt_gatt_dm_data_release(dm);
}

static void discovery_service_not_found(struct bt_conn *conn,
					void *context)
{
	LOG_INF(&amp;quot;Service not found&amp;quot;);
}

static void discovery_error(struct bt_conn *conn,
			    int err,
			    void *context)
{
	LOG_WRN(&amp;quot;Error while discovering GATT database: (%d)&amp;quot;, err);
}

struct bt_gatt_dm_cb discovery_cb = {
	.completed         = discovery_complete,
	.service_not_found = discovery_service_not_found,
	.error_found       = discovery_error,
};

static void gatt_discover(struct bt_conn *conn)
{
	int err;

	if (conn != default_conn) {
		return;
	}

	err = bt_gatt_dm_start(conn,
			       BT_UUID_NUS_SERVICE,
			       &amp;amp;discovery_cb,
			       &amp;amp;nus_client);
	if (err) {
		LOG_ERR(&amp;quot;could not start the discovery procedure, error &amp;quot;
			&amp;quot;code: %d&amp;quot;, err);
	}
}

static void exchange_func(struct bt_conn *conn, uint8_t err, struct bt_gatt_exchange_params *params)
{
	if (!err) {
		LOG_INF(&amp;quot;MTU exchange done&amp;quot;);
	} else {
		LOG_WRN(&amp;quot;MTU exchange failed (err %&amp;quot; PRIu8 &amp;quot;)&amp;quot;, err);
	}
}

static void connected(struct bt_conn *conn, uint8_t conn_err)
{
	char addr[BT_ADDR_LE_STR_LEN];
	int err;

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	if (conn_err) {
		LOG_INF(&amp;quot;Failed to connect to %s (%d)&amp;quot;, log_strdup(addr),
			conn_err);

		if (default_conn == conn) {
			bt_conn_unref(default_conn);
			default_conn = NULL;

			err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
			if (err) {
				LOG_ERR(&amp;quot;Scanning failed to start (err %d)&amp;quot;,
					err);
			}
		}

		return;
	}

	LOG_INF(&amp;quot;Connected: %s&amp;quot;, log_strdup(addr));

	static struct bt_gatt_exchange_params exchange_params;

	exchange_params.func = exchange_func;
	err = bt_gatt_exchange_mtu(conn, &amp;amp;exchange_params);
	if (err) {
		LOG_WRN(&amp;quot;MTU exchange failed (err %d)&amp;quot;, err);
	}

	err = bt_conn_set_security(conn, BT_SECURITY_L2);
	if (err) {
		LOG_WRN(&amp;quot;Failed to set security: %d&amp;quot;, err);

		gatt_discover(conn);
	}

	err = bt_scan_stop();
	if ((!err) &amp;amp;&amp;amp; (err != -EALREADY)) {
		LOG_ERR(&amp;quot;Stop LE scan failed (err %d)&amp;quot;, err);
	}
}

static void disconnected(struct bt_conn *conn, uint8_t reason)
{
	char addr[BT_ADDR_LE_STR_LEN];
	int err;

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	LOG_INF(&amp;quot;Disconnected: %s (reason %u)&amp;quot;, log_strdup(addr),
		reason);

	if (default_conn != conn) {
		return;
	}

	bt_conn_unref(default_conn);
	default_conn = NULL;

	err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
	if (err) {
		LOG_ERR(&amp;quot;Scanning failed to start (err %d)&amp;quot;,
			err);
	}
}

static void security_changed(struct bt_conn *conn, bt_security_t level,
			     enum bt_security_err err)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	if (!err) {
		LOG_INF(&amp;quot;Security changed: %s level %u&amp;quot;, log_strdup(addr),
			level);
	} else {
		LOG_WRN(&amp;quot;Security failed: %s level %u err %d&amp;quot;, log_strdup(addr),
			level, err);
	}

	gatt_discover(conn);
}

static struct bt_conn_cb conn_callbacks = {
	.connected = connected,
	.disconnected = disconnected,
	.security_changed = security_changed
};

/*
static void scan_filter_match(struct bt_scan_device_info *device_info,
			      struct bt_scan_filter_match *filter_match,
			      bool connectable)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(device_info-&amp;gt;recv_info-&amp;gt;addr, addr, sizeof(addr));

	LOG_INF(&amp;quot;Filters matched. Address: %s connectable: %d&amp;quot;,
		log_strdup(addr), connectable);
}
*/
/************************* Coded PHY************************************/
static void scan_filter_match(struct bt_scan_device_info *device_info,
			      struct bt_scan_filter_match *filter_match,
			      bool connectable)
{
	int err;
	char addr[BT_ADDR_LE_STR_LEN];
	struct bt_conn_le_create_param *conn_params;

	bt_addr_le_to_str(device_info-&amp;gt;recv_info-&amp;gt;addr, addr, sizeof(addr));

	printk(&amp;quot;Filters matched. Address: %s connectable: %s\n&amp;quot;,
		addr, connectable ? &amp;quot;yes&amp;quot; : &amp;quot;no&amp;quot;);

	err = bt_scan_stop();
	if (err) {
		printk(&amp;quot;Stop LE scan failed (err %d)\n&amp;quot;, err);
	}

	conn_params = BT_CONN_LE_CREATE_PARAM(
			BT_CONN_LE_OPT_CODED | BT_CONN_LE_OPT_NO_1M,
			BT_GAP_SCAN_FAST_INTERVAL,
			BT_GAP_SCAN_FAST_INTERVAL);

	err = bt_conn_le_create(device_info-&amp;gt;recv_info-&amp;gt;addr, conn_params,
				BT_LE_CONN_PARAM_DEFAULT,
				&amp;amp;default_conn);

	if (err) {
		printk(&amp;quot;Create conn failed (err %d)\n&amp;quot;, err);

		err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
		if (err) {
			printk(&amp;quot;Scanning failed to start (err %d)\n&amp;quot;, err);
			return;
		}
	}

	printk(&amp;quot;Connection pending\n&amp;quot;);
}

//BT_SCAN_CB_INIT(scan_cb, scan_filter_match, NULL, NULL, NULL);



/***********************************************************************************/

static void scan_connecting_error(struct bt_scan_device_info *device_info)
{
	LOG_WRN(&amp;quot;Connecting failed&amp;quot;);
}

static void scan_connecting(struct bt_scan_device_info *device_info,
			    struct bt_conn *conn)
{
	default_conn = bt_conn_ref(conn);
}

static int nus_client_init(void)
{
	int err;
	struct bt_nus_client_init_param init = {
		.cb = {
			.received = ble_data_received,
			.sent = ble_data_sent,
		}
	};

	err = bt_nus_client_init(&amp;amp;nus_client, &amp;amp;init);
	if (err) {
		LOG_ERR(&amp;quot;NUS Client initialization failed (err %d)&amp;quot;, err);
		return err;
	}

	LOG_INF(&amp;quot;NUS Client module initialized&amp;quot;);
	return err;
}

BT_SCAN_CB_INIT(scan_cb, scan_filter_match, NULL,
		scan_connecting_error, scan_connecting);


static void scan_init(void)
{
	int err;

	/* Use active scanning and disable duplicate filtering to handle any
	 * devices that might update their advertising data at runtime. */
	struct bt_le_scan_param scan_param = {
		.type     = BT_LE_SCAN_TYPE_ACTIVE,
		.interval = BT_GAP_SCAN_FAST_INTERVAL,
		.window   = BT_GAP_SCAN_FAST_WINDOW,
		.options  = BT_LE_SCAN_OPT_CODED | BT_LE_SCAN_OPT_NO_1M
	};

	struct bt_scan_init_param scan_init = {
		.connect_if_match = 0,
		.scan_param = &amp;amp;scan_param,
		.conn_param = NULL
	};

	bt_scan_init(&amp;amp;scan_init);
	bt_scan_cb_register(&amp;amp;scan_cb);

	err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_UUID, BT_UUID_HRS);
	if (err) {
		printk(&amp;quot;Scanning filters cannot be set (err %d)\n&amp;quot;, err);

		return;
	}

	err = bt_scan_filter_enable(BT_SCAN_UUID_FILTER, false);
	if (err) {
		printk(&amp;quot;Filters cannot be turned on (err %d)\n&amp;quot;, err);
	}
}



static void auth_cancel(struct bt_conn *conn)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	LOG_INF(&amp;quot;Pairing cancelled: %s&amp;quot;, log_strdup(addr));
}


static void pairing_complete(struct bt_conn *conn, bool bonded)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	LOG_INF(&amp;quot;Pairing completed: %s, bonded: %d&amp;quot;, log_strdup(addr),
		bonded);
}


static void pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	LOG_WRN(&amp;quot;Pairing failed conn: %s, reason %d&amp;quot;, log_strdup(addr),
		reason);
}

static struct bt_conn_auth_cb conn_auth_callbacks = {
	.cancel = auth_cancel,
	.pairing_complete = pairing_complete,
	.pairing_failed = pairing_failed
};

void main(void)
{
	int err;

	err = bt_conn_auth_cb_register(&amp;amp;conn_auth_callbacks);
	if (err) {
		LOG_ERR(&amp;quot;Failed to register authorization callbacks.&amp;quot;);
		return;
	}

	err = bt_enable(NULL);
	if (err) {
		LOG_ERR(&amp;quot;Bluetooth init failed (err %d)&amp;quot;, err);
		return;
	}
	LOG_INF(&amp;quot;Bluetooth initialized&amp;quot;);

	if (IS_ENABLED(CONFIG_SETTINGS)) {
		settings_load();
	}

	bt_conn_cb_register(&amp;amp;conn_callbacks);

	int (*module_init[])(void) = {uart_init, scan_init, nus_client_init};
	for (size_t i = 0; i &amp;lt; ARRAY_SIZE(module_init); i++) {
		err = (*module_init[i])();
		if (err) {
			return;
		}
	}

	printk(&amp;quot;Starting Bluetooth Central UART example\n&amp;quot;);

	scan_init();

	err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
	if (err) {
		LOG_ERR(&amp;quot;Scanning failed to start (err %d)&amp;quot;, err);
		return;
	}

	LOG_INF(&amp;quot;Scanning successfully started&amp;quot;);

	for (;;) {
		/* Wait indefinitely for data to be sent over Bluetooth */
		struct uart_data_t *buf = k_fifo_get(&amp;amp;fifo_uart_rx_data,
						     K_FOREVER);

		err = bt_nus_client_send(&amp;amp;nus_client, buf-&amp;gt;data, buf-&amp;gt;len);
		if (err) {
			LOG_WRN(&amp;quot;Failed to send data over BLE connection&amp;quot;
				&amp;quot;(err %d)&amp;quot;, err);
		}

		err = k_sem_take(&amp;amp;nus_write_sem, NUS_WRITE_TIMEOUT);
		if (err) {
			LOG_WRN(&amp;quot;NUS send timeout&amp;quot;);
		}
	}
}
&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Kindly help me with these 2 issues.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Regards&lt;/div&gt;
&lt;div&gt;Karthik Kumar&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error with peripheral_uart_coded.</title><link>https://devzone.nordicsemi.com/thread/349162?ContentTypeID=1</link><pubDate>Mon, 24 Jan 2022 09:43:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ccf2656-e534-4dd5-8216-6195b0031855</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Karthik Kumar,&lt;/p&gt;
&lt;p&gt;How are you setting the TX power, and where do you see what it is set to?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error with peripheral_uart_coded.</title><link>https://devzone.nordicsemi.com/thread/348918?ContentTypeID=1</link><pubDate>Fri, 21 Jan 2022 12:35:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a3431e1-773b-4829-a8b4-d1a79e439577</guid><dc:creator>KarthikKumar</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/marte.m"&gt;Marte Myrvold&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;Thank you the issue is fixed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I wanted to set the TX power to the maximum and constant all the time but it look like set to 0.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Karthik Kumar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error with peripheral_uart_coded.</title><link>https://devzone.nordicsemi.com/thread/348909?ContentTypeID=1</link><pubDate>Fri, 21 Jan 2022 12:15:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40ebfb5f-1ed7-4688-95f3-c8f9f69dd879</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Karthik Kumar,&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;example code is made for v1.5.0 of nRF Connect for Desktop, so using it with v1.8.0 might cause errors and unexpected behavior.&lt;/p&gt;
&lt;p&gt;This issue is fixed by changing the&amp;nbsp;auth_conn parameter in LOG_INF in function&amp;nbsp;num_comp_reply() to&amp;nbsp;(void *)auth_conn so that you have the following instead:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void num_comp_reply(bool accept)
{
	if (accept) {
		bt_conn_auth_passkey_confirm(auth_conn);
		LOG_INF(&amp;quot;Numeric Match, conn %p&amp;quot;, (void *)auth_conn);
	} else {
		bt_conn_auth_cancel(auth_conn);
		LOG_INF(&amp;quot;Numeric Reject, conn %p&amp;quot;, (void *)auth_conn);
	}

	bt_conn_unref(auth_conn);
	auth_conn = NULL;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You should also be aware that there were some changes to the Zephyr Workqueue API in nRF Connect SDK v1.6.0, and part of the API has become deprecated and replaced.&amp;nbsp;You can read more about this in&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/nrf/releases/release-notes-1.6.0.html?highlight=k_delayed_work_init#zephyr-workqueue-api-migration"&gt;Zephyr Workqueue API Migration&lt;/a&gt;, but the relevant parts for your code are the functions&amp;nbsp;k_delayed_work_init() and&amp;nbsp;k_delayed_work_submit():&lt;/p&gt;
&lt;table height="73" width="395"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Deprecated API&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Corresponding new API&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;k_delayed_work_init()&lt;/td&gt;
&lt;td&gt;k_work_init_delayable()&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;k_delayed_work_submit()&lt;/td&gt;
&lt;td&gt;k_work_schedule() or k_work_reschedule()&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;As you can see,&amp;nbsp;k_delayed_work_submit() has been split into two function that covers different usage scenarios, so you must make sure to use the correct one:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a title="(in Zephyr Project v2.7.0)" href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/zephyr/reference/kernel/threads/workqueue.html#c.k_work_reschedule"&gt;&lt;code&gt;&lt;span&gt;k_work_reschedule()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&amp;nbsp;behaves the same way as the old&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a title="(in Zephyr Project v2.7.0)" href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/zephyr/reference/kernel/threads/workqueue.html#c.k_delayed_work_submit"&gt;&lt;code&gt;&lt;span&gt;k_delayed_work_submit()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;function, and will resubmit the work item, even if it has already been queued.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a title="(in Zephyr Project v2.7.0)" href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/zephyr/reference/kernel/threads/workqueue.html#c.k_work_schedule"&gt;&lt;code&gt;&lt;span&gt;k_work_schedule()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;will only submit the work item if it has not yet been queued.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Please see the&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/nrf/release_notes.html"&gt;release notes&lt;/a&gt;&amp;nbsp;for other changes between specific nRF Connect SDK releases.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>