Merge pull request #8 from Tencent/master

merge
This commit is contained in:
Mculover666
2020-06-08 21:34:41 +08:00
committed by GitHub
14 changed files with 66 additions and 44 deletions

View File

@@ -95,7 +95,8 @@ uint8_t pool[DATA_CNT];
void application_entry(void *arg)
{
int i = 0;
int ret = 0;
int send_failed_count = 0;
rhf76_lora_init(HAL_UART_PORT_1);
tos_lora_module_recvcb_register(recv_callback);
@@ -113,7 +114,20 @@ void application_entry(void *arg)
}
printf("\n\n");
tos_lora_module_send(&dev_data.data, mail_size);
ret = tos_lora_module_send(&dev_data.data, mail_size);
if (ret < 0 )
{
printf("LoRa Send data faild! count is %d\r\n",send_failed_count);
send_failed_count++;
if (send_failed_count > 10)
{
eclic_system_reset();// when lora send faied more than 10 times , cpu reset to reconnect.
}
}
else
{
send_failed_count = 0;
}
}
}

View File

@@ -95,7 +95,8 @@ uint8_t pool[DATA_CNT];
void application_entry(void *arg)
{
int i = 0;
int ret = 0;
int send_failed_count = 0;
rhf76_lora_init(HAL_UART_PORT_0);
tos_lora_module_recvcb_register(recv_callback);
@@ -113,7 +114,20 @@ void application_entry(void *arg)
}
printf("\n\n");
tos_lora_module_send(&dev_data.data, mail_size);
ret = tos_lora_module_send(&dev_data.data, mail_size);
if (ret < 0 )
{
printf("LoRa Send data faild!, count is %d\r\n",send_failed_count);
send_failed_count++;
if (send_failed_count > 10)
{
NVIC_SystemReset();// when lora send faied more than 10 times , cpu reset to reconnect.
}
}
else
{
send_failed_count = 0;
}
}
}

View File

@@ -526,12 +526,12 @@ static int rhf76_send(const void *buf, size_t len)
snprintf(cmd, sizeof(cmd), RHF76_ATCMD_FMT_SEND_CMSGHEX, str_buf);
cmd[sizeof(cmd) - 1] = '\0';
tos_mmheap_free(str_buf);
tos_at_echo_create(&echo, NULL, 0, "+CMSG: ACK Received");
tos_at_echo_create(&echo, NULL, 0, "+CMSGHEX: ACK Received");
tos_at_cmd_exec(&echo, 6000, cmd);
if (echo.status == AT_ECHO_STATUS_OK || echo.status == AT_ECHO_STATUS_EXPECT) {
return -1;
return len;
}
return len;
return -1;
}
static int rhf76_send_unconfirmed(const void *buf, size_t len)
@@ -552,9 +552,9 @@ static int rhf76_send_unconfirmed(const void *buf, size_t len)
tos_at_echo_create(&echo, NULL, 0, "+MSGHEX: Done");
tos_at_cmd_exec(&echo, 6000, cmd);
if (echo.status == AT_ECHO_STATUS_OK || echo.status == AT_ECHO_STATUS_EXPECT) {
return -1;
return len;
}
return len;
return -1;
}
static int rhf76_close(void)

View File

