<?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>MQTT 128kB packet size</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/73647/mqtt-128kb-packet-size</link><description>Hello, 
 I am using NRF9160 running the Serial LTE Modem application in NCS 1.5.0. When connecting with AWS IoT over a secure MQTT connection the maximum MQTT packet size allowed by AWS IoT is 128kB. When I publish a message of this size from an external</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 30 Sep 2021 15:05:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/73647/mqtt-128kb-packet-size" /><item><title>RE: MQTT 128kB packet size</title><link>https://devzone.nordicsemi.com/thread/331986?ContentTypeID=1</link><pubDate>Thu, 30 Sep 2021 15:05:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0ee3171-91be-43e9-9ae0-4992d60118c0</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Actually, it turns out the POLLHUP issue has already been fixed in upstream Zephyr.&lt;/p&gt;
&lt;p&gt;It will be included in the NCS fork in the next upmerge, and be included in NCS 1.8.0.&lt;/p&gt;
&lt;p&gt;You can find the fix here: &lt;a href="https://github.com/zephyrproject-rtos/zephyr/pull/37794"&gt;https://github.com/zephyrproject-rtos/zephyr/pull/37794&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It should apply cleanly to NCS v1.7.0.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT 128kB packet size</title><link>https://devzone.nordicsemi.com/thread/331853?ContentTypeID=1</link><pubDate>Thu, 30 Sep 2021 08:14:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:edae7624-4570-49e5-a5ff-71adb0154bf2</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi, and again, sorry for this taking so long.&lt;/p&gt;
&lt;p&gt;But, I have some good news this time: I have found a solution/workaround for the POLLHUP problem.&lt;/p&gt;
&lt;p&gt;After some digging, it&amp;nbsp; turned out that the connection to AWS is fine. While I still don&amp;#39;t understand 100% why the POLLHUP flag is set, I believe that either the POLLHUP flag itself is a bug, or the application&amp;#39;s handling of the POLLHUP is wrong. I&amp;#39;ll have to discuss this more with our developers before I can be sure which one it is.&lt;/p&gt;
&lt;p&gt;Regardless, you can simply ignore the POLLHUP, and everthing will work fine.&lt;/p&gt;
&lt;p&gt;What I did was to add a &amp;#39;continue&amp;#39; inside the if that checks if fds.revents has the POLLIN flag set, after the call to mqtt_input (and checking the return value) in mqtt_thread_fn in slm_at_mqtt.c.&lt;/p&gt;
&lt;p&gt;In an unmodified SLM, it would be here: &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/applications/serial_lte_modem/src/mqtt_c/slm_at_mqtt.c#L237"&gt;https://github.com/nrfconnect/sdk-nrf/blob/master/applications/serial_lte_modem/src/mqtt_c/slm_at_mqtt.c#L237&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll try to keep you updated as we open PRs to make AWS connections with native TLS supported.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT 128kB packet size</title><link>https://devzone.nordicsemi.com/thread/326434?ContentTypeID=1</link><pubDate>Tue, 24 Aug 2021 21:37:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c48d67dc-75bb-43f5-b17f-cef5e24a28a5</guid><dc:creator>JWizard</dc:creator><description>&lt;p&gt;I was able to get past the handshake by increasing the&amp;nbsp;CONFIG_MBEDTLS_HEAP_SIZE. In my case to 81920.&lt;br /&gt;&lt;br /&gt;Now the error is POLLHUP. From what I can tell at this moment this occurs immediately, the first time the socket is polled.&lt;br /&gt;&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/723x111/__key/communityserver-discussions-components-files/4/POLLHUP.PNG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT 128kB packet size</title><link>https://devzone.nordicsemi.com/thread/326411?ContentTypeID=1</link><pubDate>Tue, 24 Aug 2021 15:01:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0441044-4115-4daa-807e-af5bc344cc67</guid><dc:creator>JWizard</dc:creator><description>&lt;p&gt;Thanks&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/didrik-rokhaug"&gt;Didrik Rokhaug&lt;/a&gt;&amp;nbsp;The Only reply button seems to be at the top so I&amp;#39;m replying to&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote userid="81181" url="~/f/nordic-q-a/73647/mqtt-128kb-packet-size/325810#325810"]&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Unfortunately, I have not been able to make much progress. I have been quite busy, especially the past couple of months, due to low staffing during the summer acation period.&lt;/p&gt;
&lt;p&gt;I am truly sorry for not having been able to work more on this.&lt;/p&gt;
&lt;p&gt;However, staffing should soon return to normal, which will make it easier to find the time needed to look properly into this issue.&lt;/p&gt;
&lt;p&gt;There has also been a lot of work done on the crypto side, with the inclusion of Trusted Firmware-M.&lt;/p&gt;
&lt;p&gt;This includes adding a sample to the master branch that shows how you can run the TLS stack in the secure domain: &lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/master/samples/crypto/psa_tls"&gt;https://github.com/nrfconnect/sdk-nrf/tree/master/samples/crypto/psa_tls&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;With sincere apologies,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Understood. I will check that out. In the meantime I have found what looks like the point where my error first arises in rsa.c. You can see the Call stack and the line where the error code comes from in this image.&lt;br /&gt;&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x752/__key/communityserver-discussions-components-files/4/rsa_5F00_c_5F00_error.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Watch on &amp;quot;ret&amp;quot; doesn&amp;#39;t work here but I do believe the value is -0x10 = MBEDTLS_ERR_MPI_ALLOC_FAILED.&lt;/p&gt;
&lt;p&gt;Hopefully that might be of use in the future.&lt;br /&gt;&lt;br /&gt;As a side note it&amp;#39;s pretty difficult to step through this code because it is optimized and there is only Common Configuration in the drop down. Is it possible to run this SLM application in an unoptimized Debug configuration?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT 128kB packet size</title><link>https://devzone.nordicsemi.com/thread/325810?ContentTypeID=1</link><pubDate>Thu, 19 Aug 2021 18:21:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd8ac4b8-3cb3-406b-aa54-986deb558451</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Unfortunately, I have not been able to make much progress. I have been quite busy, especially the past couple of months, due to low staffing during the summer acation period.&lt;/p&gt;
&lt;p&gt;I am truly sorry for not having been able to work more on this.&lt;/p&gt;
&lt;p&gt;However, staffing should soon return to normal, which will make it easier to find the time needed to look properly into this issue.&lt;/p&gt;
&lt;p&gt;There has also been a lot of work done on the crypto side, with the inclusion of Trusted Firmware-M.&lt;/p&gt;
&lt;p&gt;This includes adding a sample to the master branch that shows how you can run the TLS stack in the secure domain: &lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/master/samples/crypto/psa_tls"&gt;https://github.com/nrfconnect/sdk-nrf/tree/master/samples/crypto/psa_tls&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;With sincere apologies,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT 128kB packet size</title><link>https://devzone.nordicsemi.com/thread/325593?ContentTypeID=1</link><pubDate>Wed, 18 Aug 2021 20:58:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f9db85f-007b-438f-b04e-490b76c4291d</guid><dc:creator>JWizard</dc:creator><description>&lt;p&gt;Hello &lt;a href="https://devzone.nordicsemi.com/members/didrik-rokhaug"&gt;Didrik Rokhaug&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I haven&amp;#39;t received a reply in some time. I have attempted to repeat the process in NCS 1.6.1 but found the same results. Are there any updates on this topic? Thanks, Jack&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT 128kB packet size</title><link>https://devzone.nordicsemi.com/thread/308001?ContentTypeID=1</link><pubDate>Mon, 03 May 2021 17:11:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f57c609f-f333-42f3-84c0-466b12665871</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;I am able to write the certificates with native TLS using the Certificate Manager in the LTE Link Monitor application.&lt;/p&gt;
&lt;p&gt;However, I did have a problem reading the private key back out when I tried to use it. The problem was that MAX_CRDL_LEN in slm_native_tls.c was too small to hold all three certificate types.&lt;/p&gt;
&lt;p&gt;But, the TLS handshake is still failing. I&amp;#39;ll keep trying to debug this, and let you know when I know more (hopefully it won&amp;#39;t be this long until my next update).&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Is did you use the code you attached to try to write the certificates?&lt;/p&gt;
&lt;p&gt;If so, you must write all certificate types as MODEM_KEY_MGMT_CRED_TYPE_CA_CHAIN, so that they can be read back out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT 128kB packet size</title><link>https://devzone.nordicsemi.com/thread/307337?ContentTypeID=1</link><pubDate>Wed, 28 Apr 2021 22:31:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b622f91-4a93-409b-a04e-3a66a027a507</guid><dc:creator>JWizard</dc:creator><description>&lt;p&gt;Thank you Didrik.&lt;br /&gt;&lt;br /&gt;I think I misunderstood the mapping, however, I have tried using the Native TLS version to write the credentials and I could not connect to my Broker. It is possible that I did not format the creds correctly.&lt;br /&gt;&lt;br /&gt;So I took the mapping knowledge and I used a non-native TLS App to write the creds to SecTag = 240.&lt;br /&gt;&lt;br /&gt;I reloaded the NativeTLS application and I do read my type 0 credential with AT%CMNG=2,24,0.&lt;br /&gt;&lt;br /&gt;However It still is not connecting. Interestingly I get this output. The first time I am using the correct port and the second time I used an incorrect port and got different output.&lt;br /&gt;&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1000x1000/__key/communityserver-discussions-components-files/4/TestNewSecTag.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I tried again this time incrementing the SEC_TAG (per the mapping function) when I use the modem_key_mgmt_write function in a non-native TLS app.&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    err = modem_key_mgmt_write(CONFIG_MQTT_TLS_SEC_TAG,
				   MODEM_KEY_MGMT_CRED_TYPE_CA_CHAIN,
				   CA_CERTIFICATE,
				   strlen(CA_CERTIFICATE));
	if (err) {
		LOG_ERR(&amp;quot;Failed to provision CA certificate: %d&amp;quot;, err);
		return err;

        
	}
        
        err = modem_key_mgmt_write(CONFIG_MQTT_TLS_SEC_TAG+1,
				   MODEM_KEY_MGMT_CRED_TYPE_PUBLIC_CERT,
				   CLIENT_PUBLIC_CERTIFICATE,
				   strlen(CLIENT_PUBLIC_CERTIFICATE));
	if (err) {
		LOG_ERR(&amp;quot;Failed to provision public certificate: %d&amp;quot;, err);
		return err;
        }

        err = modem_key_mgmt_write(CONFIG_MQTT_TLS_SEC_TAG+2,
				   MODEM_KEY_MGMT_CRED_TYPE_PRIVATE_CERT,
				   CLIENT_PRIVATE_KEY,
				   strlen(CLIENT_PRIVATE_KEY));
	if (err) {
		LOG_ERR(&amp;quot;Failed to provision private key: %d&amp;quot;, err);
		return err;
        }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Results were the same.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT 128kB packet size</title><link>https://devzone.nordicsemi.com/thread/307295?ContentTypeID=1</link><pubDate>Wed, 28 Apr 2021 14:46:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54537d39-2b2f-4629-86e7-ba3949f1efe0</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;The CLAC problem has been fixed in the fork the SLM developers are working on.&lt;/p&gt;
