<?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>Can&amp;#39;t transmit int data through BLE?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/73207/can-t-transmit-int-data-through-ble</link><description>Hi everyone, 
 I&amp;#39;m using the nRF5340 board, nRF Connect SDK v1.5.0 and the nRF Connect app. 
 I am also using the example code &amp;quot;beacon&amp;quot; and all the data with integer format that I transmit to the app is arriving corrupted, for example 0x04, etc. 
 Before</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 06 Aug 2021 12:49:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/73207/can-t-transmit-int-data-through-ble" /><item><title>RE: Can't transmit int data through BLE?</title><link>https://devzone.nordicsemi.com/thread/323758?ContentTypeID=1</link><pubDate>Fri, 06 Aug 2021 12:49:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f48a194c-db82-42d1-9318-f668e0334d02</guid><dc:creator>Kaja</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;is this problem still unsolved?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Kaja&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't transmit int data through BLE?</title><link>https://devzone.nordicsemi.com/thread/302014?ContentTypeID=1</link><pubDate>Thu, 25 Mar 2021 19:10:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:646dfcd2-098d-4fef-ad27-888a56d13d34</guid><dc:creator>guillengap</dc:creator><description>&lt;p&gt;&lt;strong&gt;Hi Terje&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Thanks for your interest in this issue. Below I describe a summary:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1. I use the example code &amp;quot;beacon&amp;quot; (...\ncs\v1.5.0\zephyr\samples\bluetooth\ibeacon) because I want to send the data from an analog sensor to the Connect app, and first&amp;nbsp;at all I want to simulate the sending of data in integer format.&amp;nbsp;Below I show you the &amp;quot;main.c&amp;quot; code and a screenshot without making changes:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr/types.h&amp;gt;
#include &amp;lt;stddef.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;sys/util.h&amp;gt;

#include &amp;lt;bluetooth/bluetooth.h&amp;gt;
#include &amp;lt;bluetooth/hci.h&amp;gt;

#define DEVICE_NAME CONFIG_BT_DEVICE_NAME
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)

/*
* Set Advertisement data. Based on the Eddystone specification:
* https://github.com/google/eddystone/blob/master/protocol-specification.md
* https://github.com/google/eddystone/tree/master/eddystone-url
*/
static const struct bt_data ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, BT_LE_AD_NO_BREDR),
BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0xaa, 0xfe),
BT_DATA_BYTES(BT_DATA_SVC_DATA16,
0xaa, 0xfe, /* Eddystone UUID */
0x10, /* Eddystone-URL frame type */
0x00, /* Calibrated Tx power at 0m */
0x00, /* URL Scheme Prefix http://www. */
&amp;#39;z&amp;#39;, &amp;#39;e&amp;#39;, &amp;#39;p&amp;#39;, &amp;#39;h&amp;#39;, &amp;#39;y&amp;#39;, &amp;#39;r&amp;#39;,
&amp;#39;p&amp;#39;, &amp;#39;r&amp;#39;, &amp;#39;o&amp;#39;, &amp;#39;j&amp;#39;, &amp;#39;e&amp;#39;, &amp;#39;c&amp;#39;, &amp;#39;t&amp;#39;,
0x08) /* .org */
};

/* Set Scan Response data */
static const struct bt_data sd[] = {
BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
};

static void bt_ready(int err)
{
char addr_s[BT_ADDR_LE_STR_LEN];
bt_addr_le_t addr = {0};
size_t count = 1;
if (err) {
printk(&amp;quot;Bluetooth init failed (err %d)\n&amp;quot;, err);
return;
}

printk(&amp;quot;Bluetooth initialized\n&amp;quot;);

/* Start advertising */
err = bt_le_adv_start(BT_LE_ADV_NCONN_IDENTITY, ad, ARRAY_SIZE(ad),
sd, ARRAY_SIZE(sd));
if (err) {
printk(&amp;quot;Advertising failed to start (err %d)\n&amp;quot;, err);
return;
}
/* For connectable advertising you would use
* bt_le_oob_get_local(). For non-connectable non-identity
* advertising an non-resolvable private address is used;
* there is no API to retrieve that.
*/
bt_id_get(&amp;amp;addr, &amp;amp;count);
bt_addr_le_to_str(&amp;amp;addr, addr_s, sizeof(addr_s));
printk(&amp;quot;Beacon started, advertising as %s\n&amp;quot;, addr_s);
}

