Files
TencentOS-tiny/net/lora_module_wrapper/lora_module_wrapper.c
Winfred LIN cafe9c8a87 added sending unconfirmed message for RHF76
1. added AT+ command "AT+MSGHEX" and change previous RHF76_ATCMD_FMT_SEND_MSGHEX to RHF76_ATCMD_FMT_SEND_CMSGHEX

2. implement send_unconfirmed with a non-breaking approach: added int (*send_unconfirmed)(const void *buf, size_t len); event handle in lora_module_st; added int tos_lora_module_send_unconfirmed(const void *buf, size_t len); in lora_module_wrapper.c; and implement static int rhf76_send_unconfirmed(const void *buf, size_t len) in RHF76.c

3. added { "+MSGHEX: PORT:", rhf76_incoming_data_process } in event array rhf76_at_event so that the device is able to process the downlink data when it is configurated to send unconfirmed message.

4. added AT+ command "AT+REPT", and implement the static int rhf76_set_repeat(uint8_t num) to enable user to set repeat times (1-15) while using "unconfirmed message"

5. updated the instructions of implemeting up-link parser and downlink parser on the server in the file "..\board\NUCLEO_STM32L073RZ\BSP\Src\lora_demo.c"
2020-04-01 18:47:45 +11:00

71 lines
1.5 KiB
C

#include "lora_module_wrapper.h"
static lora_module_t *g_lora_module = NULL;
int tos_lora_module_register(lora_module_t *module)
{
if (!g_lora_module) {
g_lora_module = module;
return 0;
}
return -1;
}
int tos_lora_module_init(void)
{
if (g_lora_module && g_lora_module->init) {
return g_lora_module->init();
}
return -1;
}
int tos_lora_module_join_otaa(const char *deveui, const char *appkey)
{
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;
}
int tos_lora_module_send(const void *buf, size_t len)
{
if (g_lora_module && g_lora_module->send) {
return g_lora_module->send(buf, len);
}
return -1;
}
int tos_lora_module_send_unconfirmed(const void *buf, size_t len)
{
if (g_lora_module && g_lora_module->send_unconfirmed) {
return g_lora_module->send_unconfirmed(buf, len);
}
return -1;
}
int tos_lora_module_recvcb_register(lora_recv_callback_t recv_callback)
{
if (g_lora_module) {
g_lora_module->recv_callback = recv_callback;
return 0;
}
return -1;
}
int tos_lora_module_close(void)
{
if (g_lora_module && g_lora_module->close) {
return g_lora_module->close();
}
return -1;
}