<?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>Smart BLE alarm</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/109091/smart-ble-alarm</link><description>I am currently working on a smart BLE alarm project using the nRF52840 DK board in the nRF Connect SDK (version 2.5.1). 
 During modular testing of the project, I attempted to connect two ICs, an NPM1300 and a touch sensing IC, via I2C communication.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 27 Mar 2024 14:16:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/109091/smart-ble-alarm" /><item><title>RE: Smart BLE alarm</title><link>https://devzone.nordicsemi.com/thread/476181?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2024 14:16:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1f308e6-a3fb-43b5-a9e9-8dd3732aae78</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;It could be an Android bug. I don&amp;#39;t know. That depends on what it says when it fails to establish the connection. Isn&amp;#39;t it already connected when you perform the bonding?&lt;/p&gt;
&lt;p&gt;I am closing this ticket, since it is far off topic for the title. Please be aware that we are closed from tomorrow until 2nd of April, due to public holidays here in Norway. We will be back to normal operation on Tuesday.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Smart BLE alarm</title><link>https://devzone.nordicsemi.com/thread/476119?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2024 11:26:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c97325b-b0a8-4824-afb3-8d49df9e8423</guid><dc:creator>Priyesh Shahi</dc:creator><description>&lt;p&gt;Let me explain step by step what is happening:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I flashed the &amp;#39;peripheral_nfc_pairing&amp;#39; to the DK board.&lt;/li&gt;
&lt;li&gt;Then I placed my phone to read the NFC tag and clicked on &amp;#39;pair&amp;#39; in the popup message.&lt;/li&gt;
&lt;li&gt;In the serial monitor, there is a log indicating that pairing completed successfully.&lt;/li&gt;
&lt;li&gt;However, on my phone, another popup message appeared stating that it couldn&amp;#39;t pair with the device.&lt;/li&gt;
&lt;li&gt;Despite this, the device appears in the Bluetooth paired device list on my phone, and also in the NRF Connect mobile app under the list of bonded devices.&lt;/li&gt;
&lt;li&gt;Nevertheless, when I attempt to click on &amp;#39;connect&amp;#39;, it fails to establish a connection.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span&gt;Additionally, if I choose to cancel the pairing process in the second step instead of pairing, I am able to use the device&amp;#39;s BLE services as usual( by regular scanning process).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And when I flashed my merged project then there, I saw that I have successfully merged my code because all the custom services I added are present there.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Smart BLE alarm</title><link>https://devzone.nordicsemi.com/thread/476096?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2024 10:09:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3570be4-3dc7-463e-8d93-0d76133fbf7e</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;For further follow ups, please create a new ticket, since this is related to the title of this ticket anymore.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For NFC pairing, please see the sample found in:&lt;/p&gt;
&lt;p&gt;ncs\nrf\samples\bluetooth\&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/peripheral_nfc_pairing/README.html"&gt;peripheral_nfc_pairing&lt;/a&gt;&lt;/p&gt;
[quote user="Priyesh Shahi"]also please tell me&amp;nbsp;about the Out-of-Band (OOB) pairing method.[/quote]
&lt;p&gt;In general, OOB pairing is used to make it harder (impossible) for attackers to pick up the keys that will be used for encryption of the BLE link. One way of bonding is to use the &amp;quot;Just works&amp;quot; method, where the keys are just sent as a normal message over the unencrypted BLE link. If an attacker is nearby, they can capture these packets, and use this to decrypt the link, or even pretend to be one of the devices in the future.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;By using OOB, it means that an attacker have no way of picking up these keys, because they are not sent on air. There are several ways to use OOB. One is NFC, another is to use a 6 digit passkey, and in theory, you can use anything that can transport a secret from one device to the other without using BLE. But if one of the devices is a phone, it would be smart to use something that they support, such as passkey or NFC.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Smart BLE alarm</title><link>https://devzone.nordicsemi.com/thread/476040?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2024 05:50:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2f119ff-928b-4c56-ba56-0c44d9aa8d3e</guid><dc:creator>Priyesh Shahi</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I have successfully resolved the&amp;nbsp;above issue by leveraging functions from the DK library&amp;#39;s source and header files. These functions utilize a scheduler and mutex in the background, resulting in the problem being resolved.&lt;/p&gt;
&lt;p&gt;Currently, I am&amp;nbsp;trying to integrate BLE NFC pairing functionality into my project(using peripheral_nfc_pairing sample). However, each attempt to initiate pairing triggers directed advertising, which abruptly ceases according to the logs. Although pairing with my phone is successful, as evidenced by its appearance in the bonded device section of the NRF Connect mobile app, attempts to establish a connection from the phone are unsuccessful.&lt;/p&gt;
&lt;p&gt;Could you please provide guidance on how to pair a BLE device with NFC?&amp;nbsp;also please tell me&amp;nbsp;about the Out-of-Band (OOB) pairing method.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;br /&gt;&lt;br /&gt;the error log :&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:400px;max-width:547px;" alt=" " height="400" src="https://devzone.nordicsemi.com/resized-image/__size/1094x800/__key/communityserver-discussions-components-files/4/1513.Error_5F00_log.png" width="547" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Smart BLE alarm</title><link>https://devzone.nordicsemi.com/thread/475971?ContentTypeID=1</link><pubDate>Tue, 26 Mar 2024 14:34:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:138f0cf1-d218-4be4-b957-7c382925b637</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Jonathan is out of office, so I will look into your ticket.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is this question at all related to the I2C or nPM1300 anymore? It looks like it is not, but let me know if it is.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So you are trying to send an indication, is that right? From where are you doing this? Is it from an interrupt? If so, can you try to create a work, and call it from within the work? Similar to how it is done in a timer interrupt here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/kernel/services/timing/timers.html#using-a-timer-expiry-function"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/kernel/services/timing/timers.html#using-a-timer-expiry-function&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Smart BLE alarm</title><link>https://devzone.nordicsemi.com/thread/474299?ContentTypeID=1</link><pubDate>Mon, 18 Mar 2024 12:02:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5967496a-5d4e-4563-a66b-092a1773e09f</guid><dc:creator>Priyesh Shahi</dc:creator><description>&lt;p&gt;I have tried to put that indication code inside a thread still that didn&amp;#39;t work.&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting nRF Connect SDK v2.5.1 ***
I: Starting bootloader
I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Image index: 0, Swap type: none
I: Bootloader chainload address offset: 0xc000
*** Booting nRF Connect SDK v2.5.1 ***
I: Booting my smart alarm

