<?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>AWS FOTA Update inconsistent</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74821/aws-fota-update-inconsistent</link><description>Hi dev team, 
 I am using a Thingy91 device along with the NCS v1.5.1. 
 I used the AWS FOTA example for firmware upgrades and I integrated the example in my code. 
 The FOTA update works for me but sometimes it hangs. It works for me once and the next</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 26 May 2021 13:56:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74821/aws-fota-update-inconsistent" /><item><title>RE: AWS FOTA Update inconsistent</title><link>https://devzone.nordicsemi.com/thread/311843?ContentTypeID=1</link><pubDate>Wed, 26 May 2021 13:56:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:748b97f4-d10d-4c98-8598-4cd20d03fdb6</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi Adeel,&lt;/p&gt;
&lt;p&gt;Good to hear that you figured out what was causing the issue, and that you were able to create a workaround for now.&lt;/p&gt;
&lt;p&gt;Have you tested how this works with the AWS FOTA sample, is the behavior the same there when you have a job in queue before your device connects? It might be related to how AWS IoT notifies your device about a job. As I have mentioned before, in the sample the device receives notifications about available jobs through MQTT, by subscribing to the app_fw_update job topic. So it might be that AWS IoT only sends a notification on this topic when the job is created. If so, you should see the same behavior in the AWS FOTA sample as well, and you will have to implement something so that it will notify your device later if it is not connected when the job is created. The other possibility is that there is something on the application side that causes you to not receive this notification.&lt;/p&gt;
&lt;p&gt;Modem trace is used by us to look at the communication with the modem, to try and figure out what is wrong if for example a disconnect happens. Since it seems like you have figured out what the problem it, I am not sure a modem trace is necessary, but you can still get one if you are still seeing errors from the modem in your log. You must use the Trace Collector in nRF Connect for Desktop to get a modem trace. The guide for doing this with Thingy:91 can be found&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ug_trace_collector/UG/trace_collector/capture_modem_trace_thingy.html"&gt;here&lt;/a&gt;. Make sure that you have&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ug_trace_collector/UG/trace_collector/update_board_controller_thingy.html?cp=9_3_3_4_0"&gt;updated the board controller firmware&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ug_trace_collector/UG/trace_collector/enable_tracing_thingy.html"&gt;enabled tracing in the application&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS FOTA Update inconsistent</title><link>https://devzone.nordicsemi.com/thread/311439?ContentTypeID=1</link><pubDate>Tue, 25 May 2021 12:05:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:679f24b0-4884-4247-8695-adf1f2d0879e</guid><dc:creator>Adeel</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;Sorry for the late reply. Actually the issue that I have noticed is that if I keep a job in queue before connecting to the AWS IoT, then the job is not picked up by the Thingy.&lt;/p&gt;
&lt;p&gt;However, if I create the job when the Thingy is subscribed to the AWS , then it works perfectly. So, as a work around for now, I am creating the job when I am subscribing to the FOTA and that works for now.&lt;/p&gt;
&lt;p&gt;What I am curious to see is why does the issue occur when the job is already created and queued in the Job section of AWS IoT:&lt;/p&gt;
&lt;p&gt;Also, could you let me know how to get the modem trace from the Link monitor ?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Adeel.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS FOTA Update inconsistent</title><link>https://devzone.nordicsemi.com/thread/310526?ContentTypeID=1</link><pubDate>Wed, 19 May 2021 14:42:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75ffbe8b-361e-4a73-9d2a-bbb4bef34454</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi Adeel,&lt;/p&gt;
&lt;p&gt;I see you are getting errors -5 and -128. -5 is EIO&amp;nbsp;(input/output error), and -128 is&amp;nbsp;ENOTCONN (socket is not connected). In cellular examples, EIO can be returned if you are sending an AT command to the modem and the function failed to send the command, but I am not certain why you are getting that error in your case.&lt;/p&gt;
&lt;p&gt;Could you get a&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ug_trace_collector/UG/trace_collector/collect_modem_trace.html"&gt;modem trace&lt;/a&gt;&amp;nbsp;of when this happens and attach it here?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS FOTA Update inconsistent</title><link>https://devzone.nordicsemi.com/thread/310229?ContentTypeID=1</link><pubDate>Tue, 18 May 2021 15:37:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0744c84-4605-4013-a385-dae2fb7cbd1a</guid><dc:creator>Adeel</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;Thanks for clarifying this for me. I actually am no longer getting the Version Mismatch error.&lt;/p&gt;
&lt;p&gt;I am getting a different error which i will try to briefly explain to get some inputs from you:&amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am actually connecting to a different server and subscribing to it via MQTT and getting a command from the server. The command is received by the device when it subscribes to the server. I try to initiate my FOTA update through this command (FOTA). When I do it, the FOTA works perfectly once and updates. When I try to do it the next time, I get a Job rejected error inspite of having a job available in the AWS IoT.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I get an error that I think is mostly due a conflict with the MQTT payload buf.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Error-in-2nd-FOTA-update.txt"&gt;devzone.nordicsemi.com/.../Error-in-2nd-FOTA-update.txt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Could you help me understand where the issue could be ? I have integrated the AWS_FOTA sample (for my FOTA updates) in my application along with the mqtt_simple application (for my MQTT data) as well.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Adeel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS FOTA Update inconsistent</title><link>https://devzone.nordicsemi.com/thread/309552?ContentTypeID=1</link><pubDate>Wed, 12 May 2021 14:56:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d9525d6-e00a-4ca1-8bb8-f9fc2c4a6e75</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The job version that version mismatch reacts to is not the same as&amp;nbsp;fwversion, but&amp;nbsp;the version of the job execution. This will be the field &amp;quot;versionNumber&amp;quot; in a JobExecution object, which can for example look like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;{
&amp;quot;execution&amp;quot; : {
    &amp;quot;jobId&amp;quot; : &amp;quot;022&amp;quot;,
    &amp;quot;thingName&amp;quot; : &amp;quot;MyThing&amp;quot;,
    &amp;quot;jobDocument&amp;quot; : &amp;quot;&amp;lt; contents of job document &amp;gt;&amp;quot;,
    &amp;quot;status&amp;quot; : &amp;quot;IN_PROGRESS&amp;quot;,
    &amp;quot;queuedAt&amp;quot; : 1489096123309,
    &amp;quot;lastUpdatedAt&amp;quot; : 1489096123309,
    &amp;quot;versionNumber&amp;quot; : 1,
    &amp;quot;executionNumber&amp;quot; : 1234567890
},
&amp;quot;clientToken&amp;quot; : &amp;quot;client-1&amp;quot;,
&amp;quot;timestamp&amp;quot; : 1489088524284,
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can read more about job executions&amp;nbsp;&lt;a href="https://docs.aws.amazon.com/iot/latest/developerguide/jobs-mqtt-api.html"&gt;here&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://docs.aws.amazon.com/iot/latest/developerguide/jobs-data-plane-data-types.html"&gt;here&lt;/a&gt;. I have not been able to figure out what might cause this error, as there is not much information about it unfortunately.&lt;/p&gt;
&lt;p&gt;The device will subscribe to the topic, and if it receives a message it will go into the case&amp;nbsp;MQTT_EVT_PUBLISH in&amp;nbsp;mqtt_evt_handler(). It does not check the topic for messages and see if it is empty or if there is a message there. When it subscribes to a topic it will only receive a message when one is sent, and that is when it will react and handle that message. If you want to disconnect if it does not receive any messages on that topic for some time you can&amp;nbsp;create some sort of timer or timeout, and then disconnect if it times out without any new messages being received on the topic.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS FOTA Update inconsistent</title><link>https://devzone.nordicsemi.com/thread/309428?ContentTypeID=1</link><pubDate>Wed, 12 May 2021 09:26:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:878f1120-9f42-4a27-8792-28a1c0bde2dd</guid><dc:creator>Adeel</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
[quote userid="92402" url="~/f/nordic-q-a/74821/aws-fota-update-inconsistent/309151#309151"]Are you experiencing&amp;nbsp;the VersionMismatch&amp;nbsp;issue&amp;nbsp;if you use a clean version of the AWS FOTA sample, or only with your own application?[/quote]
&lt;p&gt;I only experience it with my application. Could it be something related to my version number in my Job document ?&lt;/p&gt;
[quote userid="92402" url="~/f/nordic-q-a/74821/aws-fota-update-inconsistent/309151#309151"]In this case you can for example disconnect if you do not receive any messages on this topic.[/quote]
&lt;p&gt;Where could I call the mqtt_disconnect() function to do this exactly in the AWS_FOTA sample&amp;nbsp; ? I would like to it in such a way that I disconnect if there is no message on the topic. Can you please help me with this ?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Adeel.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS FOTA Update inconsistent</title><link>https://devzone.nordicsemi.com/thread/309151?ContentTypeID=1</link><pubDate>Tue, 11 May 2021 08:53:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:776fa2bb-c811-47c9-9301-6bea29bb4390</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Are you experiencing&amp;nbsp;the VersionMismatch&amp;nbsp;issue&amp;nbsp;if you use a clean version of the AWS FOTA sample, or only with your own application?&lt;/p&gt;
&lt;p&gt;You can disconnect from the MQTT client with the function&amp;nbsp;mqtt_disconnect(). &lt;span&gt;What you want the trigger that causes your device to disconnect to be is up to you. I&lt;/span&gt;n the AWS FOTA sample the device subscribes to the app_fw_update job topic, so it will be notified when a update job is created. In this case you can for example disconnect if you do not receive any messages on this topic.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS FOTA Update inconsistent</title><link>https://devzone.nordicsemi.com/thread/308768?ContentTypeID=1</link><pubDate>Fri, 07 May 2021 14:01:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f306a482-fcb9-41f3-ada6-3557c275c701</guid><dc:creator>Adeel</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;Thanks, that would be great. Also, I sometimes face an issue where I have no job available and the AWS MQTT stays connected. I want it to disconnect gracefully if there is no job in the server.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How can I have a do an implementation wherein the MQTT can gracefully disconnect if it cannot find any job in the AWS IoT jobs ? Currently, it stays connected all the time and does not disconnect.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Adeel.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS FOTA Update inconsistent</title><link>https://devzone.nordicsemi.com/thread/308757?ContentTypeID=1</link><pubDate>Fri, 07 May 2021 13:18:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c099d6db-22fa-4f98-bdb6-697802c79e24</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;From your log I can see that is says VersionMismatch. You get this error if the version of the job executed stored in Jobs does not match expected version. Each time you update the job execution, its version is incremented. So it seems like the version has incremented for some reason when it should not have, or that the expected version is incorrect.&amp;nbsp;I am not certain why there is a mismatch, as I have not seen this error happening in NCS before. There could be a problem if you are running multiple instances of the same job simultaneously. I did find someone experiencing the same issue on the&amp;nbsp;&lt;a href="https://forums.aws.amazon.com/thread.jspa?threadID=319451"&gt;AWS forum&lt;/a&gt;, so you can try the suggestion there. I will keep looking into this and see if I can find any reasons for why you are getting VersionMismatch.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS FOTA Update inconsistent</title><link>https://devzone.nordicsemi.com/thread/308566?ContentTypeID=1</link><pubDate>Thu, 06 May 2021 13:35:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:298ff1bc-2ca5-45d2-81a8-e6bfb0b70bde</guid><dc:creator>Adeel</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
[quote userid="92402" url="~/f/nordic-q-a/74821/aws-fota-update-inconsistent/308554#308554"]Here the application goes into&amp;nbsp;mqtt_evt_handler() and the case&amp;nbsp;MQTT_EVT_PUBLISH twice, so you are receiving two publish events on your device.[/quote]
&lt;p&gt;This is a command that I send through MQTT to start the FOTA, so it should not interfere with the issue here.&lt;/p&gt;
&lt;p&gt;However, I see an error that is logged after the job is rejected.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Rejected-with-error-message.txt"&gt;devzone.nordicsemi.com/.../Rejected-with-error-message.txt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It says a mismatch error but I could not understand what that is. This could maybe be related to my Job file as it says a mismatch.&lt;/p&gt;
&lt;p&gt;I am attaching my job file for reference.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Job.txt"&gt;devzone.nordicsemi.com/.../Job.txt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Could you let me know what this error means ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;One thing that is peculiar here is that : FOTA update is successful once, but is rejected the next time.&lt;/p&gt;
&lt;p&gt;Its happening in an alternate way (once successful, once rejected) which is really weird.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Adeel.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS FOTA Update inconsistent</title><link>https://devzone.nordicsemi.com/thread/308554?ContentTypeID=1</link><pubDate>Thu, 06 May 2021 12:47:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6751155b-85b9-4ce2-b1b0-967b96195433</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi Adeel,&lt;/p&gt;
&lt;p&gt;From the log it seems like you are receiving the job twice the times it is rejected:&lt;/p&gt;
&lt;pre&gt;[mqtt_evt_handler:162] MQTT client connected!&lt;br /&gt;Subscribing to: sensorstest1/nrf352656100980047/commands2&lt;br /&gt;[mqtt_evt_handler:190] MQTT PUBLISH result=0 len=4&lt;br /&gt;Received: FOTA&lt;br /&gt;Payload buf is : FOTA&lt;br /&gt;[mqtt_evt_handler:190] MQTT PUBLISH result=0 len=4&lt;br /&gt;Received: FOTA&lt;br /&gt;Payload buf is : FOTA&lt;/pre&gt;
&lt;p&gt;Here the application goes into&amp;nbsp;mqtt_evt_handler() and the case&amp;nbsp;MQTT_EVT_PUBLISH twice, so you are receiving two publish events on your device.&lt;/p&gt;
&lt;p&gt;There was a known issue where the device received multiple notify-next messages in AWS FOTA before, but this was fixed before NCS v1.5.0, so you should not get this error when you are using v1.5.1. The changes that were done to fix this issue can be found&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/commit/004f8092d7b295a95d394b53d781edbcaeacf17e#diff-3be2efd8e80c580e7251d3efba3cfceab5ab7074bdc24d72c81f445fce7f933a"&gt;here&lt;/a&gt;,&amp;nbsp;but this part in nrf/subsys/net/lib/aws_fota/src/aws_fota.c has been changed since then, so it does not look the same in v1.5.1 as in that change. However, the for when&amp;nbsp;get_job_execution() is called is the same in v1.5.1:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	if (is_notify_next_topic) {
		if (fota_state == NONE) {
			LOG_DBG(&amp;quot;Checking for an available job&amp;quot;);

			return get_job_execution(client, payload_len);
		}
		
