Hi,
I am trying to run the nRF9160 AWS IoT sample - https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/nrf9160/aws_iot/README.html on an nRF9160 DK, but have had no luck. I have done all setup, but the code fails during AWS IoT initialisation:
*** Booting Zephyr OS build v2.4.0-ncs1 *** The AWS IoT sample started, version: v1.0.0 E: aws_topics_populate, error: -12 AWS IoT library could not be initialized, error: -12
I have inspected the call stack, and noticed that aws_topics_populate is called by aws_iot_init, which in turn is called from main.c as follows:
err = aws_iot_init(NULL, aws_iot_event_handler);
if (err) {
printk("AWS IoT library could not be initialized, error: %d\n", err);
}
From the above, the first argument to the function is NULL, is this expected? I noticed that this maps to the aws_iot_config * parameter inside the function declaration in aws_iot.c, and the argument actually gets used, with failure eventually happening inside aws_topics_populate
I read the AWS IoT library documentation - https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/include/net/aws_iot.html#lib-aws-iot, and encountered the note:
The API requires that a configuration structure aws_iot_config is declared in the application and passed into the aws_iot_init() and aws_iot_connect() functions. This exposes the application to the MQTT socket used for the connection, which is polled on, in the application. It also enables the application to pass in a client id (thingname) at runtime.
I then set out to create an instance of the struct, but couldn't figure out what the socket field should be set to.
Question: Am I on the right path the and aws_iot_config instance needs to be created for the nRF9160 AWS IoT sample even though the sample documentation doesn't say so explicitly. And if so, how do determine what the socket value should be set to?
The API requires that a configuration structure aws_iot_config is declared in the application and passed into the aws_iot_init() and aws_iot_connect() functions. This exposes the application to the MQTT socket used for the connection, which is polled on, in the application. It also enables the application to pass in a client id (thingname) at runtime.