PWM-based LED fade
Button initialized. Press the button!
I: SoftDevice Controller build revision: 
I: c5 93 ba a9 14 4d 8d 05 |.....M..
I: 30 4e 9b 92 d7 71 1e e8 |0N...q..
I: aa 02 50 3c             |..P&amp;lt;    
I: HW Platform: Nordic Semiconductor (0x0002)
I: HW Variant: nRF52x (0x0002)
I: Firmware: Standard Bluetooth controller (0x00) Version 197.47763 Build 2370639017
I: Identity: C8:5A:58:BD:46:2E (random)
I: HCI: version 5.4 (0x0d) revision 0x1102, manufacturer 0x0059
I: LMP: version 5.4 (0x0d) subver 0x1102
I: Bluetooth initialized

I: Advertising successfully started version 1.1.2

Connected
ASSERTION FAIL @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/conn.c:1375
E: r0/a1:  0x00000004  r1/a2:  0x0000055f  r2/a3:  0x00000001
E: r3/a4:  0x00026405 r12/ip:  0x00000014 r14/lr:  0x00022c3f
E:  xpsr:  0x61000016
E: Faulting instruction address (r15/pc): 0x000319a8
E: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
E: Fault during interrupt handling

E: Current thread: 0x200029f0 (unknown)
*** Booting nRF Connect SDK v2.5.1 ***
I: Starting bootloader
I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Image index: 0, Swap type: none
I: Bootloader chainload address offset: 0xc000
*** Booting nRF Connect SDK v2.5.1 ***
I: Booting my smart alarm