...

	} else if (is_get_next_topic || is_get_accepted) {
		LOG_DBG(&amp;quot;Checking for an available job&amp;quot;);
		return get_job_execution(client, payload_len);
	}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can also try to check your device&amp;#39;s shadow in AWS IoT, to get more information about why the job is rejected. The device should be publishing to the /update topic, which will create and update the shadow of your device. When the job is rejected, AWS IoT will publish a message to the &lt;span&gt;$aws/things/&lt;/span&gt;&lt;code&gt;thingName&lt;/code&gt;&lt;span&gt;/shadow/name/&lt;/span&gt;&lt;code&gt;shadowName&lt;/code&gt;&lt;span&gt;/update/rejected&lt;/span&gt;. This message contains an error response document that describes the error. For more information about&amp;nbsp;this you can check out&amp;nbsp;&lt;a href="https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-data-flow.html"&gt;Interacting with shadows&lt;/a&gt;,&amp;nbsp;&lt;a href="https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-document.html"&gt;Device Shadow service documents&lt;/a&gt;, and&amp;nbsp;&lt;a href="https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-error-messages.html"&gt;Device Shadow error messages&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Please check that your application has the correct behavior in regards to multiple notify-next messages. If this issue persists, could you please get a&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ug_trace_collector/UG/trace_collector/intro.html"&gt;modem trace&lt;/a&gt;&amp;nbsp;of this behavior?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>