I have the following code that prints to my serial console in mongoose os. I can see the device in amazon aws, and in mdash as online. I get back a 0 from the pub and it never sends a message to aws mqtt I have subscribed to the topic in the test seciton in mqtt so not sure what I am doing wrong
I followed every instruction here including the internet button video
https://mongoose-os.com/docs/mongoose-os/cloud/aws.md
load("api_gpio.js");
load("api_mqtt.js");
load("api_sys.js");
let pin = 0;
GPIO.set_button_handler(
pin,
GPIO.PULL_UP,
GPIO.INT_EDGE_NEG,
50,
function (x) {
let topic = "mOS/topic1";
let message = JSON.stringify({
total_ram: Sys.total_ram(),
free_ram: Sys.free_ram(),
});
let ok = MQTT.pub(topic, message, message.length);
let test = ok;
let res = MQTT.pub("mOS/topic1", JSON.stringify({ a: 1, b: 2 }), 1);
print(res);
print("Published:", res ? "yes" : "no");
},
true
);
print("Flash button is configured on GPIO pin", pin);
print("Press the flash button now!");
MQTT.sub(
"mOS/topic1",
function (conn, topic, msg) {
print("Topic:", topic, "message:", msg);
},
null
);
I am pretty sure I have fullfilled all these requirments
A valid connection
A valid and active certificate
A policy that allows the desired connection and operation
I have a mos-default policy with the following
{
"Statement": [
{
"Effect": "Allow",
"Action": "iot:*",
"Resource": "*"
}
],
"Version": "2012-10-17"
}
There is a mos.yml file of the following. And I do have aws.crt.pem and aws.key.pem files in the app.
author: mongoose-os
description: A JS-enabled demo Mongoose OS firmware
# arch: PLATFORM
version: 1.0
manifest_version: 2017-05-18
libs_version: ${mos.version}
modules_version: ${mos.version}
mongoose_os_version: ${mos.version}
config_schema:
- ["mqtt.server", "iot.eclipse.org:1883"]
- ["i2c.enable", true]
tags:
- js
filesystem:
- fs
libs:
- origin: https://github.com/mongoose-os-libs/boards
- origin: https://github.com/mongoose-os-libs/js-demo-bundle
conds:
# It's not that we can't work with multicore
# but we cannot afford it because of space (32K).
- when: mos.platform == "esp32"
apply:
build_vars:
ESP_IDF_SDKCONFIG_OPTS: >
${build_vars.ESP_IDF_SDKCONFIG_OPTS}
CONFIG_FREERTOS_UNICORE=y
let connected = MQTT.isConnected();
print(connected);
returns false, I am not sure how to debug this