PWM-based LED fade
Button initialized. Press the button!
I: SoftDevice Controller build revision: 
I: c5 93 ba a9 14 4d 8d 05 |.....M..
I: 30 4e 9b 92 d7 71 1e e8 |0N...q..
I: aa 02 50 3c             |..P&amp;lt;    
I: HW Platform: Nordic Semiconductor (0x0002)
I: HW Variant: nRF52x (0x0002)
I: Firmware: Standard Bluetooth controller (0x00) Version 197.47763 Build 2370639017
I: Identity: C8:5A:58:BD:46:2E (random)
I: HCI: version 5.4 (0x0d) revision 0x1102, manufacturer 0x0059
I: LMP: version 5.4 (0x0d) subver 0x1102
I: Bluetooth initialized

I: Advertising successfully started version 1.1.2&lt;/pre&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Smart BLE alarm</title><link>https://devzone.nordicsemi.com/thread/474291?ContentTypeID=1</link><pubDate>Mon, 18 Mar 2024 11:43:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f739950f-3726-4601-b3e9-649543871a28</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;can you share the crash log ?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Smart BLE alarm</title><link>https://devzone.nordicsemi.com/thread/473797?ContentTypeID=1</link><pubDate>Thu, 14 Mar 2024 09:13:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab5808fa-8c47-41b3-b60b-3587f9ca0b7c</guid><dc:creator>Priyesh Shahi</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Now I am able to scan the I2C address. However, I&amp;#39;ve encountered another issue with BLE indication. I adapted the BLE indication functionality from the Dev Academy BLE Fundamental Exercise 4-2 to my custom BLE service, which is similar to the Nordic BT LBS service.&lt;/p&gt;
&lt;p&gt;Everything seems to work fine until I attempt to read the button status using indication(even when I am just using the read function It is working). However, when I enable indication and then press the button, my device enters kernel panic mode, disconnects from the BT device, and reboots.&lt;/p&gt;
&lt;p&gt;Could you please advise on what steps I should take to resolve this issue?&lt;br /&gt;&lt;br /&gt;this is my main.c file&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/logging/log.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/bluetooth.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/gap.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/uuid.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/conn.h&amp;gt;

#include &amp;lt;zephyr/device.h&amp;gt;
#include &amp;lt;zephyr/drivers/gpio.h&amp;gt;


#include &amp;quot;my_led_pwm.h&amp;quot;
#include &amp;quot;my_user.h&amp;quot;
#include &amp;quot;my_alarm.h&amp;quot;


static struct bt_le_adv_param *adv_param = BT_LE_ADV_PARAM(
	(BT_LE_ADV_OPT_CONNECTABLE |
	 BT_LE_ADV_OPT_USE_IDENTITY), /* Connectable advertising and use identity address */
	800, /* Min Advertising Interval 500ms (800*0.625ms) */
	800, /* Max Advertising Interval 500.625ms (801*0.625ms) */
	NULL); /* Set to NULL for undirected advertising */

LOG_MODULE_REGISTER(My_Smart_Alarm, LOG_LEVEL_INF);

#define DEVICE_NAME CONFIG_BT_DEVICE_NAME
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)

/* Define your button pin */
#define BUTTON_PIN DT_NODELABEL(button0)
static const struct gpio_dt_spec USER_BUTTON = GPIO_DT_SPEC_GET(BUTTON_PIN, gpios);
static struct gpio_callback button_cb_data;

static const struct bt_data ad[] = {
	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
	BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),

};

static const struct bt_data sd[] = {
	BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_16_ENCODE(BT_UUID_UDS_VAL)),
	BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_ALARM_VAL),
};


user_data_t app_user_data;
static bool app_button_state = false;

static void app_alarm_status_cb(bool alarm_state)
{
	app_user_data.alarm_state = alarm_state;
}

static bool app_button_cb(void)
{
	return app_button_state;
}

static void app_user_name_cb(user_data_t *my_user)
{
	// Clear the user name buffer before writing a new name
    memset(app_user_data.name, 0, sizeof(app_user_data.name));

    memcpy(app_user_data.name, my_user-&amp;gt;name, sizeof(my_user-&amp;gt;name));
	LOG_INF(&amp;quot;write was called: %s\n&amp;quot;, app_user_data.name);
}

static void app_user_age_cb(user_data_t *my_user)
{
	app_user_data.age = my_user-&amp;gt;age;
	LOG_INF(&amp;quot;write was called: %d\n&amp;quot;, app_user_data.age);
}
static void app_user_sex_cb(user_data_t *my_user)
{
	app_user_data.sex = my_user-&amp;gt;sex;
	LOG_INF(&amp;quot;write was called: %d\n&amp;quot;, app_user_data.sex);
}

