<?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>Integers in characteristics little or big endian?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12653/integers-in-characteristics-little-or-big-endian</link><description>This is a simple question: If I have a characteristic with, let&amp;#39;s say an int16_t in it and catch the write event in a ble_gatts_evt_write_t structure - is the data field in little or big endian order? 
 I tried writing to my characteristic with Nordic</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 28 Mar 2016 17:49:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12653/integers-in-characteristics-little-or-big-endian" /><item><title>RE: Integers in characteristics little or big endian?</title><link>https://devzone.nordicsemi.com/thread/48064?ContentTypeID=1</link><pubDate>Mon, 28 Mar 2016 17:49:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5a73494-5c44-41c1-bc52-94d27dfb993c</guid><dc:creator>Raphael</dc:creator><description>&lt;p&gt;OK, It may be true that it is generally up to the higher layers, but any Bluetooth GATT service, such as the &lt;a href="https://developer.bluetooth.org/TechnologyOverview/Pages/HRS.aspx"&gt;Heart Rate Service&lt;/a&gt;. They all use Little Endian. So Nordic&amp;#39;s MCP really should not set integers in Big Endian order since it&amp;#39;s largely inconsistent with GATT&amp;#39;s standard services.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Integers in characteristics little or big endian?</title><link>https://devzone.nordicsemi.com/thread/48063?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 16:55:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0679f762-5d7d-4e12-9f9f-673d96bc911d</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not entirely sure if I got all this right, but:&lt;/p&gt;
&lt;p&gt;The Bluetooth Core spec Vol 3: Part A, Ch. 3, &amp;quot;Data Packet Format&amp;quot; says:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;All L2CAP layer packet fields shall
use Little Endian byte order &lt;strong&gt;with the
exception of the information payload
field&lt;/strong&gt;. The endian-ness of higher layer
protocols encapsulated within L2CAP
information payload is
protocol-specific.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So the payload is received and stored in memory as big endian. If I use MCP (on my PC) and write 0x11223344 this is how it is transmitted and how it is stored in memory:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/endians.png" alt="image description" /&gt;&lt;/p&gt;
&lt;p&gt;However, the nRF5 core is &lt;em&gt;little&lt;/em&gt; endian so if I cast the four byte long data into an uint32_t I will get 0x44332211.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>