Giter Site home page Giter Site logo

hornbill-examples's Introduction

Hornbill-Examples

Kindly check our latest AWS IoT libraries, with additional features such as:

  1. Device provisioning.
  2. Shadow updates.
  3. Jobs management.
  4. Over-the-Air (OTA) updates.
  5. Mobile app for aws

Additionally, you can explore libraries tailored for various platforms such as Azure, Thingsboard, and Kaa IoT, supporting both WiFi and cellular-based applications.

hornbill-examples's People

Contributors

resceince avatar saheblalbagwan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hornbill-examples's Issues

Remove variables related to certs and keys

I was brought here via https://exploreembedded.com/wiki/AWS_IOT_with_Arduino_ESP32

Could not compile till aws_root_ca_pem, certificate_pem_crt, and private_pem_key was commented out:
https://github.com/ExploreEmbedded/Hornbill-Examples/blob/master/arduino-esp32/AWS_IOT/src/aws_iot_certficates.c

Receive error (based on what you comment out):
libraries\AWS_IOT\aws_iot_certficates.c.o:(.rodata.aws_root_ca_pem+0x0): multiple definition of aws_root_ca_pem'`

libraries\AWS_IOT\aws_iot_certficates.c.o:(.rodata.certificate_pem_crt+0x0): multiple definition of certificate_pem_crt'`

libraries\AWS_IOT\aws_iot_certficates.c.o:(.rodata.private_pem_key+0x0): multiple definition of private_pem_key'`

Error parsing root-ca

I've substituded my certs in the .c file per the instructions (including \n\ at end of lines) but I'm getting a runtime error from the esp32 saying that it had an error parsing the root-ca.

I have verified that the cert is correct, so that's not it.

Here's the error:
E (14239) aws_iot: failed! mbedtls_x509_crt_parse returned -0x2180 while parsing root cert

Thanks!

Not receiving MQTT messages when subscribe is done using a non const char

My Code:

`
if (device.connect(HOST_ADDRESS, const_cast<char*>(client_id.c_str())) == 0) {
Serial.println("Connected To AWS");
delay(1000);

                char getAcceptedTopic[60];
                strcpy(getAcceptedTopic, "Lamps/"); //these ones need to be strcpy to get it started
                strcat(getAcceptedTopic, const_cast<char*>(myLampCred.username.c_str()));
                strcat(getAcceptedTopic, "/rga");

                Serial.print("\ngetAcceptedTopic: ");
                Serial.print(getAcceptedTopic);


                char republishedShadowTopic[60];
                strcpy(republishedShadowTopic, "Lamp/");
                strcat(republishedShadowTopic, const_cast<char*>(myLampCred.username.c_str()));
                strcat(republishedShadowTopic, "/rs");


                
                if (0==device.subscribe(getAcceptedTopic, mySubCallBackHandler)) {
                //if (0==device.subscribe("Lamps/SamHang/rs", mySubCallBackHandler)) { //try just doing it with the string? 
                Serial.print("Subscribe Successful");
                } else {
                Serial.println("Subscribe Failed, Check The Thing Name and Certificates");
                while(1);
                } 
                
                if (0==device.subscribe("testchannel", mySubCallBackHandler)) {
                Serial.println("Subscribe Successful");
                } else {
                Serial.println("Subscribe Failed, Check The Thing Name and Certificates");
                while(1);
                } 
                //will need to add in effects/channel topic at some point, but since none of the effects code is set up yet anyways, theres no point in adding a topic now.
                yield();
                Serial.println(republishedShadowTopic);
                if (0 == device.subscribe(republishedShadowTopic, mySubCallBackHandler)){
                    Serial.println("Subscribe Successful");
                } else {
                    Serial.println("Subscribe Failed, Check The THing Name and Certificates");
                    while(1);
                }

                delay(500);
                //send get request
                gettingShadow = true;
                std::string shadowGetTopic = "$aws/things/" + myLampCred.username + "Lamp/shadow/get";
                publishFunc(shadowGetTopic.c_str(), "");
            } else {
                //could add error for this but unless the host address changes and EVERYTHING breaks or wifi isn't connected, then there shouldn't be a problem
                Serial.println("AWS connection failed, check the HOST address");
                while(1);
            }`

I have 3 topics that I subscribe to and two of them are based off of the username, which changes
based on device/user. My testchannel and getAcceptedTopic topics receive messages just fine but the republishedShadowTopic does not receive any messages. If i change it from the republishedShadowTopic variable to the string literal "Lamp/user/rs" in the subscribe method, then it works fine. I'm using the AWS IoT console and I can see that all of the messages and sent but the device is just not receiving them. I'm really not sure what this is because it seems like it should work based on the getAcceptedTopic topic working and being declared the same way? I can send the same messages through and have the same results on each topic respectively, so I know that it doesn't have to do with the message contents. Thanks for any help :)

