Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to AWS in the loop. #18

Open
WizKid32 opened this issue Jul 18, 2019 · 0 comments
Open

Cannot connect to AWS in the loop. #18

WizKid32 opened this issue Jul 18, 2019 · 0 comments

Comments

@WizKid32
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant