# Connecting wp77 to AWS IoT

**URL:** <https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344>\
**Category:** Uncategorized\
**Created:** [August 10, 2020, 7:01am UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344 "2020-08-10T07:01:44Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [August 10, 2020, 7:01am UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/1 "2020-08-10T07:01:44Z")

</div>

I am trying to connect a wp77 to AWS IoT and I was wondering if there is any available app which support TLS authentication for mqtt protocol.  
Cheers

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 10, 2020, 8:44am UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/2 "2020-08-10T08:44:13Z")

</div>

Here says you can use python:

> **[How to Implement MQTT with TLS Client Authentication on Port 443 from Client...](https://aws.amazon.com/tw/blogs/iot/how-to-implement-mqtt-with-tls-client-authentication-on-port-443-from-client-devices-python/)**
>
> Application Layer Protocol Negotiation (ALPN) is an extension to TLS that enables clients connecting to a TLS server to pass an extra parameter, known as a ProtocolNameList. The ProtocolNameList is a preference-ordered list of the application...

To use python phao mqtt, you can see here:

> [@FX30s LTE \[WP7702\] Addition of python recipes](https://forum.legato.io/t/fx30s-lte-wp7702-addition-of-python-recipes/4896):
>
> Hi, I am new to this source compilation. Below are some of the queries related to the same. For one of our requirement we require python paho-mqtt 1.3 version to be added to the image. From where to download the respective recipe and it’s dependency recipes if any. Adding the same in the base code. Steps to be followed for the base code compilation.

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [August 14, 2020, 11:19pm UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/3 "2020-08-14T23:19:46Z")

</div>

Same here, would prefer not recompile the image to include python libraries, maybe using cpp is native for this target and so I can avoid recompiling the image??

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 15, 2020, 1:51am UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/4 "2020-08-15T01:51:12Z")

</div>

You might need to give a try to cross compile the aws sdk in c language.

[https://github.com/aws/aws-iot-device-sdk-embedded-C/issues/435](https://github.com/aws/aws-iot-device-sdk-embedded-C/issues/435)

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [August 18, 2020, 11:47pm UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/5 "2020-08-18T23:47:21Z")

</div>

yes, it worked. Cheers

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 19, 2020, 2:12am UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/6 "2020-08-19T02:12:26Z")

</div>

how do you cross compile the AWS iot embedded C SDK?  
Can you write down some procedure?

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [August 21, 2020, 12:54am UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/7 "2020-08-21T00:54:22Z")

</div>

I just used the mkapp, didn`t need to cross compile as this was written in C.  
Not sure I understand your question…

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 21, 2020, 1:00am UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/8 "2020-08-21T01:00:04Z")

</div>

Which legato application are you using for compilation?

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [August 21, 2020, 1:07am UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/9 "2020-08-21T01:07:26Z")

</div>

mmmhhh, good question…  
I believe I am using the latest legato application 20.04 but how do I check it?  
I can see the leaf version is 2.3.1

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 21, 2020, 1:17am UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/10 "2020-08-21T01:17:39Z")

</div>

as you say “it works”, I thought you already compiled something…

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [August 21, 2020, 1:32am UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/11 "2020-08-21T01:32:12Z")

</div>

yes, I did get the AWS SDK for embedded C, did create the app, component and used pretty much the source code from them with just some small adjustments.  
Only problem I had was with the port, which I had to change from 8883 to 443 for the TLS to work properly.  
So, once the cm data is connected, I can connect subscribe and publish to the AWS backend.  
Haven`t done anything fancy really, just implemented the SDK as it came from AWS website, then compiled for the wp77xx target.

---

<div class="post-metadata">

**Author:** ![johannes.lehtonen](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@johannes.lehtonen](https://forum.legato.io/u/johannes.lehtonen)\
**Post date:** [February 13, 2021, 10:09pm UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/12 "2021-02-13T22:09:31Z")

</div>

Hi, I’m facing the same task of adding the SDK to WP7702. Could you elaborate on what you mean with “used pretty much the source code from them”? Which files did you copy over and what did you add to the \*def files?

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [February 15, 2021, 9:03am UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/13 "2021-02-15T09:03:04Z")

</div>

this is the cdef I have used:  
sources:  
{  
mqttClientAws.c

```
//aws client implementation
$CURDIR/../src/aws_iot_jobs_interface.c
$CURDIR/../src/aws_iot_jobs_json.c
$CURDIR/../src/aws_iot_jobs_topics.c
$CURDIR/../src/aws_iot_jobs_types.c
$CURDIR/../src/aws_iot_json_utils.c
$CURDIR/../src/aws_iot_mqtt_client.c
$CURDIR/../src/aws_iot_mqtt_client_common_internal.c
$CURDIR/../src/aws_iot_mqtt_client_connect.c
$CURDIR/../src/aws_iot_mqtt_client_publish.c
$CURDIR/../src/aws_iot_mqtt_client_subscribe.c
$CURDIR/../src/aws_iot_mqtt_client_unsubscribe.c
$CURDIR/../src/aws_iot_mqtt_client_yield.c
$CURDIR/../src/aws_iot_shadow_actions.c
$CURDIR/../src/aws_iot_shadow.c
$CURDIR/../src/aws_iot_shadow_json.c
$CURDIR/../src/aws_iot_shadow_records.c

//timer library
$CURDIR/../platform/linux/common/timer.c

//jsmn library
$CURDIR/../external_libs/jsmn/jsmn.c

//mbedtls network interface wrapper
$CURDIR/../platform/linux/mbedtls/network_mbedtls_wrapper.c
$CURDIR/../external_libs/mbedTLS/library/aes.c
$CURDIR/../external_libs/mbedTLS/library/aesni.c
$CURDIR/../external_libs/mbedTLS/library/arc4.c
$CURDIR/../external_libs/mbedTLS/library/aria.c
$CURDIR/../external_libs/mbedTLS/library/asn1parse.c
$CURDIR/../external_libs/mbedTLS/library/asn1write.c
$CURDIR/../external_libs/mbedTLS/library/base64.c
$CURDIR/../external_libs/mbedTLS/library/bignum.c
$CURDIR/../external_libs/mbedTLS/library/blowfish.c
$CURDIR/../external_libs/mbedTLS/library/camellia.c
$CURDIR/../external_libs/mbedTLS/library/ccm.c
$CURDIR/../external_libs/mbedTLS/library/certs.c
$CURDIR/../external_libs/mbedTLS/library/chacha20.c
$CURDIR/../external_libs/mbedTLS/library/chachapoly.c
$CURDIR/../external_libs/mbedTLS/library/cipher.c
$CURDIR/../external_libs/mbedTLS/library/cipher_wrap.c
$CURDIR/../external_libs/mbedTLS/library/cmac.c
$CURDIR/../external_libs/mbedTLS/library/ctr_drbg.c
$CURDIR/../external_libs/mbedTLS/library/debug.c
$CURDIR/../external_libs/mbedTLS/library/des.c
$CURDIR/../external_libs/mbedTLS/library/dhm.c
$CURDIR/../external_libs/mbedTLS/library/ecdh.c
$CURDIR/../external_libs/mbedTLS/library/ecdsa.c
$CURDIR/../external_libs/mbedTLS/library/ecjpake.c
$CURDIR/../external_libs/mbedTLS/library/ecp.c
$CURDIR/../external_libs/mbedTLS/library/ecp_curves.c
$CURDIR/../external_libs/mbedTLS/library/entropy.c
$CURDIR/../external_libs/mbedTLS/library/entropy_poll.c
$CURDIR/../external_libs/mbedTLS/library/error.c
$CURDIR/../external_libs/mbedTLS/library/gcm.c
$CURDIR/../external_libs/mbedTLS/library/havege.c
$CURDIR/../external_libs/mbedTLS/library/hkdf.c
$CURDIR/../external_libs/mbedTLS/library/hmac_drbg.c
$CURDIR/../external_libs/mbedTLS/library/md2.c
$CURDIR/../external_libs/mbedTLS/library/md4.c
$CURDIR/../external_libs/mbedTLS/library/md5.c
$CURDIR/../external_libs/mbedTLS/library/md.c
$CURDIR/../external_libs/mbedTLS/library/memory_buffer_alloc.c
$CURDIR/../external_libs/mbedTLS/library/net_sockets.c
$CURDIR/../external_libs/mbedTLS/library/nist_kw.c
$CURDIR/../external_libs/mbedTLS/library/oid.c
$CURDIR/../external_libs/mbedTLS/library/padlock.c
$CURDIR/../external_libs/mbedTLS/library/pem.c
$CURDIR/../external_libs/mbedTLS/library/pk.c
$CURDIR/../external_libs/mbedTLS/library/pkcs11.c
$CURDIR/../external_libs/mbedTLS/library/pkcs12.c
$CURDIR/../external_libs/mbedTLS/library/pkcs5.c
$CURDIR/../external_libs/mbedTLS/library/pkparse.c
$CURDIR/../external_libs/mbedTLS/library/pk_wrap.c
$CURDIR/../external_libs/mbedTLS/library/pkwrite.c
$CURDIR/../external_libs/mbedTLS/library/platform.c
$CURDIR/../external_libs/mbedTLS/library/platform_util.c
$CURDIR/../external_libs/mbedTLS/library/poly1305.c
$CURDIR/../external_libs/mbedTLS/library/psa_crypto.c
$CURDIR/../external_libs/mbedTLS/library/psa_crypto_se.c
$CURDIR/../external_libs/mbedTLS/library/psa_crypto_slot_management.c
$CURDIR/../external_libs/mbedTLS/library/psa_crypto_storage.c
$CURDIR/../external_libs/mbedTLS/library/psa_its_file.c
$CURDIR/../external_libs/mbedTLS/library/ripemd160.c
$CURDIR/../external_libs/mbedTLS/library/rsa.c
$CURDIR/../external_libs/mbedTLS/library/rsa_internal.c
$CURDIR/../external_libs/mbedTLS/library/sha1.c
$CURDIR/../external_libs/mbedTLS/library/sha256.c
$CURDIR/../external_libs/mbedTLS/library/sha512.c
$CURDIR/../external_libs/mbedTLS/library/ssl_cache.c
$CURDIR/../external_libs/mbedTLS/library/ssl_ciphersuites.c
$CURDIR/../external_libs/mbedTLS/library/ssl_cli.c
$CURDIR/../external_libs/mbedTLS/library/ssl_cookie.c
$CURDIR/../external_libs/mbedTLS/library/ssl_msg.c
$CURDIR/../external_libs/mbedTLS/library/ssl_srv.c
$CURDIR/../external_libs/mbedTLS/library/ssl_ticket.c
$CURDIR/../external_libs/mbedTLS/library/ssl_tls.c
$CURDIR/../external_libs/mbedTLS/library/threading.c
$CURDIR/../external_libs/mbedTLS/library/timing.c
$CURDIR/../external_libs/mbedTLS/library/version.c
$CURDIR/../external_libs/mbedTLS/library/version_features.c
$CURDIR/../external_libs/mbedTLS/library/x509.c
$CURDIR/../external_libs/mbedTLS/library/x509_create.c
$CURDIR/../external_libs/mbedTLS/library/x509_crl.c
$CURDIR/../external_libs/mbedTLS/library/x509_crt.c
$CURDIR/../external_libs/mbedTLS/library/x509_csr.c
$CURDIR/../external_libs/mbedTLS/library/x509write_crt.c
$CURDIR/../external_libs/mbedTLS/library/x509write_csr.c
$CURDIR/../external_libs/mbedTLS/library/xtea.c

//JSON-C libraries
$CURDIR/../json-c/arraylist.c
$CURDIR/../json-c/json_util.c
$CURDIR/../json-c/json_object.c
$CURDIR/../json-c/libjson.c
$CURDIR/../json-c/random_seed.c
$CURDIR/../json-c/printbuf.c
$CURDIR/../json-c/strerror_override.c
$CURDIR/../json-c/json_tokener.c
$CURDIR/../json-c/linkhash.c

```

}

bundles:  
{  
dir:  
{  
certs /  
}  
}

cflags:  
{  
-I$CURDIR/…/include  
-I$CURDIR/…/platform/linux/common  
-I$CURDIR/…/platform/linux/mbedtls  
-I$CURDIR/…/external\_libs/mbedTLS/include  
-I$CURDIR/…/external\_libs/jsmn  
-I$CURDIR/…/json-c  
}

requires:  
{  
api:  
{  
modemServices/le\_info.api  
modemServices/le\_mdc.api  
//interfaces/le\_data.api  
}  
}

provides:  
{  
api:  
{  
mqttClientAws = $CURDIR/…/…/Interfaces/mqttClientAws.api  
}  
}

The api is actually something I am using internally with other apps, don`t bother about that

---

<div class="post-metadata">

**Author:** ![ClaudioBaldo](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@ClaudioBaldo](https://forum.legato.io/u/ClaudioBaldo)\
**Post date:** [February 15, 2021, 9:03am UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/14 "2021-02-15T09:03:40Z")

</div>

Also, I haven`t got a chance to clean this at all, so there may be source files you don`t need to include.

---

<div class="post-metadata">

**Author:** ![johannes.lehtonen](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@johannes.lehtonen](https://forum.legato.io/u/johannes.lehtonen)\
**Post date:** [February 15, 2021, 10:24am UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/15 "2021-02-15T10:24:42Z")

</div>

Oh nice, thanks for the reply! The files do not correspond to the sdk v3.1.5, are you using an older version? Anyway, I think I can figure it out from there.

Edit: yeah that’s version 2.x.x you’re using. I think I’m gonna try first with the 3.1.5.  
Edit2: oh I was in the main branch, it seems like I should’ve been in one of the tagged branches. 😑

---

<div class="post-metadata">

**Author:** ![johannes.lehtonen](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@johannes.lehtonen](https://forum.legato.io/u/johannes.lehtonen)\
**Post date:** [February 17, 2021, 6:15pm UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/16 "2021-02-17T18:15:59Z")

</div>

So I managed to add the sdk and build it, all seems fine, but I can’t connect to the endpoint. It always fails with MBEDTLS\_ERR\_NET\_UNKNOWN\_HOST when it tries to connect. The error code has the comment “Failed to get an IP address for the given hostname”.

I made a test app on PC and ran the sample apps just fine so all the connection information is correct. I can also ping and telnet the endpoint on PC but only ping it on WP7702. Any attempt to test the connection fails like so:

root@swi-mdm9x28-wp:~# ping [a1o5neajgmytt9-ats.iot.eu-central-1.amazonaws.com](http://a1o5neajgmytt9-ats.iot.eu-central-1.amazonaws.com)  
PING [a1o5neajgmytt9-ats.iot.eu-central-1.amazonaws.com](http://a1o5neajgmytt9-ats.iot.eu-central-1.amazonaws.com) (52.59.59.88): 56 data bytes  
64 bytes from 52.59.59.88: seq=0 ttl=239 time=58.062 ms  
64 bytes from 52.59.59.88: seq=1 ttl=239 time=136.530 ms

root@swi-mdm9x28-wp:~# telnet [a1o5neajgmytt9-ats.iot.eu-central-1.amazonaws.com](http://a1o5neajgmytt9-ats.iot.eu-central-1.amazonaws.com) 8883  
Connection closed by foreign host  
root@swi-mdm9x28-wp:~# telnet [a1o5neajgmytt9-ats.iot.eu-central-1.amazonaws.com](http://a1o5neajgmytt9-ats.iot.eu-central-1.amazonaws.com) 443  
Connection closed by foreign host

---

<div class="post-metadata">

**Author:** ![dan](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@dan](https://forum.legato.io/u/dan)\
**Post date:** [March 15, 2024, 9:35pm UTC](https://forum.legato.io/t/connecting-wp77-to-aws-iot/5344/17 "2024-03-15T21:35:57Z")

</div>

Hi I know this was along time ago and most likely you won’t respond but. I’m trying to get this working when ever I try and find I seem to just keep getting an everlasting failure of can’t find file x cant file y. I think it’s due to a miss match of aws sdk version, mbedtls version and what you originally had in you .cdef sources. Has anyone made any more progress with this and maybe can share their full setup?