putting certificates in seperate file in arduino IDE

Hi so I want to use this library but I want to store cert in a seperate AWS_cert.h file that I can add in code in Arduino IDE. and so I don't need to go to library folder and edit it every time I want to add another cert.

Can you suggest some way? though I tried it to comment aws_iot_cert.c in AWS_IOT.cpp and add aws_cert.h with code of aws_iot_cert.c but during compilation I get error

var/folders/w2/jb9h2v3j5s5bs70q009xq2x00000gn/T/arduino_build_683901/libraries/AWS_IOT/AWS_IOT.cpp.o:(.literal._ZN7AWS_IOT7connectEPcS0_+0x10): undefined reference to `aws_root_ca_pem'
/var/folders/w2/jb9h2v3j5s5bs70q009xq2x00000gn/T/arduino_build_683901/libraries/AWS_IOT/AWS_IOT.cpp.o:(.literal._ZN7AWS_IOT7connectEPcS0_+0x14): undefined reference to `certificate_pem_crt'
Multiple libraries were found for "WiFi.h"
/var/folders/w2/jb9h2v3j5s5bs70q009xq2x00000gn/T/arduino_build_683901/libraries/AWS_IOT/AWS_IOT.cpp.o:(.literal._ZN7AWS_IOT7connectEPcS0_+0x18): undefined reference to `private_pem_key'
 Used: /Users/shirishbytelens/Documents/Arduino/hardware/espressif/esp32/libraries/WiFi
collect2: error: ld returned 1 exit status
 Not used: /private/var/folders/w2/jb9h2v3j5s5bs70q009xq2x00000gn/T/AppTranslocation/52665A05-AAB2-4BD4-96BE-401CDCEB2D12/d/Arduino 2.app/Contents/Java/libraries/WiFi
Using library AWS_IOT at version 1.0 in folder: /Users/shirishbytelens/Documents/Arduino/libraries/AWS_IOT 
Using library WiFi at version 1.0 in folder: /Users/shirishbytelens/Documents/Arduino/hardware/espressif/esp32/libraries/WiFi 
exit status 1
Error compiling for board ESP32 Dev Module.

so its not linking to the library.

esp8266

Can I modify the code and use it with an esp8266-01?

Doubts with the TOPIC_NAME paramater

In the code the TOPIC NAME parameter is slightly confusing

for updating a shadow the topic format is usually:
$aws/things/DemoThing/shadow/update

However to get the update accepted the topic is:
$aws/things/DemoThing/shadow/update/accepted

so now when i want to subscribe to the topic update/accepted should my TOPIC_NAME parameter be:

TOPIC_NAME=$aws/things/DemoThing/shadow/update/accepted ??

when i try the above, i am not able to subscribe to the messages correctly. Please correct me if i am wrong

Thanks !!

Publish failed! Error NETWORK_SSL_WRITE_ERROR = -7

Hi,

I'm using BLE and WIFI simultaneously, the device connects to AWS and successfully posts 2 MQTT messages but when sending the 3rd one it stops working. The error I get is E (122946) aws_iot: failed! mbedtls_ssl_write returned -0x5.
Log trace: Publish failed! Error NETWORK_SSL_WRITE_ERROR = -7
Free memory: 28348

the implemented logic is:

  1. Scan BLE device
  2. Connect to WiFi
  3. Connect to AWS
  4. Find BLE Device
  5. Publish data

FUNC_ENTRY: aws_iot_mqtt_publish L#272
DEBUG: aws_iot_mqtt_publish L#273 /voronich/0/reports
FUNC_ENTRY: aws_iot_mqtt_is_client_connected L#235
FUNC_EXIT: aws_iot_mqtt_is_client_connected L#266 Return Code : 1
FUNC_ENTRY: aws_iot_mqtt_get_client_state L#55
FUNC_EXIT: aws_iot_mqtt_get_client_state L#60 Return Code : 3
FUNC_ENTRY: aws_iot_mqtt_set_client_state L#102
FUNC_ENTRY: aws_iot_mqtt_client_lock_mutex L#65
FUNC_EXIT: aws_iot_mqtt_client_lock_mutex L#83 Return Code : 0
FUNC_ENTRY: aws_iot_mqtt_get_client_state L#55
FUNC_EXIT: aws_iot_mqtt_get_client_state L#60 Return Code : 3
FUNC_EXIT: aws_iot_mqtt_set_client_state L#127 Return Code : 0
FUNC_ENTRY: _aws_iot_mqtt_internal_publish L#205
FUNC_ENTRY: _aws_iot_mqtt_internal_serialize_publish L#97
FUNC_ENTRY: aws_iot_mqtt_internal_init_header L#189
FUNC_EXIT: aws_iot_mqtt_internal_init_header L#264 Return Code : 0
FUNC_ENTRY: aws_iot_mqtt_internal_write_len_to_buffer L#60
FUNC_EXIT: aws_iot_mqtt_internal_write_len_to_buffer L#71 Return Code : 2
FUNC_EXIT: _aws_iot_mqtt_internal_serialize_publish L#132 Return Code : 0
Call _aws_iot_mqtt_internal_serialize_publish : 0
FUNC_ENTRY: aws_iot_mqtt_internal_send_packet L#272
FUNC_ENTRY: aws_iot_mqtt_client_lock_mutex L#65
FUNC_EXIT: aws_iot_mqtt_client_lock_mutex L#83 Return Code : 0
ENABLE_THREAD_SUPPORT call aws_iot_mqtt_client_lock_mutex : 0
E (1503909) aws_iot: failed! mbedtls_ssl_write returned -0x50
Network stack write result: -7
ENABLE_THREAD_SUPPORT call aws_iot_mqtt_client_unlock_mutex : 0
FUNC_EXIT: aws_iot_mqtt_internal_send_packet L#319 Return Code : -1
Call aws_iot_mqtt_internal_send_packet : -1
FUNC_EXIT: _aws_iot_mqtt_internal_publish L#228 Return Code : -1
Call _aws_iot_mqtt_internal_publish : -1
FUNC_ENTRY: aws_iot_mqtt_set_client_state L#102
FUNC_ENTRY: aws_iot_mqtt_client_lock_mutex L#65
FUNC_EXIT: aws_iot_mqtt_client_lock_mutex L#83 Return Code : 0
FUNC_ENTRY: aws_iot_mqtt_get_client_state L#55
FUNC_EXIT: aws_iot_mqtt_get_client_state L#60 Return Code : 5
FUNC_EXIT: aws_iot_mqtt_set_client_state L#127 Return Code : 0
Call aws_iot_mqtt_set_client_state : 0
FUNC_EXIT: aws_iot_mqtt_publish L#301 Return Code : -1

example industrial logger gives error with delay.h

got the AWS IOT working, but MAX6675 library doesn't compile. delay functions don't work. downloaded the latest adafruit MAX6675 lib. 'util/delay.h' no such file or directory. Where can i find the delay library for ESP32?

thank you

Stops Publishing

Not sure how else to title it.

After running for about 2 and a half days, updating every 30 minutes, it suddenly will not publish anymore. I am able to connect, and I do not get a failed publish, however, the shadow is never updated.

Looking at AWS CLoudwatch Logs set to debug, there are no logs indicating that a publish was even attempted.

Let me know if there is any specific information that is needed and I'll try and get it as soon as possible.

Here is the output of the ESP32:

starting aws iot application
Attempting to connect to Wifi network: Attempting to connect to Wifi network: Connected to Wifi!
IP address: 192.168.86.44
Connected to AWS, bru
Sending data...
{"state":{"reported":{"co2":" 1647 ", "temperature":" 25.340000 ", "humidity":" 37.827148 ", "pressure":" 101369.523438 ","battery":" 3960 ",  "name":" co2-sensor ", "timestamp":" 1610827693 ", "ttl": 1611259693 }}}
Going to sleep now

Here is the relevant code for publishing:

// put your main code here, to run repeatedly:
  Serial.println("Sending data...");
  // Turning on the LED
  digitalWrite(18, HIGH);

  // Getting values
  float temperature = bme.readTemperature();
  float humidity = bme.readHumidity();
  float pressure = bme.readPressure();
  int co2 = getco2();
  uint16_t battery = adp.batteryVoltage();

  // We want to make sure we're getting a CO2 Value
  if (co2 == 0) {
    adp.enableLDO(2,0);
    delay(3000);
    
    return;
  }

  // Making sure we got values from the BME sensor as well
  // We won't update the IoT shadow without these values
  if (isnan(humidity) || isnan(temperature)) {
    Serial.println("Failed to read from BME sensor!");
    char rule_payload[512];
    time_t now = time(nullptr);
    time_t delete_time = now + (5 * 24 * 60 * 60);
    sprintf(rule_payload, "{\"state\":{\"reported\":{\"co2\":\" %d \",\"battery\":\" %d \",  \"name\":\" co2-sensor \", \"timestamp\":\" %d \", \"ttl\": %d }}}",co2,temperature,humidity,pressure,battery,now,delete_time);
    Serial.println(rule_payload);
    while (hornbill.publish(TOPIC_NAME,rule_payload) != 0) {
      counter++;
      if (counter >= 10) {
        Serial.println("Message was not published");
        counter = 0;
        break;
      }
      delay(1000);
    }
    counter = 0;
  } else {
    // Generating the JSON Payload
    char rule_payload[512];
    time_t now = time(nullptr);
    time_t delete_time = now + (5 * 24 * 60 * 60);
    sprintf(rule_payload, "{\"state\":{\"reported\":{\"co2\":\" %d \", \"temperature\":\" %f \", \"humidity\":\" %f \", \"pressure\":\" %f \",\"battery\":\" %d \",  \"name\":\" co2-sensor \", \"timestamp\":\" %d \", \"ttl\": %d }}}",co2,temperature,humidity,pressure,battery,now,delete_time);
    Serial.println(rule_payload);
    while (hornbill.publish(TOPIC_NAME,rule_payload) != 0) {
      counter++;
      if (counter >= 10) {
        Serial.println("Message was not published");
        counter = 0;
        break;
      }
      delay(1000);
    }
    counter = 0;
  }

AWS Logs showing it connected:

2021-01-16 20:24:58.055 TRACEID:a45b3777-4cc7-b47e-45f3-93cd034b3f57 PRINCIPALID:AIDAQDMAHMFBPLGXBH6BQ [INFO]  EVENT:PublishOut TOPICNAME:$aws/events/presence/connected/co2-sensor MESSAGE:PublishOut Status: SUCCESS

AWS Logs showing it disconnected:

2021-01-16 20:26:07.459 TRACEID:9b4b1c6d-1d62-ef2d-17d6-ec835455c1bb PRINCIPALID:AIDAQDMAHMFBPLGXBH6BQ [INFO]  EVENT:MQTT Client Disconnect MESSAGE:Disconnect Status: SUCCESS

The message I would expect to see, according to AWS Documentation, would be something like this:

{
    "timestamp": "2017-08-07 18:43:59.436",
    "logLevel": "INFO",
    "traceId": "d0074ba8-0c4b-a400-69df-76326d414c28",
    "accountId": "123456789012",
    "status": "Success",
    "eventType": "UpdateThingShadow",
    "protocol": "MQTT",
    "deviceShadowName": "Jack",
    "topicName": "$aws/things/Jack/shadow/update"
}

Any help or information is much appreciated...

Thanks,
RM

running out of memory when doing the TLS handshake

I am getting the mbed_tls error when trying to connect to AWS.
MBEDTLS_ERR_SSL_ALLOC_FAILED -0x7F00

I know it is a memory issue. I have BLE and WiFi enabled, of course, but when i get to the AWS portion, it doesn't have enough memory to allocate for the TLS Handshake.
Has anyone had success with this?

Cannot connect to AWS in the loop.

Hi,

I am currently involved with a project in which we use an ESP32 device to service a mesh of BLE devices, and I have discovered a bug I don't know how to fix. The bug in question involves the central node device. This device starts a BLE Client and services the mesh. Once collected in JSON format, the data is then to be sent over to AWS.

This is where my issue starts. I cannot connect the MQTT bridge to AWS in the loop. When I try I get the following message: E (56089) aws_iot: failed! mbedtls_ssl_handshake returned -0x4d80
E (56093) AWS_IOT: Error(-4) connecting to a3twuhzs2qbepq-ats.iot.us-east.2.amazonaws.com:8883,
Trying to reconnect
E (57385) aws_iot: failed! mbedtls_ssl_handshake returned -0x10
E (57388) AWS_IOT: Error(-4) connecting to a3twuhzs2qbepq-ats.iot.us-east-2.amazonaws.com:8883,
Trying to reconnect

Please note that the BLE service has been switched off after the mesh has been serviced. This is required else the ESP32 core crashes. Also, note that I have had to repartition the ESP32 device due to the size of the program. I am currently using the Huge_App.csv partition scheme.

Also, note that I did copy and run the same code in the setup to send a test package and all goes well. I also tested the repartition settings by using all available partition schemes โ€” no change in result.

Here is the code I used to test with:

void setup() {
  Serial.begin(115200);

  // if(!connectWiFi()) reconnectWiFi();
  // connectAWS(AWS_HOST_GATEWAY_ENDPOINT, POLICY_ID, aws_root_ca_pem, certificate_pem_crt, private_pem_key);
  // delay(1000);
  // subscribeToTopic();
  // delay(1000);
  // strcpy(msgAWS, "VSC says hello.");
  // publishToTopic();
  // delay(1000);
  // disconnectAWS(); 

  createBLEClient();
  scanBLEDevices();
}

void loop() {
  connectToBLEServer();
    if(flagSendBLEData) {
        flagSendBLEData = false;
        if(!connectWiFi()) reconnectWiFi();
        Serial.print("Gateway name: ");
        Serial.println(AWS_HOST_GATEWAY_ENDPOINT);
        Serial.print("Policy name: ");
        Serial.println(POLICY_ID);
        Serial.print("Root: ");
        Serial.println(aws_root_ca_pem);
        Serial.print("CA: ");
        Serial.println(certificate_pem_crt);
        Serial.print("Key");
        Serial.println(private_pem_key);
        connectAWS(AWS_HOST_GATEWAY_ENDPOINT, POLICY_ID, aws_root_ca_pem, certificate_pem_crt, private_pem_key);
        delay(1000);
        subscribeToTopic();
        delay(1000);
        strcpy(msgAWS, "VSC says hello.");
        publishToTopic();
        delay(1000);
        disconnectAWS(); 
    }
}

Please let me know if anyone manages to fix this bug. Thanks.

Publishing message without internet access

My ESP32 says it was able to post 2/3 messages 1/2 seconds after disconnecting my local network from internet.

This is my code:

void loop(){
...
    String json = "{\"id\":"+id+",\"code\":"+str+"}";
    publishAWS(json);
...
}

void publishAWS(String str) {
    Serial.println("Publishing message to AWS...");

    char arr[512];
    str.toCharArray(arr, 512);

    if(hornbill.publish(TOPIC_NAME, arr) == 0){
        Serial.print("Publish Message:");
        Serial.println(arr);
    }else{
        Serial.println("Publish failed");
        runBuzzer(freq_failed);
    }
}

Any thoughts?

Edit: multiple publishers with same id.

Feature of Hornbill

I want to know what is the difference between esp-jumpstart cloud and ota firmware upgrade and Hornbill AWS IOT library

AWS_IOT: Error(-28)

I'm trying to connect to MQTT using ESP32 but I get this error over and over.

Attempting to connect to SSID: //MySSID//
Connected to wifi
E (67286) AWS_IOT: Error(-28) connecting to <xxxxxxxxxxxxx>-ats.iot.eu-central-1.amazonaws.com:8883, 
Trying to reconnect

Send SIM808 GPS data to the AWS IoT

Hello,
I have successfully posted my sample static data on AWS using Hornbill library.

Now I have used SIM808 GPS, GSM/GPRS Module. It works using AT Commands. I got GPS data from SIM808 module.
I want to post this GPS data to AWS using SIM808 AT commands.
So, I had created HTTP/MQTT connection.

Now I have a hostname, Port: 8883, certificates of my AWS console.
how can I attach certificates using AT commands?

One more question,
If I used MQTT Lens or MQTT.fx or any other MQTT App, how to Attach Certificates in particular app?

Can you please suggest me using an example!!
Thanks!!

large payloads do not get returned

I can subscribe to a topic and get a return when the payload is small, but if it goes above around 470 characters, the subscription stops receiving. Must be a buffer size somewhere, but I'm struggling to find it.

AWS OTA (Over The Air) Update

I'd like to know if you guys are planning to put in your Arduino AWS IoT Library (by the way, it is awesome), the functionality for OTA (Over The Air) Update, to use it using the Arduino IDE and AWS IoT OTA. Thanks in advance for any help in this.

sending large payload truncates the string - TX buffer size?

Trying to send a payload larger than 512 bytes, but the last characters are missing.
I have changed the butter size in aws_iot_config.h
#define AWS_IOT_MQTT_TX_BUF_LEN 512
but it does not appear to change the output.
I thought it might be in AWS_IOT.cpp
char cPayload[512];
...but sadly ...no dice

Wrting a Book using hornbill

I am writing a book about ALEXA + LAMBDA + AWS IOT + ESP32 to command peripheral houses.

Will hornbill have updates on this github or stoped the manutenance ?

Thank you!

Publish failed!

hornbill.publish(TOPIC_NAME,payload) fails to return zero sometimes. In my case it fails once every 3 times.
publish_failed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.