This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to check the nRF is connected with MQTT broker or not?

Hi,
I am facing an issue, I am developing nRF9160 based Product, get sensor data  from peripherals and publish to AWS cloud.my firmware is based on AWS IoT sample. I observed that some time devices get disconnected from AWS.I missed the sensor data during that period.
1.Now I want to save data into SD card  during  that disconnected period.? So I need find Exact point in my application which shows that it is disconnected so I log data into SD card.
2.Once if I done it successfully, log the data then I want to send this file to AWS over MQTT when it again connected?

if I place check on shadow_update ( .So for test purpose I remove the antenna from Device while application is running .its Still updating the Shadow(although message not reached on AWS ).how to kill this issue?

static void shadow_update_work_fn(struct k_work *work)
{
int err;

err = shadow_update(false);
if (err) {
printk("shadow_update, error: %d\n", err);
}

printk("Next data publication in %d seconds\n", publication_interval_seconds);

k_delayed_work_submit(&shadow_update_work, K_SECONDS( publication_interval_seconds));
}




Thanks 

  • Waqar Ahmed said:
    let suppose that  I am looking for the network status(by sending command AT+CEREG?) before every publication.

    That would not really be a good way to check if you have a connection. Whn in PSM, the radio is turned off, which means that you have no way of knowing what the current signalling conditions are. Your log shows that your transmit interval is much shorter than the PSM period. This means that you will not be able to base your decision on whether to send or not on recent data.

    When in PSM, you cannot really know if you still are connected to the network or not, unless you try to send something. However, in mfw 1.3.0 and newer, you can use the %CONEVAL command to get an overview of the current conditions without having to send anything.

  • Hi Didrik,

    Thank you for  reply.
    1.Is mfw 1.3.0 or later is compatible with nrfConnect sdk 1.5.0?

    2.if I send this AT+CEREG? is it power consuming command? What is your opinion

  • Waqar Ahmed said:
    1.Is mfw 1.3.0 or later is compatible with nrfConnect sdk 1.5.0?

    MFW 1.3.0 was tested with NCS 1.6.0. However, the interface between the application core and the modem core has generally been quite stable, so even if the NCS and mfw combination hasn't been tested, I don't expect there to be any issues.

    Waqar Ahmed said:
    2.if I send this AT+CEREG? is it power consuming command? What is your opinion

    AT+CEREG? only returns information already stored in the modem, so it should not use much power (i.e. no radio activity, just the CPU time needed to respond). However, this also means that the information might be outdated or not very useful (e.g. you entered PSM while in a connection, then move out of coverage. Because the modem hasn't used the radio, it will still believe it is connected with the network).

Related