@@ -32,7 +32,7 @@ int fputc(int ch, FILE *f)
return(ch);
}
```
添加完毕后在MDK工程上打开option选项选择debug选项调试方式选择User Simulator并修改调试参数如下图
添加完毕后在MDK工程上打开option选项选择debug选项调试方式选择User Simulator并修改调试参数如下图
![](image/MDK_Simulator_Guide/set_simulator_para.png)
完成软件仿真参数配置后就可以点击debug按钮开始调试了打开调试窗口后选择view->Serial windows->debug 就可以打开调试日志窗口了如图可以看到TencentOS Tiny内核的两个任务输出的日志信息。

View File

@@ -15,8 +15,8 @@
* within TencentOS.
*---------------------------------------------------------------------------*/
#ifndef _TOS_AT_H_
#define _TOS_AT_H_
#ifndef _TOS_AT_EVTDRV_H_
#define _TOS_AT_EVTDRV_H_
#include "tos_evtdrv.h"
#include "tos_at_utils_evtdrv.h"
@@ -53,8 +53,8 @@ typedef struct at_cache_st {
uint8_t *buffer;
size_t buffer_size;
size_t recv_len;
size_t curr_len;
size_t last_data;
size_t curr_len;
size_t last_data;
} at_cache_t;
typedef enum at_parse_status_en {
@@ -95,8 +95,8 @@ typedef struct at_echo_st {
char *buffer;
size_t buffer_size;
char *echo_expect;
evtdrv_task_id_t module_task_id;
evtdrv_event_flag_t event_flags;
evtdrv_task_id_t module_task_id;
evtdrv_event_flag_t event_flags;
int line_num;
at_echo_status_t status;
size_t __w_idx;
@@ -401,5 +401,5 @@ const char *tos_at_agent_channel_port_get(int channel_id);
evtdrv_event_flag_t tos_at_evtdrv_task(evtdrv_event_flag_t event);
#endif /* __AT_AGENT_H_ */
#endif /* _TOS_AT_EVTDRV_H_ */

View File

@@ -1,5 +1,5 @@
#ifndef _TOS_AT_UTILS_H_
#define _TOS_AT_UTILS_H_
#ifndef _TOS_AT_UTILS_EVTDRV_H_
#define _TOS_AT_UTILS_EVTDRV_H_
typedef struct at_timer_st {
evtdrv_tick_t end_time;
@@ -19,5 +19,5 @@ evtdrv_tick_t at_timer_remain(at_timer_t *tmr);
void at_timer_init(at_timer_t *tmr);
#endif
#endif//_TOS_AT_UTILS_EVTDRV_H_

View File

@@ -15,8 +15,8 @@
* within TencentOS.
*---------------------------------------------------------------------------*/
#ifndef __ESP8266_H__
#define __ESP8266_H__
#ifndef __ESP8266_EVTDRV_H__
#define __ESP8266_EVTDRV_H__
#include "tos_evtdrv.h"
#include "tos_hal.h"
@@ -50,14 +50,14 @@
typedef struct esp8266_event_header_st {
evtdrv_event_flag_t event;
evtdrv_task_id_t sender_id;
evtdrv_task_id_t sender_id;
} esp8266_event_hdr_t;
typedef struct esp8266_in_msg_init_st {
esp8266_event_hdr_t header;
hal_uart_port_t uart_port;
evtdrv_task_id_t at_task_id;
evtdrv_task_id_t esp8266_task_id;
evtdrv_task_id_t at_task_id;
evtdrv_task_id_t esp8266_task_id;
} esp8266_imsg_init_t;
typedef struct esp8266_in_msg_join_ap_st {
@@ -130,5 +130,5 @@ int esp8266_join_ap(const char *ssid, const char *pwd);
evtdrv_event_flag_t esp8266_task(evtdrv_event_flag_t event);
#endif /* __ESP8266_H__ */
#endif /* __ESP8266_EVTDRV_H__ */

View File

@@ -44,12 +44,11 @@ typedef struct k_barrier_st {
__API__ k_err_t tos_barrier_create(k_barrier_t *barrier, k_barrier_cnt_t count);
/**
* @brief Create a thread barrier.
* @brief Destroy a thread barrier.
*
* @attention the count must be greater then zero.
* @attention
*
* @param[in] barrier the barrier.
* @param[in] count the number of threads(task) must call tos_barrier_pend before any of them successfully return from the call.
*
* @return errcode
* @retval #K_ERR_NONE return successfully.

View File

@@ -83,7 +83,6 @@ __API__ k_err_t tos_completion_pend_timed(k_completion_t *completion, k_tick_t t
* @attention None
*
* @param[in] completion pointer to the handler of the completion.
* @param[in] timeout how much time(in k_tick_t) we would like to wait.
*
* @return errcode
* @retval #K_ERR_PEND_SCHED_LOCKED we can wait, but scheduler is locked.

View File

@@ -16,7 +16,7 @@
*---------------------------------------------------------------------------*/
#ifndef _TOS_COUNTDOWNLATCH_H_
#define _TOS_COUNTDOWNLATCH_H_
#define _TOS_COUNTDOWNLATCH_H_
__CDECLS_BEGIN
@@ -108,6 +108,7 @@ __API__ k_err_t tos_countdownlatch_post(k_countdownlatch_t *countdownlatch);
* @attention None.
*
* @param[in] countdownlatch pointer to the handler of the countdown-latch.
* @param[in] count the count to wait of the countdown-latch.
*
* @return errcode
* @retval #K_ERR_NONE return successfully.

View File

@@ -68,15 +68,13 @@ __API__ k_err_t tos_mmblk_pool_create(k_mmblk_pool_t *mbp, void *pool_start, siz
__API__ k_err_t tos_mmblk_pool_destroy(k_mmblk_pool_t *mbp);
/**
* @brief Create a memory manage block pool.
* Create a memory manage block pool.
* @brief Allocate a memory manage block.
* Allocate a memory manage block.
*
* @attention None
*
* @param[in] mbp pointer to the memory block pool handler.
* @param[in] pool_start start address of the pool.
* @param[in] blk_num number of the blocks in the pool.
* @param[in] blk_size size of each block in the pool.
* @param[in] blk start address of the memory manage block.
*
* @return errcode
* @retval #K_ERR_MMBLK_POOL_EMPTY the pool is empty.
@@ -85,15 +83,13 @@ __API__ k_err_t tos_mmblk_pool_destroy(k_mmblk_pool_t *mbp);
__API__ k_err_t tos_mmblk_alloc(k_mmblk_pool_t *mbp, void **blk);
/**
* @brief Create a memory manage block pool.
* Create a memory manage block pool.
* @brief Free a memory manage block.
* Free a memory manage block.
*
* @attention None
*
* @param[in] mbp pointer to the memory block pool handler.
* @param[in] pool_start start address of the pool.
* @param[in] blk_num number of the blocks in the pool.
* @param[in] blk_size size of each block in the pool.
* @param[in] blk start address of the memory manage block.
*
* @return errcode
* @retval #K_ERR_MMBLK_POOL_FULL the pool is full.

View File

@@ -106,8 +106,6 @@ __API__ k_err_t tos_prio_q_destroy(k_prio_q_t *prio_q);
* @attention if we wanna create a priority queue, we should offer a manager array buffer of which the size can be calculated by TOS_PRIO_Q_MGR_ARRAY_SIZE.
*
* @param[in] prio_q pointer to the handler of the priority queue.
* @param[in] mgr_array manager array buffer of the priority queue.
* @param[in] pool pool buffer of the priority queue.
* @param[in] item_cnt item count of the priority queue.
* @param[in] item_size size of each item of the priority queue.
*

View File

@@ -69,6 +69,7 @@ __API__ k_err_t tos_rwlock_destroy(k_rwlock_t *rwlock);
* and no writers can hold the write-lock.
*
* @param[in] rwlock the read-write lock.
* @param[in] timeout how much time(in k_tick_t) we would like to wait.
*
* @return errcode
* @retval #K_ERR_NONE return successfully.
@@ -110,6 +111,7 @@ __API__ k_err_t tos_rwlock_rpend_try(k_rwlock_t *rwlock);
* and no readers can hold the read-lock.
*
* @param[in] rwlock the read-write lock.
* @param[in] timeout how much time(in k_tick_t) we would like to wait.
*
* @return errcode
* @retval #K_ERR_NONE return successfully.

View File

@@ -217,7 +217,6 @@ int tos_tf_module_mqtt_state_get(mqtt_state_t *state);
* @attention None
*
* @param[in] log_level device information
* @param[in] tls_mode tls mode
*
* @return errcode
*/