<?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>NCS BLE mesh memory safety of mesh send and publish functions</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94996/ncs-ble-mesh-memory-safety-of-mesh-send-and-publish-functions</link><description>I am working on a BLE mesh project, and I have created my own BLE mesh publish and send functions, 
 
 
 My concern is, I am creating buffers using the bt_mesh_model_msg_init() and NET_BUF_SIMPLE() functions, which I suspect might perform dynamic allocation</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 21 Dec 2022 12:59:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94996/ncs-ble-mesh-memory-safety-of-mesh-send-and-publish-functions" /><item><title>RE: NCS BLE mesh memory safety of mesh send and publish functions</title><link>https://devzone.nordicsemi.com/thread/401716?ContentTypeID=1</link><pubDate>Wed, 21 Dec 2022 12:59:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81c4b3fb-f983-403e-85ff-7dbfdcb79f0e</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;I did make them from the BLE mesh vendor model example provided. Sounds like it is safe to use.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS BLE mesh memory safety of mesh send and publish functions</title><link>https://devzone.nordicsemi.com/thread/401559?ContentTypeID=1</link><pubDate>Tue, 20 Dec 2022 15:02:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e3ca13b-8d6d-44a5-9a77-c5d089a89eca</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;To me, it looks like bt_mesh_model_msg_init() is used by most of our mesh examples, so I think this one is safe to use. The same goes for NET_BUF_SIMPLE_DEFINE(), if that is what you meant? If you mean NET_BUF_SIMPLE(), can you please let me know where you found it being used, and where you found the implementation of it (if you found it).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user=""]&lt;p&gt;Or tell me how I can find that out for myself?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;I suggest looking at our samples that are closest to what you want to acheive, such as the mesh samples in this case. When you are using Bluetooth Mesh, or the &amp;quot;normal&amp;quot; BLE samples which both uses the SoftDevice Controller (the Bluetooth Low Energy Stack), these buffers are usually copied locally to the bluetooth stack, and handled (released) when they are done with that message.&lt;/p&gt;
&lt;p&gt;Both of the functions (function and macro) that you refer to,&amp;nbsp;are just creating buffers that are being used in the function where they are being called, and the content of the buffer is copied into the softdevice controller, as far as I can tell.&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></channel></rss>