&lt;p&gt;If I have understood their fix correctly, they do it by only checking for CLAC responses of the second line of the respons, rather than the first.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="JWizard"]And now I am at least getting through to something happening and getting &amp;quot;FAILED! modem_key_mgmt_read() = -22&amp;quot; in my log.[/quote]
&lt;p&gt;&amp;nbsp;Did you write a certificate (with the SLM configured to use native TLS) to that sec_tag first?&lt;/p&gt;
&lt;p&gt;When native TLS is enabled, the SLM remaps the sec_tags, so if the certificates was written without the remapping, you have to map backwards to find the new sec_tag you must use with %CMNG.&lt;/p&gt;
&lt;p&gt;You can find the mapping function here: &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v1.5.0/applications/serial_lte_modem/src/slm_native_tls.c#L21"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v1.5.0/applications/serial_lte_modem/src/slm_native_tls.c#L21&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll continue to work on using the native TLS stack for connecting to an MQTT broker tomorrow.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT 128kB packet size</title><link>https://devzone.nordicsemi.com/thread/307081?ContentTypeID=1</link><pubDate>Tue, 27 Apr 2021 14:52:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:258f7c17-b892-4e82-b009-0085b4ffc8ea</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi, and sorry for the late reply.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="JWizard"]&lt;br /&gt;The documentation of SLM states I &amp;quot;must&amp;quot; use the overridden %CMNG command to provision credentials. What does this mean exactly?[/quote]
&lt;p&gt;&amp;nbsp;Normally, %CMNG writes the credentials to the modem, where they cannot be read by the application (except for the root CA certificates).&lt;/p&gt;
&lt;p&gt;The overridden %CMNG command is used automatically when you enable CONFIG_SLM_NATIVE_TLS, so it is not really something you have to think about, except for %CMNG=1 not being supported in the overridden version.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="JWizard"]There is a comment in slm_at_cmng.c that says it should be like this:&amp;nbsp;&lt;span&gt;AT#XCMNG, but that doesn&amp;#39;t change the outcome.&lt;/span&gt;[/quote]
&lt;p&gt;&amp;nbsp;I believe AT#XCMNG was used in an earlier version, though I might be mistaken.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="JWizard"]For good measure I ran CLAC and AT%CMNG does in fact appear in the list of available commands, AT#XCMNG does not.[/quote]
&lt;p&gt;&amp;nbsp;Anyway, if it was supported, I would expect it to be listed by #CLAC, not %CLAC.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="JWizard"]Do I need to issue %CMNG with the write opcode for each of my three credentials every time I start the application?[/quote]
&lt;p&gt;&amp;nbsp;No. The credentials are stored in the modem as CA certificates, so that the application can read them out later if it needs them.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="JWizard"]AT%CMNG=2,24,0 fails at the first check in handle_at_xcmng. Line 73 of slm_at_cmng.c. I edited the LOGERR to differentiate it from the others.[/quote]
&lt;p&gt;&amp;nbsp;Yes, I get this as well.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="JWizard"]Testing with other known commands such as AT+CFUN seems to show these commands are not parsed in at_parse_param of at_cmd_parser.c. Special commands of the structure AT#X... are parsed in this function, and it is apparent that the &amp;#39;X&amp;#39; is specifically meant to differentiate a command subject to this parser from a CLAC response.[/quote]
&lt;p&gt;&amp;nbsp;&amp;quot;normal&amp;quot; AT commands are sent to the modem, where they are parsed and handled. The exception here is %CMNG, which normally would be sent to the modem, but we now want to intercept so that we can do something else with it. AT#-commands on the other hand are implemented by the SLM on the application core, and must therefore be parsed by the application.&lt;/p&gt;
&lt;p&gt;The &amp;#39;X&amp;#39; is used to differentiate between standard AT commands specified by 3GPP, and custom commands added by us.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="JWizard"]So I don&amp;#39;t think this is probably how you should do this but I edited is_clac in at_utils.h to read:[/quote]
&lt;p&gt;&amp;nbsp;I haven&amp;#39;t fully wrapped my head around the parser logic, and why CLAC responses must be detected. But it is not unreasonable for is_clac to trigger here, as you wouldn&amp;#39;t encounter AT%&amp;lt;non &amp;#39;X&amp;#39;&amp;gt; anywhere normally, except for this special case where we want to override an AT command, while using a parser not made to handle that scenario.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll discuss the best way to handle this with our developers tomorrow, along with looking into your other problems with using the credentials.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT 128kB packet size</title><link>https://devzone.nordicsemi.com/thread/305952?ContentTypeID=1</link><pubDate>Tue, 20 Apr 2021 19:01:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9610845c-6077-46ad-90c4-fed233748814</guid><dc:creator>JWizard</dc:creator><description>&lt;p&gt;Thank you for the clarifications Didrik. I did not expect it to be easy, but your reply has helped a lot in getting started.&lt;br /&gt;&lt;br /&gt;If half of the RAM is still available while using the SLM then yes that is exactly what I should try and accomplish.&lt;br /&gt;&amp;nbsp;&lt;br /&gt;But I am first trying to establish a connection with the MQTT broker using TLS in the application core. I have not been successful and I think it has something to do with credentials. I changed &amp;quot;overlay-native_tls.conf&amp;quot; so it looks like this&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;# To build serial LTE modem native TLS socket support&lt;br /&gt;# add the following to your west build command:&lt;br /&gt;# -DOVERLAY_CONFIG=overlay-native_tls.conf&lt;br /&gt;#&lt;/p&gt;
&lt;p&gt;# TLS configuration&lt;br /&gt;CONFIG_SLM_NATIVE_TLS=y&lt;br /&gt;CONFIG_MODEM_KEY_MGMT=y&lt;br /&gt;CONFIG_MBEDTLS=y&lt;br /&gt;CONFIG_MBEDTLS_LIBRARY=y&lt;br /&gt;CONFIG_MBEDTLS_TLS_LIBRARY=y&lt;br /&gt;CONFIG_MBEDTLS_PKCS1_V15=y&lt;br /&gt;CONFIG_MBEDTLS_ENABLE_HEAP=y&lt;br /&gt;CONFIG_MBEDTLS_INSTALL_PATH=&amp;quot;DUMMY&amp;quot;&lt;br /&gt;# If larger TLS buffer is required for large CA chain,&lt;br /&gt;# increase CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN to 4096&lt;br /&gt;# and CONFIG_MBEDTLS_HEAP_SIZE to 32768&lt;br /&gt;#CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=1280&lt;br /&gt;#CONFIG_MBEDTLS_HEAP_SIZE=23040&lt;br /&gt;CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=4096&lt;br /&gt;CONFIG_MBEDTLS_HEAP_SIZE=32768&lt;br /&gt;CONFIG_NET_SOCKETS_OFFLOAD_TLS=n&lt;br /&gt;CONFIG_NET_SOCKETS_SOCKOPT_TLS=y&lt;br /&gt;CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=2&lt;br /&gt;# Increase extra FD entry for TLS contexts(2)&lt;br /&gt;CONFIG_POSIX_MAX_FDS=10&lt;br /&gt;CONFIG_NORDIC_SECURITY_BACKEND=y&lt;br /&gt;CONFIG_NRF_SECURITY_ADVANCED=y&lt;br /&gt;# Enable Socket Logging for debug&lt;br /&gt;#CONFIG_NET_LOG=y&lt;br /&gt;#CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=y&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;according to the note in the middle of this file about large CA chains (in case that refers to me.) And I build with&amp;nbsp;&lt;code&gt;&lt;span&gt;-DOVERLAY_CONFIG=overlay-native_tls.conf&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The documentation of SLM states I &amp;quot;must&amp;quot; use the overridden %CMNG command to provision credentials. What does this mean exactly? Do I need to issue %CMNG with the write opcode for each of my three credentials every time I start the application?&lt;br /&gt;&lt;br /&gt;This is what I have been trying to do but without success. I was thinking I have not found the correct way to format the certificates but then I discovered that every %CMNG command is returning a simple &amp;quot;ERROR.&amp;quot;&lt;br /&gt;&lt;br /&gt;For example if I try to read a CA Root Cert with security tag 24: AT%CMNG=2,24,0 will return ERROR. I have not been able to get a success or even a +CME Error Code&lt;br /&gt;&lt;br /&gt;I have set CFUN=4 like it says to do if I want to write a credential.&lt;/p&gt;
&lt;p&gt;There is a comment in slm_at_cmng.c that says it should be like this:&amp;nbsp;&lt;span&gt;AT#XCMNG, but that doesn&amp;#39;t change the outcome.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For good measure I ran CLAC and AT%CMNG does in fact appear in the list of available commands, AT#XCMNG does not.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Am I misunderstanding something about the overridden %CMNG command?&lt;br /&gt;&lt;br /&gt;Update: AT%CMNG=2,24,0 fails at the first check in handle_at_xcmng. Line 73 of slm_at_cmng.c. I edited the LOGERR to differentiate it from the others.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;static int handle_at_xcmng(enum at_cmd_type cmd_type)&lt;/code&gt;&lt;br /&gt;&lt;code&gt;{&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; int err = -EINVAL;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; uint16_t op, type;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; nrf_sec_tag_t sec_tag;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; uint8_t *content;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; size_t len = CONFIG_AT_CMD_RESPONSE_MAX_LEN;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; switch (cmd_type) {&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; case AT_CMD_TYPE_SET_COMMAND:&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (at_params_valid_count_get(&amp;amp;at_param_list) &amp;lt; 2) {&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LOG_ERR(&amp;quot;Parameter missed at first get count&amp;quot;);&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return -EINVAL;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;Update:&lt;br /&gt;&lt;/code&gt;I am struggling to wrap my mind around the full operation of the at_parser, however it appears to me that this AT%CMNG is being treated as a CLAC response, which results in the at_params_list containing just one element, the whole string.&lt;br /&gt;&lt;br /&gt;Testing with other known commands such as AT+CFUN seems to show these commands are not parsed in at_parse_param of at_cmd_parser.c. Special commands of the structure AT#X... are parsed in this function, and it is apparent that the &amp;#39;X&amp;#39; is specifically meant to differentiate a command subject to this parser from a CLAC response.&lt;br /&gt;&lt;br /&gt;So I don&amp;#39;t think this is probably how you should do this but I edited is_clac in at_utils.h to read:&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;static bool is_clac(const char *str)&lt;/code&gt;&lt;br /&gt;&lt;code&gt;{&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; if (strlen(str) &amp;lt; 4) {&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return false;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; }&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; if ((toupper(str[0]) != &amp;#39;A&amp;#39;) || (toupper(str[1]) != &amp;#39;T&amp;#39;)) {&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* Not an AT command */&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return false;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; }&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; if ((toupper(str[2]) != &amp;#39;+&amp;#39;) &amp;amp;&amp;amp; (toupper(str[2]) != &amp;#39;%&amp;#39;)) {&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; /* Neither AT+ nor AT% */&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; return false;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; }&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; if ((toupper(str[2]) == &amp;#39;%&amp;#39;) &amp;amp;&amp;amp; ((toupper(str[3]) == &amp;#39;X&amp;#39;) ||&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (strlen(str) &amp;gt;= 7) &amp;amp;&amp;amp; (toupper(str[3]) == &amp;#39;C&amp;#39;) &amp;amp;&amp;amp; (toupper(str[4]) == &amp;#39;M&amp;#39;)&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;&amp;amp; (toupper(str[5]) == &amp;#39;N&amp;#39;) &amp;amp;&amp;amp; (toupper(str[6]) == &amp;#39;G&amp;#39;))){&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* Ignore AT%X to avoid false detect (read resp XCOEX0 etc.) */&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* Ignore CMNG */&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return false;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; }&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; return true;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;And now I am at least getting through to something happening and getting &amp;quot;FAILED! modem_key_mgmt_read() = -22&amp;quot; in my log.&lt;/p&gt;
&lt;p&gt;-----------------------------------------------&lt;/p&gt;
&lt;p&gt;Update:&lt;/p&gt;
&lt;p&gt;It seems that provisioning credentials is now possible with the is_clac edits. I have tried many ways of formatting the credentials but I always get this message when I try to connect to the broker whether I use the URL or the IP directly:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/788x131/__key/communityserver-discussions-components-files/4/mqttcon.PNG" /&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT 128kB packet size</title><link>https://devzone.nordicsemi.com/thread/303844?ContentTypeID=1</link><pubDate>Thu, 08 Apr 2021 15:35:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:387b88a9-0b61-4ee2-a0ce-28576dbca9bd</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]When I publish a message of this size from an external device my nrf9160 device outputs the error -128. What is this error?[/quote]
&lt;p&gt;&amp;nbsp;ENOTCONN.&lt;/p&gt;
&lt;p&gt;You get this error because the nRF9160 modem does not support TLS fragments this large, and closes the connection.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""] 128 does not appear in errno.h.[/quote]
&lt;p&gt;&amp;nbsp;Yes, it does: &lt;a href="https://github.com/eblot/newlib/blob/2a63fa0fd26ffb6603f69d9e369e944fe449c246/newlib/libc/include/sys/errno.h#L161"&gt;https://github.com/eblot/newlib/blob/2a63fa0fd26ffb6603f69d9e369e944fe449c246/newlib/libc/include/sys/errno.h#L161&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Your confusion comes from the fact that Zephyr and NCS supports two different implementations of libc. Zephyr has it&amp;#39;s own minimal implementation (which is the default), but it also supports the Newlib implementation which is distributed with the compiler.&lt;/p&gt;
&lt;p&gt;These two implementations uses different values for the error codes.&lt;/p&gt;
&lt;p&gt;The aws_iot sample has enabled the Newlib implementation by setting CONFIG_NEWLIB_LIBC=y in the prj.conf file.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]How can I allow the maximum packet size of 128kB from AWS IoT to be received by the nrf9160?[/quote]
&lt;p&gt;&amp;nbsp;Realistically, you can&amp;#39;t.&lt;/p&gt;
&lt;p&gt;The modem only supports TLS fragments up to ~2kB.&lt;/p&gt;
&lt;p&gt;You can also run the TLS stack on the application core, instead of in the modem. This will let you increase the buffer size, but a buffer size of 128kB would be half the RAM available on the nRF9160 (if you are interested in this, take a look at &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/serial_lte_modem/doc/slm_description.html#native-tls-sockets"&gt;how it is done in the SLM&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;You can read about how the nRF Asset Tracker works around this limitation here: &lt;a href="https://nordicsemiconductor.github.io/asset-tracker-cloud-docs/v1.5.x/docs/aws/LimitingShadowDocumentSize.html"&gt;https://nordicsemiconductor.github.io/asset-tracker-cloud-docs/v1.5.x/docs/aws/LimitingShadowDocumentSize.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>