NuMaker connection with AWS IoT thru MQTT/HTTPS

Dependencies:   MQTT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MyTLSSocket.h Source File

MyTLSSocket.h

00001 #ifndef _MY_TLS_SOCKET_H_
00002 #define _MY_TLS_SOCKET_H_
00003 
00004 #include "mbed.h"
00005 #include "TLSSocket.h"
00006 #include "mbedtls_utils.h"
00007 
00008 #if MBED_CONF_MY_TLSSOCKET_TLS_DEBUG_LEVEL > 0
00009 #include "mbedtls/debug.h"
00010 #endif
00011 
00012 /* MyTLSSocket = TLSSocket + MQTT lib required timed read/write + debug thru console */
00013 class MyTLSSocket : public TLSSocket
00014 {
00015 public:
00016     MyTLSSocket();
00017     ~MyTLSSocket();
00018 
00019     /**
00020      * Timed recv for MQTT lib
00021      */
00022     int read(unsigned char* buffer, int len, int timeout);
00023 
00024     /**
00025      * Timed send for MQTT lib
00026      */
00027     int write(unsigned char* buffer, int len, int timeout);
00028     
00029 protected:
00030 #if MBED_CONF_MY_TLSSOCKET_TLS_DEBUG_LEVEL > 0
00031     /**
00032      * Debug callback for Mbed TLS
00033      * Just prints on the USB serial port
00034      */
00035     static void my_debug(void *ctx, int level, const char *file, int line,
00036                          const char *str);
00037 
00038     /**
00039      * Certificate verification callback for Mbed TLS
00040      * Here we only use it to display information on each cert in the chain
00041      */
00042     static int my_verify(void *data, mbedtls_x509_crt *crt, int depth, uint32_t *flags);
00043 #endif
00044 };
00045 
00046 #endif // _MY_TLS_SOCKET_H_