add Tencent Cloud explorer lora demo

develop guide, see http://iwiki.oa.com/pages/viewpage.action?pageId=46342556
This commit is contained in:
daishengdong
2020-01-02 18:57:31 +08:00
parent 5b194c3d0a
commit a82569d9f3
5 changed files with 242 additions and 75 deletions

View File

@@ -20,10 +20,18 @@ int tos_lora_module_init(void)
return -1;
}
int tos_lora_module_join(void)
int tos_lora_module_join_otaa(const char *deveui, const char *appkey)
{
if (g_lora_module && g_lora_module->join) {
return g_lora_module->join();
if (g_lora_module && g_lora_module->join_otaa) {
return g_lora_module->join_otaa(deveui, appkey);
}
return -1;
}
int tos_lora_module_join_abp(const char *deveui, const char *devaddr, const char *nwkskey, const char *appskey)
{
if (g_lora_module && g_lora_module->join_abp) {
return g_lora_module->join_abp(deveui, devaddr, nwkskey, appskey);
}
return -1;
}
@@ -36,10 +44,11 @@ int tos_lora_module_send(const void *buf, size_t len)
return -1;
}
int tos_lora_module_recv_register(void* mcps_indication)
int tos_lora_module_recvcb_register(lora_recv_callback_t recv_callback)
{
if (g_lora_module && g_lora_module->recv_register) {
return g_lora_module->recv_register(mcps_indication);
if (g_lora_module) {
g_lora_module->recv_callback = recv_callback;
return 0;
}
return -1;
}

View File

@@ -21,18 +21,20 @@
#include <stdint.h>
#include <stdio.h>
typedef void (*mcps_indication_t)(uint8_t* data, uint8_t len);
typedef void (*lora_recv_callback_t)(uint8_t *data, uint8_t len);
typedef struct lora_module_st {
int (*init)(void);
int (*join)(void);
int (*join_otaa)(const char *deveui, const char *appkey);
int (*join_abp)(const char *deveui, const char *devaddr, const char *nwkskey, const char *appskey);
int (*send)(const void *buf, size_t len);
int (*recv_register)(void *mcps_indication);
int (*close)(void);
lora_recv_callback_t recv_callback;
} lora_module_t;
/**
@@ -62,7 +64,16 @@ int tos_lora_module_init(void);
*
* @return errcode
*/
int tos_lora_module_join(void);
int tos_lora_module_join_otaa(const char *deveui, const char *appkey);
/**
* @brief Join a lora gateway.
*
* @attention None
*
* @return errcode
*/
int tos_lora_module_join_abp(const char *deveui, const char *devaddr, const char *nwkskey, const char *appskey);
/**
* @brief Send data by lora module.
@@ -85,7 +96,7 @@ int tos_lora_module_send(const void *buf, size_t len);
*
* @return errcode
*/
int tos_lora_module_recv_register(void* mcps_indication);
int tos_lora_module_recvcb_register(lora_recv_callback_t recv_callback);
/**
* @brief Close the lora module.