static struct my_user_cb app_user_callbacks = {
	.user_name_cb = app_user_name_cb,
	.user_age_cb = app_user_age_cb,
	.user_sex_cb = app_user_sex_cb
};

static struct my_alarm_cb app_callbacks = {
	.alarm_status_cb = app_alarm_status_cb,
	.button_cb = app_button_cb,
};


/* Button callback function */
static void button_pressed(const struct device *dev, struct gpio_callback *cb,
                           uint32_t pins)
{
    /* Check if the button pin is pressed or released */
    if (pins &amp;amp; BIT(USER_BUTTON.pin)) {
        /* Read the current button state */
        uint32_t button_state = gpio_pin_get(dev, USER_BUTTON.pin);
        
        if (button_state) {
            /* Button is pressed (active state) */
            my_alarm_send_button_state_indicate(true);  // Indicate button press
            app_button_state = true;
        } else {
            /* Button is released (inactive state) */
            my_alarm_send_button_state_indicate(false);  // Indicate button release
            app_button_state = false;
        }
    }
}


static void on_connected(struct bt_conn *conn, uint8_t err)
{
	if (err) {
		printk(&amp;quot;Connection failed (err %u)\n&amp;quot;, err);
		return;
	}
	printk(&amp;quot;Connected\n&amp;quot;);
    // pwm_circuelar_pattern();

}

static void on_disconnected(struct bt_conn *conn, uint8_t reason)
{
	printk(&amp;quot;Disconnected (reason %u)\n&amp;quot;, reason);
    // pwm_blink_pattern();
}

struct bt_conn_cb connection_callbacks = {
	.connected = on_connected,
	.disconnected = on_disconnected,
};

static int cfg_button(void)
{
	gpio_pin_configure_dt(&amp;amp;USER_BUTTON, GPIO_INPUT);

	gpio_pin_interrupt_configure_dt(&amp;amp;USER_BUTTON, GPIO_INT_EDGE_BOTH);
	gpio_init_callback(&amp;amp;button_cb_data, button_pressed, BIT(USER_BUTTON.pin));
	gpio_add_callback(USER_BUTTON.port ,&amp;amp;button_cb_data);
    LOG_INF(&amp;quot;Button initialized.&amp;quot;);
	return 0;
}

