the push is modified as follows:

1. delete some junk files.
2. mqttclient added comments and updated to v1.0.2.
3. update README.md.
4. update the author's own server certificate.
5. minor changes to salof.
This commit is contained in:
jiejieTop
2020-03-21 21:47:08 +08:00
parent c0cb4460b7
commit 476e0dec02
43 changed files with 1100 additions and 15612 deletions

View File

@@ -2,7 +2,7 @@
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @Date: 2019-12-14 22:02:07
* @LastEditTime : 2019-12-20 20:43:38
* @LastEditTime: 2020-02-19 23:53:50
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
*/
#include "tos_k.h"

View File

@@ -2,7 +2,7 @@
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @Date: 2019-12-14 22:06:35
* @LastEditTime : 2019-12-20 20:57:32
* @LastEditTime: 2020-02-19 23:54:02
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
*/
#ifndef _PLATFORM_MEMORY_H_

View File

@@ -92,7 +92,7 @@ int platform_net_socket_write_timeout(int fd, unsigned char *buf, int len, int t
tv.tv_usec = 100;
}
setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv,sizeof(struct timeval));
platform_net_socket_setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv,sizeof(struct timeval));
return write(fd, buf, len);
}

View File

@@ -2,21 +2,21 @@
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @Date: 2019-12-15 13:39:00
* @LastEditTime : 2020-01-12 00:22:22
* @LastEditTime: 2020-02-19 01:02:51
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
*/
#ifndef _PLATFORM_NET_SOCKET_H_
#define _PLATFORM_NET_SOCKET_H_
#include "network.h"
#include "error.h"
#include "lwip/opt.h"
#include "lwip/sys.h"
#include "lwip/api.h"
#include <lwip/sockets.h>
#include "lwip/netdb.h"
#include "network.h"
#include "error.h"
#define PLATFORM_NET_PROTO_TCP 0 /**< The TCP transport protocol */
#define PLATFORM_NET_PROTO_UDP 1 /**< The UDP transport protocol */

View File

