Connecting wp77 to AWS IoT

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

Here says you can use python:

To use python phao mqtt, you can see here:

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??

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

yes, it worked. Cheers

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

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

Which legato application are you using for compilation?

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

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

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.

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?

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

Also, I havent got a chance to clean this at all, so there may be source files you dont need to include.

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. :expressionless:

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
PING 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 8883
Connection closed by foreign host
root@swi-mdm9x28-wp:~# telnet a1o5neajgmytt9-ats.iot.eu-central-1.amazonaws.com 443
Connection closed by foreign host