void main(void)
{
int err;
printk(&amp;quot;Starting Beacon Demo\n&amp;quot;);
/* Initialize the Bluetooth Subsystem */
err = bt_enable(bt_ready);
if (err) {
printk(&amp;quot;Bluetooth init failed (err %d)\n&amp;quot;, err);
}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/1134.OK.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;2.-&amp;nbsp;Now I make a small change to the code &amp;quot;main.c&amp;quot; to see the integer value: 999, and I see the 0xE7 in the app.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;const int test_int = 999;

static const struct bt_data ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, BT_LE_AD_NO_BREDR),
// BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0xaa, 0xfe),
BT_DATA_BYTES(test_int),
BT_DATA_BYTES(BT_DATA_SVC_DATA16,
0xaa, 0xfe, /* Eddystone UUID */
0x10, /* Eddystone-URL frame type */
0x00, /* Calibrated Tx power at 0m */
0x00, /* URL Scheme Prefix http://www. */
&amp;#39;z&amp;#39;, &amp;#39;e&amp;#39;, &amp;#39;p&amp;#39;, &amp;#39;h&amp;#39;, &amp;#39;y&amp;#39;, &amp;#39;r&amp;#39;,
&amp;#39;p&amp;#39;, &amp;#39;r&amp;#39;, &amp;#39;o&amp;#39;, &amp;#39;j&amp;#39;, &amp;#39;e&amp;#39;, &amp;#39;c&amp;#39;, &amp;#39;t&amp;#39;,
0x08) /* .org */
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/INT.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;3.-&amp;nbsp;Finally I make another small change to the code &amp;quot;main.c&amp;quot; to see the value char: 999, and again I see the 0xE7 in the app.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;const char test_char = 999;

static const struct bt_data ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, BT_LE_AD_NO_BREDR),
// BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0xaa, 0xfe),
BT_DATA_BYTES(test_char),
BT_DATA_BYTES(BT_DATA_SVC_DATA16,
0xaa, 0xfe, /* Eddystone UUID */
0x10, /* Eddystone-URL frame type */
0x00, /* Calibrated Tx power at 0m */
0x00, /* URL Scheme Prefix http://www. */
&amp;#39;z&amp;#39;, &amp;#39;e&amp;#39;, &amp;#39;p&amp;#39;, &amp;#39;h&amp;#39;, &amp;#39;y&amp;#39;, &amp;#39;r&amp;#39;,
&amp;#39;p&amp;#39;, &amp;#39;r&amp;#39;, &amp;#39;o&amp;#39;, &amp;#39;j&amp;#39;, &amp;#39;e&amp;#39;, &amp;#39;c&amp;#39;, &amp;#39;t&amp;#39;,
0x08) /* .org */
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/CHAR.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;4.- Today I&amp;#39;m working with strings using &amp;quot;sprintf&amp;quot;. The code below compiles fine, but I still don&amp;#39;t know how to add the string &amp;quot;buffer&amp;quot; to the data of &amp;quot;static const struct bt_data ad []&amp;quot;:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int test()
{
char buffer[50];
int a = 10, b = 20, c;
c = a + b;
sprintf(buffer, &amp;quot;Sum of %d and %d is %d&amp;quot;, a, b, c);

// The string &amp;quot;sum of 10 and 20 is 30&amp;quot; is stored
// into buffer instead of printing on stdout

return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I feel like I&amp;#39;m close to the solution, and I&amp;#39;m just trying ideas and none of them satisfy me ... Anything on your mind?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Regards&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Guillermo&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't transmit int data through BLE?</title><link>https://devzone.nordicsemi.com/thread/301963?ContentTypeID=1</link><pubDate>Thu, 25 Mar 2021 15:17:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ea73908-1518-44f2-9324-26c978c862c5</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Is &amp;quot;0x04&amp;quot; what the data looks like before you send it, or when you receive it? We would need to know what it looks like in both ends, in order to have any idea what it might be.&lt;/p&gt;
&lt;p&gt;Can you share the lines of code where you set the data?&lt;br /&gt; And a screenshot from nRF Connect?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>