16
16
#include <zephyr/net/tls_credentials.h>
17
17
#include <zephyr/data/json.h>
18
18
#include <zephyr/random/random.h>
19
+ #include <zephyr/pm/device.h>
20
+ #include <zephyr/pm/device_runtime.h>
19
21
#include <zephyr/logging/log.h>
20
22
#include "net_sample_common.h"
21
23
22
-
23
24
#if defined(CONFIG_MBEDTLS_MEMORY_DEBUG )
24
25
#include <mbedtls/memory_buffer_alloc.h>
25
26
#endif
@@ -31,9 +32,9 @@ LOG_MODULE_REGISTER(aws, LOG_LEVEL_DBG);
31
32
#define AWS_BROKER_PORT CONFIG_AWS_MQTT_PORT
32
33
33
34
#define MQTT_BUFFER_SIZE 256u
34
- #define APP_BUFFER_SIZE 4096u
35
+ #define APP_BUFFER_SIZE 4096u
35
36
36
- #define MAX_RETRIES 10u
37
+ #define MAX_RETRIES 10u
37
38
#define BACKOFF_EXP_BASE_MS 1000u
38
39
#define BACKOFF_EXP_MAX_MS 60000u
39
40
#define BACKOFF_CONST_MS 5000u
@@ -49,11 +50,11 @@ static struct mqtt_client client_ctx;
49
50
static const char mqtt_client_name [] = CONFIG_AWS_THING_NAME ;
50
51
51
52
static uint32_t messages_received_counter ;
52
- static bool do_publish ; /* Trigger client to publish */
53
+ static bool do_publish ; /* Trigger client to publish */
53
54
static bool do_subscribe ; /* Trigger client to subscribe */
54
55
55
56
#if (CONFIG_AWS_MQTT_PORT == 443 && !defined(CONFIG_MQTT_LIB_WEBSOCKET ))
56
- static const char * const alpn_list [] = {"x-amzn-mqtt-ca" };
57
+ static const char * const alpn_list [] = {"x-amzn-mqtt-ca" };
57
58
#endif
58
59
59
60
#define TLS_TAG_DEVICE_CERTIFICATE 1
@@ -193,8 +194,8 @@ static ssize_t handle_published_message(const struct mqtt_publish_param *pub)
193
194
const char * mqtt_evt_type_to_str (enum mqtt_evt_type type )
194
195
{
195
196
static const char * const types [] = {
196
- "CONNACK" , "DISCONNECT" , "PUBLISH" , "PUBACK" , "PUBREC" ,
197
- "PUBREL" , "PUBCOMP" , "SUBACK" , "UNSUBACK" , "PINGRESP" ,
197
+ "CONNACK" , "DISCONNECT" , "PUBLISH" , "PUBACK" , "PUBREC" ,
198
+ "PUBREL" , "PUBCOMP" , "SUBACK" , "UNSUBACK" , "PINGRESP" ,
198
199
};
199
200
200
201
return (type < ARRAY_SIZE (types )) ? types [type ] : "<unknown>" ;
@@ -281,7 +282,7 @@ struct backoff_context {
281
282
282
283
#if defined(CONFIG_AWS_EXPONENTIAL_BACKOFF )
283
284
uint32_t attempt_max_backoff ; /* ms */
284
- uint32_t max_backoff ; /* ms */
285
+ uint32_t max_backoff ; /* ms */
285
286
#endif
286
287
};
287
288
@@ -453,7 +454,14 @@ static int resolve_broker_addr(struct sockaddr_in *broker)
453
454
int main (void )
454
455
{
455
456
setup_credentials ();
457
+ /* Not quite sure where to invoke */
458
+ #ifdef CONFIG_MODEM_HL78XX
459
+ const struct device * modem = DEVICE_DT_GET (DT_ALIAS (modem ));
456
460
461
+ LOG_INF ("Powering on modem\n" );
462
+ pm_device_action_run (modem , PM_DEVICE_ACTION_RESUME );
463
+ #endif
464
+ /* ------------------- */
457
465
wait_for_network ();
458
466
459
467
for (;;) {
0 commit comments