int main(void)
{
	LOG_INF(&amp;quot;Booting my smart alarm&amp;quot;);
	LOG_INF(&amp;quot;Current firmware version %s&amp;quot;, DEVICE_FIRMWARE_VERSION);
	my_pwm_init();
	// pwm_booting_pattern();
        
	int err;
	err = cfg_button();
	if (err) {
		printk(&amp;quot;Button init failed (err %d)\n&amp;quot;, err);
		return 0;
	}

	err = bt_enable(NULL);
	if (err) {
		LOG_ERR(&amp;quot;Bluetooth init failed (err %d)\n&amp;quot;, err);
		return 0;
	}
	bt_conn_cb_register(&amp;amp;connection_callbacks);
	LOG_INF(&amp;quot;Bluetooth initialized&amp;quot;);

	err = bt_le_adv_start(adv_param, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
	if (err) {
		LOG_ERR(&amp;quot;Advertising failed to start (err %d)\n&amp;quot;, err);
		return 0;
	}

	err = my_user_init(&amp;amp;app_user_callbacks);
	if (err) {
		printk(&amp;quot;Failed to init USER  (err:%d)\n&amp;quot;, err);
		return 0;
	}


	err = my_alarm_init(&amp;amp;app_callbacks);
	if (err) {
		printk(&amp;quot;Failed to init LBS (err:%d)\n&amp;quot;, err);
		return 0;
	}

	LOG_INF(&amp;quot;Advertising successfully started&amp;quot;);
	for (;;) {
		// pwm_blink_pattern();
		k_msleep(500);
		// rc = pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);
		// k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL/2));
		// rc = pm_device_action_run(cons, PM_DEVICE_ACTION_RESUME);
	}
        return 0;
}

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;this is my_alarm.c file&amp;nbsp;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2018 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

/** @file
 *  @brief LED Button Service (LBS) sample
 */

#include &amp;lt;zephyr/types.h&amp;gt;
#include &amp;lt;stddef.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;zephyr/sys/printk.h&amp;gt;
#include &amp;lt;zephyr/sys/byteorder.h&amp;gt;
#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/logging/log.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/bluetooth.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/hci.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/conn.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/uuid.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/gatt.h&amp;gt;

#include &amp;quot;my_user.h&amp;quot;


LOG_MODULE_DECLARE(My_Smart_Alarm);



static struct my_user_cb user_cb;
user_data_t ble_user_data;


static ssize_t write_name(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf,
			 uint16_t len, uint16_t offset, uint8_t flags)
{
	LOG_DBG(&amp;quot;Attribute write, handle: %u, conn: %p&amp;quot;, attr-&amp;gt;handle, (void *)conn);

	if (len &amp;gt; 30U) {
		LOG_DBG(&amp;quot;Write led: Incorrect data length&amp;quot;);
		return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
	}

	if (offset != 0) {
		LOG_DBG(&amp;quot;Write led: Incorrect data offset&amp;quot;);
		return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
	}

	if (user_cb.user_name_cb) {
		// Clear the user name buffer before writing a new name
        memset(ble_user_data.name, 0, sizeof(ble_user_data.name));
		// Read the received value and update the user_name field
        memcpy(ble_user_data.name, buf, len);

        // Ensure that the name is null-terminated
        ble_user_data.name[len] = &amp;#39;\0&amp;#39;;

        // Call the application callback function to update the user name
        user_cb.user_name_cb(&amp;amp;ble_user_data);
	}

	return len;
}

static ssize_t write_age(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf,
			 uint16_t len, uint16_t offset, uint8_t flags)
{
	LOG_DBG(&amp;quot;Attribute write, handle: %u, conn: %p&amp;quot;, attr-&amp;gt;handle, (void *)conn);

	if (len != 1U) {
		LOG_DBG(&amp;quot;Write led: Incorrect data length&amp;quot;);
		return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
	}

	if (offset != 0) {
		LOG_DBG(&amp;quot;Write led: Incorrect data offset&amp;quot;);
		return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
	}

	if (user_cb.user_age_cb) {
		// Read the received value
		ble_user_data.age = *((uint8_t *)buf);

        // Call the application callback function to update the LED state
        user_cb.user_age_cb(&amp;amp;ble_user_data);
	}

	return len;
}static ssize_t write_sex(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf,
			 uint16_t len, uint16_t offset, uint8_t flags)
{
	LOG_DBG(&amp;quot;Attribute write, handle: %u, conn: %p&amp;quot;, attr-&amp;gt;handle, (void *)conn);

	if (len != 1U) {
		LOG_DBG(&amp;quot;Write led: Incorrect data length&amp;quot;);
		return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
	}

	if (offset != 0) {
		LOG_DBG(&amp;quot;Write led: Incorrect data offset&amp;quot;);
		return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
	}

	if (user_cb.user_sex_cb) {
		// Read the received value
		ble_user_data.sex = *((Sex_t *)buf);

        user_cb.user_sex_cb(&amp;amp;ble_user_data);
		
	}

	return len;
}

static ssize_t read_name(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf,
			   uint16_t len, uint16_t offset)
{
	// get a pointer to button_state which is passed in the BT_GATT_CHARACTERISTIC() and stored in attr-&amp;gt;user_data
    const char *value = attr-&amp;gt;user_data;

    LOG_DBG(&amp;quot;Attribute read, handle: %u, conn: %p&amp;quot;, attr-&amp;gt;handle, (void *)conn);
    LOG_INF(&amp;quot;read was called %s\n&amp;quot;, value);

    return bt_gatt_attr_read(conn, attr, buf, len, offset, value, (sizeof(ble_user_data.name) -1));

}

static ssize_t read_age(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf,
			   uint16_t len, uint16_t offset)
{
	// get a pointer to button_state which is passed in the BT_GATT_CHARACTERISTIC() and stored in attr-&amp;gt;user_data
    const char *value = attr-&amp;gt;user_data;

    LOG_DBG(&amp;quot;Attribute read, handle: %u, conn: %p&amp;quot;, attr-&amp;gt;handle, (void *)conn);
    LOG_INF(&amp;quot;read was called %s\n&amp;quot;,value);

    return bt_gatt_attr_read(conn, attr, buf, len, offset, value, sizeof(*value));

}

static ssize_t read_sex(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf,
			   uint16_t len, uint16_t offset)
{
	// get a pointer to button_state which is passed in the BT_GATT_CHARACTERISTIC() and stored in attr-&amp;gt;user_data
    const char *value = attr-&amp;gt;user_data;

    LOG_DBG(&amp;quot;Attribute read, handle: %u, conn: %p&amp;quot;, attr-&amp;gt;handle, (void *)conn);
    LOG_INF(&amp;quot;read was called %s\n&amp;quot;,value);

    return bt_gatt_attr_read(conn, attr, buf, len, offset, value, sizeof(*value));

}
static ssize_t read_fw_ver(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf,
			   uint16_t len, uint16_t offset)
{
	// get a pointer to button_state which is passed in the BT_GATT_CHARACTERISTIC() and stored in attr-&amp;gt;user_data
    const char *value = attr-&amp;gt;user_data;

    LOG_DBG(&amp;quot;Attribute read, handle: %u, conn: %p&amp;quot;, attr-&amp;gt;handle, (void *)conn);
    LOG_INF(&amp;quot;read was called %s\n&amp;quot;,value);

    return bt_gatt_attr_read(conn, attr, buf, len, offset, value, (sizeof(CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION) -1));

}
static ssize_t read_hw_ver(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf,
			   uint16_t len, uint16_t offset)
{
	// get a pointer to button_state which is passed in the BT_GATT_CHARACTERISTIC() and stored in attr-&amp;gt;user_data
    const char *value = attr-&amp;gt;user_data;

    LOG_DBG(&amp;quot;Attribute read, handle: %u, conn: %p&amp;quot;, attr-&amp;gt;handle, (void *)conn);
    LOG_INF(&amp;quot;read was called %s\n&amp;quot;,value);

    return bt_gatt_attr_read(conn, attr, buf, len, offset, value, (sizeof(DEVICE_HARDWARE_VERSION) -1));

}

/* A function to register application callbacks for the LED and Button characteristics  */
int my_user_init(struct my_user_cb *callbacks)
{
	if (callbacks) {
		user_cb.user_name_cb = callbacks-&amp;gt;user_name_cb;
		user_cb.user_age_cb = callbacks-&amp;gt;user_age_cb;
        user_cb.user_sex_cb = callbacks-&amp;gt;user_sex_cb;
	}
	return 0;
}

/* USER data Service Declaration */
BT_GATT_SERVICE_DEFINE(
	usd_svc, BT_GATT_PRIMARY_SERVICE(BT_UUID_UDS),
	/* Modify the NAME Characteristic declaration to support indication */
	BT_GATT_CHARACTERISTIC(BT_UUID_GATT_FIRST_NAME, BT_GATT_CHRC_WRITE | BT_GATT_CHRC_READ,
			       BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, read_name, write_name, &amp;amp;ble_user_data.name),
	/* Create and add the AGE Characteristic Configuration Descriptor */
	BT_GATT_CHARACTERISTIC(BT_UUID_GATT_AGE, BT_GATT_CHRC_WRITE | BT_GATT_CHRC_READ,
					BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, read_age, write_age, &amp;amp;ble_user_data.age),
	/* Create and add the SEX Characteristic and its CCCD  */
	BT_GATT_CHARACTERISTIC(BT_UUID_GATT_GENDER, BT_GATT_CHRC_WRITE | BT_GATT_CHRC_READ,
					BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, read_sex,  write_sex, &amp;amp;ble_user_data.sex),
	/* Create and add the SEX Characteristic and its CCCD  */
	BT_GATT_CHARACTERISTIC(BT_UUID_DIS_FIRMWARE_REVISION, BT_GATT_CHRC_READ,
					BT_GATT_PERM_READ, read_fw_ver,  NULL, DEVICE_FIRMWARE_VERSION),
	/* Create and add the SEX Characteristic and its CCCD  */
	BT_GATT_CHARACTERISTIC(BT_UUID_DIS_HARDWARE_REVISION, BT_GATT_CHRC_READ,
					BT_GATT_PERM_READ, read_hw_ver,  NULL, DEVICE_HARDWARE_VERSION),

);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;this is my_alarm.h file&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2018 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

#ifndef BT_LBS_H_
#define BT_LBS_H_

/**@file
 * @defgroup bt_lbs LED Button Service API
 * @{
 * @brief API for the LED Button Service (LBS).
 */

#ifdef __cplusplus
extern &amp;quot;C&amp;quot; {
#endif

#include &amp;lt;zephyr/types.h&amp;gt;

/** @brief LBS Service UUID. */
#define BT_UUID_ALARM_VAL BT_UUID_128_ENCODE(0x7bb294ec, 0xfd4b, 0x4e73, 0x8c25, 0x8494b1977701)

/** @brief Button Characteristic UUID. */
#define BT_UUID_ALARM_BUTTON_VAL BT_UUID_128_ENCODE(0x7bb294ec, 0xfd4b, 0x4e73, 0x8c25, 0x8494b1977702)

/** @brief LED Characteristic UUID. */
#define BT_UUID_ALARM_STATUS_VAL BT_UUID_128_ENCODE(0x7bb294ec, 0xfd4b, 0x4e73, 0x8c25, 0x8494b1977703)

/*Define the 128 bit long UUID array for service and characterstics*/

#define BT_UUID_ALARM BT_UUID_DECLARE_128(BT_UUID_ALARM_VAL)
#define BT_UUID_ALARM_BUTTON BT_UUID_DECLARE_128(BT_UUID_ALARM_BUTTON_VAL)
#define BT_UUID_ALARM_STATUS BT_UUID_DECLARE_128(BT_UUID_ALARM_STATUS_VAL)

/** @brief Callback type for when an LED state change is received. */
typedef void (*alarm_status_cb_t)(const bool alarm_state);

/** @brief Callback type for when the button state is pulled. */
typedef bool (*button_cb_t)(void);

/** @brief Callback struct used by the LBS Service. */
struct my_alarm_cb {
	/** LED state change callback. */
	alarm_status_cb_t alarm_status_cb;
	/** Button read callback. */
	button_cb_t button_cb;
};

/** @brief Initialize the LBS Service.
 *
 * This function registers application callback functions with the My LBS
 * Service
 *
 * @param[in] callbacks Struct containing pointers to callback functions
 *			used by the service. This pointer can be NULL
 *			if no callback functions are defined.
 *
 *
 * @retval 0 If the operation was successful.
 *           Otherwise, a (negative) error code is returned.
 */
int my_alarm_init(struct my_alarm_cb *callbacks);

/** @brief Send the button state as indication.
 *
 * This function sends a binary state, typically the state of a
 * button, to all connected peers.
 *
 * @param[in] button_state The state of the button.
 *
 * @retval 0 If the operation was successful.
 *           Otherwise, a (negative) error code is returned.
 */
int my_alarm_send_button_state_indicate(bool button_state);

/** @brief Send the button state as notification.
 *
 * This function sends a binary state, typically the state of a
 * button, to all connected peers.
 *
 * @param[in] button_state The state of the button.
 *
 * @retval 0 If the operation was successful.
 *           Otherwise, a (negative) error code is returned.
 */
int my_alarm_send_button_state_notify(bool button_state);


#ifdef __cplusplus
}
#endif

/**
 * @}
 */

#endif /* BT_LBS_H_ */
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Smart BLE alarm</title><link>https://devzone.nordicsemi.com/thread/473498?ContentTypeID=1</link><pubDate>Tue, 12 Mar 2024 15:56:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c5dbaf7-83c1-442f-892a-e867578dc418</guid><dc:creator>JONATHAN LL</dc:creator><description>[quote user=""]I will investigate further to confirm and address this issue, ensuring accurate communication with the connected ICs.[/quote]
&lt;p&gt;Are you able to sort out the ground issues ?&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]The NPM1300, which should have had the address 0x6B, returned 0x35 instead. Similarly, the touch sensing IC, with an expected address of 0x44, returned 0x66.[/quote]
&lt;p&gt;Could it be that there is an extra bit for read\write, so 8 bits but 7 bit addressing?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>