@@ -2,7 +2,7 @@
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @Date: 2020-01-11 19:45:35
* @LastEditTime : 2020-01-16 00:17:56
* @LastEditTime: 2020-03-05 23:52:30
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
*/
#include "platform_nettype_tls.h"
@@ -11,7 +11,7 @@
#include "platform_timer.h"
#include "random.h"
#if MQTT_NETWORK_TYPE_TLS
#ifdef MQTT_NETWORK_TYPE_TLS
#include "mbedtls/platform.h"
#include "mbedtls/ssl.h"
@@ -20,6 +20,8 @@
#include "mbedtls/ctr_drbg.h"
#include "mbedtls/error.h"
#include "mbedtls/debug.h"
#include "mbedtls\x509_crt.h"
#include "mbedtls\pk.h"
#if !defined(MBEDTLS_FS_IO)
static const int ciphersuites[] = { MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA, MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA, 0 };
@@ -28,7 +30,8 @@ static const int ciphersuites[] = { MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA, MBEDTL
#if defined(MBEDTLS_X509_CRT_PARSE_C)
static int server_certificate_verify(void *hostname, mbedtls_x509_crt *crt, int depth, uint32_t *flags)
{
LOG_I("%s:%d %s()... server_certificate_verify failed returned 0x%04x\n", __FILE__, __LINE__, __FUNCTION__, *flags);
if (0 != *flags)
LOG_E("%s:%d %s()... server_certificate_verify failed returned 0x%04x\n", __FILE__, __LINE__, __FUNCTION__, *flags);
return *flags;
}
#endif
@@ -110,12 +113,12 @@ static int platform_nettype_tls_init(network_t* n, nettype_tls_params_t* nettype
if (n->network_params.network_ssl_params.cert_file != NULL && n->network_params.network_ssl_params.key_file != NULL) {
if ((rc = mbedtls_x509_crt_parse_file(&(nettype_tls_params->client_cert), n->network_params.network_ssl_params.cert_file)) != 0) {
LOG_E("%s:%d %s()... load client cert file failed returned 0x%04x", __FILE__, __LINE__, __FUNCTION__, (rc < 0 )? -rc : rc);
return PLATFORM_ERR_SSL_CERT;
return MQTT_SSL_CERT_ERROR;
}
if ((rc = mbedtls_pk_parse_keyfile(&(nettype_tls_params->private_key), n->network_params.network_ssl_params.key_file, "")) != 0) {
LOG_E("%s:%d %s()... load client key file failed returned 0x%04x", __FILE__, __LINE__, __FUNCTION__, (rc < 0 )? -rc : rc);
return PLATFORM_ERR_SSL_CERT;
return MQTT_SSL_CERT_ERROR;
}
} else {
LOG_I("%s:%d %s()... cert_file/key_file is empty! | cert_file = %s | key_file = %s", __FILE__, __LINE__, __FUNCTION__,
@@ -129,12 +132,13 @@ static int platform_nettype_tls_init(network_t* n, nettype_tls_params_t* nettype
n->network_params.network_ssl_params.psk_length, (const unsigned char *) psk_id, strlen( psk_id ));
mbedtls_ssl_conf_ciphersuites(&(nettype_tls_params->ssl_conf), ciphersuites);
if (0 != rc) {
LOG_E("%s:%d %s()... mbedtls_ssl_conf_psk fail: 0x%04x", __FILE__, __LINE__, __FUNCTION__, (rc < 0 )? -rc : rc);
return rc;
}
}
if (0 != rc) {
LOG_E("%s:%d %s()... mbedtls_ssl_conf_psk fail: 0x%04x", __FILE__, __LINE__, __FUNCTION__, (rc < 0 )? -rc : rc);
return rc;
}
#endif
#endif
@@ -277,7 +281,7 @@ int platform_nettype_tls_read(network_t *n, unsigned char *buf, int len, int tim
if (rc > 0) {
read_len += rc;
} else if ((rc == 0) || ((rc != MBEDTLS_ERR_SSL_WANT_WRITE) && (rc != MBEDTLS_ERR_SSL_WANT_READ) && (rc != MBEDTLS_ERR_SSL_TIMEOUT))) {
LOG_E("%s:%d %s()... mbedtls_ssl_read failed: 0x%04x", __FILE__, __LINE__, __FUNCTION__, (rc < 0 )? -rc : rc);
// LOG_E("%s:%d %s()... mbedtls_ssl_read failed: 0x%04x", __FILE__, __LINE__, __FUNCTION__, (rc < 0 )? -rc : rc);
break;
}
} while((!platform_timer_is_expired(&timer)) && (read_len < len));

View File

@@ -2,7 +2,7 @@
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @Date: 2020-01-11 19:45:44
* @LastEditTime : 2020-01-13 07:26:26
* @LastEditTime: 2020-02-25 03:51:37
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
*/
@@ -10,12 +10,12 @@
#define _PLATFORM_NETTYPE_TLS_H_
#include "platform_net_socket.h"
#include "mqtt_config.h"
#include "mqtt_defconfig.h"
#include "network.h"
#include "error.h"
#include "log.h"
#if MQTT_NETWORK_TYPE_TLS
#ifdef MQTT_NETWORK_TYPE_TLS
typedef struct nettype_tls_params {
mbedtls_net_context socket_fd; /**< mbed TLS network context. */

View File

@@ -38,6 +38,23 @@ platform_thread_t *platform_thread_init( const char *name,
return thread;
}
void platform_thread_startup(platform_thread_t* thread)
{
(void)thread;
}
void platform_thread_stop(platform_thread_t* thread)
{
tos_task_suspend(&(thread->thread));
}
void platform_thread_start(platform_thread_t* thread)
{
tos_task_resume(&(thread->thread));
}
void platform_thread_destroy(platform_thread_t* thread)
{
if (NULL != thread)

View File

@@ -20,6 +20,9 @@ platform_thread_t *platform_thread_init( const char *name,
unsigned int stack_size,
unsigned int priority,
unsigned int tick);
void platform_thread_startup(platform_thread_t* thread);
void platform_thread_stop(platform_thread_t* thread);
void platform_thread_start(platform_thread_t* thread);
void platform_thread_destroy(platform_thread_t* thread);
#endif