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,11 +2,12 @@
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @Date: 2019-12-26 19:11:34
* @LastEditTime : 2019-12-28 01:51:38
* @LastEditTime: 2020-03-02 01:32:23
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
*/
#include "config.h"
#include "salof_defconfig.h"
#ifdef USE_LOG
void *salof_alloc(unsigned int size)
{
@@ -119,3 +120,4 @@ char *salof_get_task_name(void)
return k_curr_task->name;
}
#endif

View File

@@ -1,6 +1,8 @@
#include "fifo.h"
#include <string.h>
#ifdef USE_LOG
static unsigned int _flbs(unsigned int x) /* find last bit set*/
{
unsigned int r = 32;
@@ -131,3 +133,4 @@ unsigned int fifo_write_able(fifo_t fifo)
return (fifo->size - fifo_read_able(fifo));
}
#endif

View File

@@ -2,13 +2,15 @@
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @Date: 2019-12-25 23:54:38
* @LastEditTime : 2019-12-28 01:04:08
* @LastEditTime: 2020-02-25 08:10:01
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
*/
#ifndef _FIFO_H_
#define _FIFO_H_
#include "config.h"
#include "salof_defconfig.h"
#ifdef USE_LOG
#define FIFO_READ 0
#define FIFO_WRITE 1
@@ -33,5 +35,7 @@ unsigned int fifo_read(fifo_t fifo, void *buff, unsigned int len, unsigned int t
unsigned int fifo_read_able(fifo_t fifo);
unsigned int fifo_write_able(fifo_t fifo);
#endif
#endif // !_FIFO_H_

View File

@@ -2,11 +2,13 @@
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @Date: 2019-12-25 23:54:19
* @LastEditTime : 2019-12-28 01:53:41
* @LastEditTime: 2020-02-25 08:12:02
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
*/
#include "format.h"
#include "salof_defconfig.h"
#ifdef USE_LOG
static int _get_atoi(const char **str)
{
@@ -280,9 +282,6 @@ int format_nstr(char *buf, unsigned int size, const char *fmt, va_list ap)
return n;
}
#endif

View File

@@ -2,13 +2,12 @@
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @Date: 2019-12-25 23:54:38
* @LastEditTime : 2019-12-26 20:10:28
* @LastEditTime: 2020-02-25 07:18:09
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
*/
#ifndef _FORMAT_H_
#define _FORMAT_H_
#include "config.h"
#include <stdarg.h>
#define FORMAT_BUF_LEN 12

View File

@@ -9,6 +9,8 @@
#include "salof.h"
#ifdef USE_LOG
#ifndef SALOF_BUFF_SIZE
#define SALOF_BUFF_SIZE (1024U)
#endif
@@ -104,5 +106,5 @@ void salof_task(void *parm)
}
#endif
#endif

View File

@@ -1,6 +1,7 @@
#ifndef _SALOF_H_
#define _SALOF_H_
#include "salof_defconfig.h"
#include "format.h"
#include "fifo.h"
#include <stdio.h>
@@ -18,21 +19,19 @@ void salof(const char *fmt, ...);
#define FC_DARK 36
#define FC_WHITE 37
#if USE_LOG
#ifdef USE_LOG
#if USE_SALOF
#define PRINT_LOG salof
#define PRINT_LOG salof
#else
#if ((!USE_SALOF)&&(!PRINT_LOG))
#define PRINT_LOG printf
#define PRINT_LOG printf
#endif
#ifndef PRINT_LOG
#error "If the USE_LOG macro definition is turned on, you must define PRINT_LOG as the LOG output, such as #definePRINT_LOG printf"
#endif
#endif
#if LOG_TS || LOG_TAR
#endif
@@ -71,7 +70,7 @@ void salof(const char *fmt, ...);
#define DEBUG_LEVEL (INFO_LEVEL + 1)
#ifndef LOG_LEVEL
#define LOG_LEVEL WARN_LEVEL
#define LOG_LEVEL DEBUG_LEVEL
#endif
#if LOG_LEVEL < DEBUG_LEVEL

View File

@@ -0,0 +1,14 @@
/*
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @Date: 2020-02-25 06:01:24
* @LastEditTime: 2020-02-25 09:28:09
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
*/
#ifndef _SALOF_CONFIG_H_
#define _SALOF_CONFIG_H_
#include "mqtt_config.h"
#endif /* _SALOF_CONFIG_H_ */

View File

@@ -0,0 +1,144 @@
/*
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @Date: 2019-12-25 23:56:34
* @LastEditTime: 2020-03-02 01:32:32
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
*/
#ifndef _SALOF_DEFCONFIG_H_
#define _SALOF_DEFCONFIG_H_
#include "salof_config.h"
#ifdef USE_LOG
#define USE_RTT 1
#define USE_FREERTOS 2
#define USE_TENCENTOS 3
#define USE_LINUX 4
#define BASE_LEVEL (0)
#define ASSERT_LEVEL (BASE_LEVEL + 1)
#define ERR_LEVEL (ASSERT_LEVEL + 1)
#define WARN_LEVEL (ERR_LEVEL + 1)
#define INFO_LEVEL (WARN_LEVEL + 1)
#define DEBUG_LEVEL (INFO_LEVEL + 1)
#ifndef USE_SALOF
#define USE_SALOF (1U)
#endif
#ifndef USE_IDLE_HOOK
#define USE_IDLE_HOOK (0U)
#endif
#ifndef LOG_COLOR
#define LOG_COLOR (1U)
#endif
#ifndef LOG_TS
#define LOG_TS (1U)
#endif
#ifndef LOG_TAR
#define LOG_TAR (0U)
#endif
#ifndef LOG_LEVEL
#define LOG_LEVEL DEBUG_LEVEL //WARN_LEVEL DEBUG_LEVEL
#endif
#if USE_SALOF
#ifndef SALOF_BUFF_SIZE
#define SALOF_BUFF_SIZE (512U)
#endif
#ifndef SALOF_FIFO_SIZE
#define SALOF_FIFO_SIZE (1024*4U)
#endif
#ifndef SALOF_TASK_STACK_SIZE
#define SALOF_TASK_STACK_SIZE (2048U)
#endif
#ifndef SALOF_TASK_TICK
#define SALOF_TASK_TICK (20U)
#endif
#endif
#if !defined(SALOF_OS)
#error "SALOF_OS isn't defined in 'salof_config.h'"
#endif
#if (SALOF_OS == USE_FREERTOS)
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#define salof_mutex SemaphoreHandle_t
#define salof_tcb TaskHandle_t
#define salof_sem salof_mutex
#if USE_IDLE_HOOK
#define salof_handler vApplicationIdleHook
#endif
#define SALOF_TASK_PRIO (0U)
#elif (SALOF_OS == USE_TENCENTOS)
#include "tos_k.h"
#define salof_mutex k_mutex_t*
#define salof_sem k_sem_t*
#define salof_tcb k_task_t*
#define SALOF_TASK_PRIO (TOS_CFG_TASK_PRIO_MAX - 2u)
#undef USE_IDLE_HOOK
#elif (SALOF_OS == USE_RTT)
#include <rtconfig.h>
#include <rtthread.h>
#include <rthw.h>
#include <stdio.h>
#define salof_mutex rt_mutex_t
#define salof_sem rt_sem_t
#define salof_tcb rt_thread_t
#define SALOF_TASK_PRIO (RT_THREAD_PRIORITY_MAX - 1)
#elif (SALOF_OS == USE_LINUX)
#include "pthread.h"
#include "memory.h"
#include <semaphore.h>
#include <stdlib.h>
#include <stdio.h>
#define salof_mutex pthread_mutex_t*
#define salof_sem sem_t*
#define salof_tcb pthread_t*
#define SALOF_TASK_PRIO (0U)
#undef USE_IDLE_HOOK
#else
#error "not supported OS type"
#endif
void *salof_alloc(unsigned int size);
void salof_free(void *mem);
salof_tcb salof_task_create(const char *name,
void (*task_entry)(void *param),
void * const param,
unsigned int stack_size,
unsigned int priority,
unsigned int tick);
salof_mutex salof_mutex_create(void);
void salof_mutex_delete(salof_mutex mutex);
int salof_mutex_pend(salof_mutex mutex, unsigned int timeout);
int salof_mutex_post(salof_mutex mutex);
salof_sem salof_sem_create(void);
void salof_sem_delete(salof_sem sem);
int salof_sem_pend(salof_sem sem, unsigned int timeout);
int salof_sem_post(salof_sem sem);
unsigned int salof_get_tick(void);
char *salof_get_task_name(void);
extern int send_buff(char *buf, int len);
#endif
#endif // !_SALOF_DEFCONFIG_H_