forked from xuos/xiuos
support lora for aiit-arm32-board on nuttx
This commit is contained in:
parent
3735f221e0
commit
63210858e5
|
@ -34,7 +34,7 @@ int AdapterFrameworkInit(void)
|
|||
AppInitDoubleList(&adapter_list);
|
||||
|
||||
ret = PrivMutexCreate(&adapter_list_lock, 0);
|
||||
if(ret < 0) {
|
||||
if(ret != 0) {
|
||||
printf("AdapterFrameworkInit mutex create failed.\n");
|
||||
}
|
||||
|
||||
|
@ -50,11 +50,16 @@ AdapterType AdapterDeviceFindByName(const char *name)
|
|||
{
|
||||
struct Adapter *ret = NULL;
|
||||
struct DoublelistNode *node;
|
||||
int status = 0;
|
||||
|
||||
if (NULL == name)
|
||||
return NULL;
|
||||
|
||||
PrivMutexObtain(&adapter_list_lock);
|
||||
status = PrivMutexObtain(&adapter_list_lock);
|
||||
if (status != 0){
|
||||
printf("%s:pthread_mutex_lock failed, status=%d\n",__func__,status);
|
||||
}
|
||||
|
||||
DOUBLE_LIST_FOR_EACH(node, &adapter_list) {
|
||||
struct Adapter *adapter = CONTAINER_OF(node,
|
||||
struct Adapter, link);
|
||||
|
@ -64,7 +69,11 @@ AdapterType AdapterDeviceFindByName(const char *name)
|
|||
}
|
||||
printf("PrivMutexObtain in loop\n");
|
||||
}
|
||||
PrivMutexAbandon(&adapter_list_lock);
|
||||
|
||||
status = PrivMutexAbandon(&adapter_list_lock);
|
||||
if (status != 0){
|
||||
printf("%s:pthread_mutex_unlock failed, status=%d\n",__func__,status);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -76,6 +85,7 @@ AdapterType AdapterDeviceFindByName(const char *name)
|
|||
*/
|
||||
int AdapterDeviceRegister(struct Adapter *adapter)
|
||||
{
|
||||
int status = 0;
|
||||
if (NULL == adapter )
|
||||
return -1;
|
||||
|
||||
|
@ -84,9 +94,17 @@ int AdapterDeviceRegister(struct Adapter *adapter)
|
|||
return -1;
|
||||
}
|
||||
|
||||
PrivMutexObtain(&adapter_list_lock);
|
||||
status = PrivMutexObtain(&adapter_list_lock);
|
||||
if (status != 0){
|
||||
printf("%s:pthread_mutex_lock failed, status=%d\n",__func__,status);
|
||||
}
|
||||
|
||||
AppDoubleListInsertNodeAfter(&adapter_list, &adapter->link);
|
||||
PrivMutexAbandon(&adapter_list_lock);
|
||||
|
||||
status = PrivMutexAbandon(&adapter_list_lock);
|
||||
if (status != 0){
|
||||
printf("%s:pthread_mutex_unlock failed, status=%d\n",__func__,status);
|
||||
}
|
||||
|
||||
adapter->adapter_status = REGISTERED;
|
||||
|
||||
|
@ -100,11 +118,20 @@ int AdapterDeviceRegister(struct Adapter *adapter)
|
|||
*/
|
||||
int AdapterDeviceUnregister(struct Adapter *adapter)
|
||||
{
|
||||
int status = 0;
|
||||
if (!adapter)
|
||||
return -1;
|
||||
PrivMutexObtain(&adapter_list_lock);
|
||||
status = PrivMutexObtain(&adapter_list_lock);
|
||||
if (status != 0){
|
||||
printf("%s:pthread_mutex_lock failed, status=%d\n",__func__,status);
|
||||
}
|
||||
|
||||
AppDoubleListRmNode(&adapter->link);
|
||||
PrivMutexAbandon(&adapter_list_lock);
|
||||
|
||||
status = PrivMutexAbandon(&adapter_list_lock);
|
||||
if (status != 0){
|
||||
printf("%s:pthread_mutex_unlock failed, status=%d\n",__func__,status);
|
||||
}
|
||||
|
||||
adapter->adapter_status = UNREGISTERED;
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/connection/lora/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_ADAPTER_SX1278),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/connection/lora
|
||||
endif
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/connection/lora/*/Make.defs)
|
|
@ -1,7 +1,16 @@
|
|||
SRC_FILES := adapter_lora.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += adapter_lora.c
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_SX1278),y)
|
||||
SRC_DIR += sx1278
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_FILES := adapter_lora.c
|
||||
ifeq ($(CONFIG_ADAPTER_SX1278),y)
|
||||
SRC_DIR += sx1278
|
||||
endif
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
endif
|
||||
|
|
|
@ -27,6 +27,7 @@ extern AdapterProductInfoType Sx1278Attach(struct Adapter *adapter);
|
|||
#define ADAPTER_LORA_NAME "lora"
|
||||
#define ADAPTER_LORA_CLIENT_NUM 6
|
||||
#define ADAPTER_LORA_DATA_LENGTH 128
|
||||
#define ADAPTER_LORA_RECV_DATA_LENGTH 256
|
||||
|
||||
#define ADAPTER_LORA_DATA_HEAD 0x3C
|
||||
#define ADAPTER_LORA_NET_PANID 0x0102
|
||||
|
@ -96,12 +97,13 @@ struct LoraClientParam
|
|||
struct LoraDataFormat
|
||||
{
|
||||
uint8 flame_head;
|
||||
uint8 reserved[3];
|
||||
uint32 length;
|
||||
uint16 panid;
|
||||
uint8 client_id;
|
||||
uint8 gateway_id;
|
||||
|
||||
uint8 data_type;
|
||||
uint16 data_type;
|
||||
uint8 data[ADAPTER_LORA_DATA_LENGTH];
|
||||
|
||||
uint16 crc16;
|
||||
|
@ -150,6 +152,35 @@ static int LoraCrc16Check(uint8 *data, uint16 length)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Lora receive data check
|
||||
* @param data receive data buffer
|
||||
* @param length receive data length
|
||||
* @param recv_data LoraDataFormat data
|
||||
*/
|
||||
static int LoraReceiveDataCheck(uint8 *data, uint16 length, struct LoraDataFormat *recv_data)
|
||||
{
|
||||
int i;
|
||||
uint32 recv_data_length = 0;
|
||||
for ( i = 0; i < length; i ++) {
|
||||
if (ADAPTER_LORA_DATA_HEAD == data[i]) {
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
/*Big-Endian*/
|
||||
recv_data_length = (data[i + 4] & 0xFF) | ((data[i + 5] & 0xFF) << 8) | ((data[i + 6] & 0xFF) << 16) | ((data[i + 7] & 0xFF) << 24);
|
||||
#else
|
||||
/*Little-Endian*/
|
||||
recv_data_length = ((data[i + 4] & 0xFF) << 24) | ((data[i + 5] & 0xFF) << 16) | ((data[i + 6] & 0xFF) << 8) | (data[i + 7] & 0xFF);
|
||||
#endif
|
||||
if (sizeof(struct LoraDataFormat) == recv_data_length) {
|
||||
memcpy(recv_data, (uint8 *)(data + i), sizeof(struct LoraDataFormat));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Lora Gateway reply connect request to Client
|
||||
* @param adapter Lora adapter pointer
|
||||
|
@ -338,6 +369,10 @@ static int LoraClientSendData(struct Adapter *adapter, void *send_buf, int lengt
|
|||
static int LoraGateWayDataAnalyze(struct Adapter *adapter, struct LoraDataFormat *gateway_recv_data)
|
||||
{
|
||||
int ret = 0;
|
||||
printf("%s:gateway_recv_data\n",__func__);
|
||||
printf("head 0x%x length %d panid 0x%x data_type 0x%x client_id 0x%x gateway_id 0x%x crc 0x%x\n",
|
||||
gateway_recv_data->flame_head, gateway_recv_data->length, gateway_recv_data->panid, gateway_recv_data->data_type,
|
||||
gateway_recv_data->client_id, gateway_recv_data->gateway_id, gateway_recv_data->crc16);
|
||||
|
||||
if (LoraCrc16Check((uint8 *)gateway_recv_data, sizeof(struct LoraDataFormat)) < 0) {
|
||||
printf("LoraGateWayDataAnalyze CRC check error\n");
|
||||
|
@ -372,19 +407,22 @@ static int LoraGateWayDataAnalyze(struct Adapter *adapter, struct LoraDataFormat
|
|||
static int LoraClientDataAnalyze(struct Adapter *adapter, void *send_buf, int length)
|
||||
{
|
||||
int ret = 0;
|
||||
uint8 lora_recv_data[ADAPTER_LORA_RECV_DATA_LENGTH] = {0};
|
||||
|
||||
struct LoraDataFormat *client_recv_data = PrivMalloc(sizeof(struct LoraDataFormat));
|
||||
|
||||
memset(client_recv_data, 0, sizeof(struct LoraDataFormat));
|
||||
|
||||
ret = AdapterDeviceRecv(adapter, client_recv_data, sizeof(struct LoraDataFormat));
|
||||
if (0 == ret) {
|
||||
ret = AdapterDeviceRecv(adapter, lora_recv_data, ADAPTER_LORA_RECV_DATA_LENGTH);
|
||||
if (ret <= 0) {
|
||||
printf("LoraClientDataAnalyze recv error.Just return\n");
|
||||
PrivFree(client_recv_data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("client_recv_data\n");
|
||||
LoraReceiveDataCheck(lora_recv_data, ADAPTER_LORA_RECV_DATA_LENGTH, client_recv_data);
|
||||
|
||||
printf("%s:client_recv_data\n",__func__);
|
||||
printf("head 0x%x length %d panid 0x%x data_type 0x%x client_id 0x%x gateway_id 0x%x crc 0x%x\n",
|
||||
client_recv_data->flame_head, client_recv_data->length, client_recv_data->panid, client_recv_data->data_type,
|
||||
client_recv_data->client_id, client_recv_data->gateway_id, client_recv_data->crc16);
|
||||
|
@ -438,6 +476,11 @@ static int LoraClientJoinNet(struct Adapter *adapter, unsigned short panid)
|
|||
client_join_data.client_id = adapter->net_role_id;
|
||||
client_join_data.crc16 = LoraCrc16((uint8 *)&client_join_data, sizeof(struct LoraDataFormat) - 2);
|
||||
|
||||
printf("%s:client_join_data\n",__func__);
|
||||
printf("head 0x%x length %d panid 0x%x data_type 0x%x client_id 0x%x gateway_id 0x%x crc 0x%x\n",
|
||||
client_join_data.flame_head, client_join_data.length, client_join_data.panid, client_join_data.data_type,
|
||||
client_join_data.client_id, client_join_data.gateway_id, client_join_data.crc16);
|
||||
|
||||
if (AdapterDeviceJoin(adapter, (uint8 *)&client_join_data) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -479,15 +522,20 @@ static int LoraClientQuitNet(struct Adapter *adapter, unsigned short panid)
|
|||
int LoraGatewayProcess(struct Adapter *lora_adapter, struct LoraGatewayParam *gateway, struct LoraDataFormat *gateway_recv_data)
|
||||
{
|
||||
int i, ret = 0;
|
||||
uint8 lora_recv_data[ADAPTER_LORA_RECV_DATA_LENGTH];
|
||||
switch (LoraGatewayState)
|
||||
{
|
||||
case LORA_STATE_IDLE:
|
||||
ret = AdapterDeviceRecv(lora_adapter, gateway_recv_data, sizeof(struct LoraDataFormat));
|
||||
if (0 == ret) {
|
||||
memset(lora_recv_data, 0, ADAPTER_LORA_RECV_DATA_LENGTH);
|
||||
|
||||
ret = AdapterDeviceRecv(lora_adapter, lora_recv_data, ADAPTER_LORA_RECV_DATA_LENGTH);
|
||||
if (ret <= 0) {
|
||||
printf("LoraGatewayProcess IDLE recv error.Just return\n");
|
||||
break;
|
||||
}
|
||||
|
||||
LoraReceiveDataCheck(lora_recv_data, ADAPTER_LORA_RECV_DATA_LENGTH, gateway_recv_data);
|
||||
|
||||
if (ADAPTER_LORA_DATA_TYPE_JOIN == gateway_recv_data->data_type) {
|
||||
LoraGatewayState = LORA_JOIN_NET;
|
||||
} else if (ADAPTER_LORA_DATA_TYPE_QUIT == gateway_recv_data->data_type) {
|
||||
|
@ -516,12 +564,15 @@ int LoraGatewayProcess(struct Adapter *lora_adapter, struct LoraGatewayParam *ga
|
|||
continue;
|
||||
}
|
||||
|
||||
ret = AdapterDeviceRecv(lora_adapter, gateway_recv_data, sizeof(struct LoraDataFormat));
|
||||
if (0 == ret) {
|
||||
memset(lora_recv_data, 0, ADAPTER_LORA_RECV_DATA_LENGTH);
|
||||
ret = AdapterDeviceRecv(lora_adapter, lora_recv_data, ADAPTER_LORA_RECV_DATA_LENGTH);
|
||||
if (ret <= 0) {
|
||||
printf("LoraGatewayProcess recv error.Just return\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
LoraReceiveDataCheck(lora_recv_data, ADAPTER_LORA_RECV_DATA_LENGTH, gateway_recv_data);
|
||||
|
||||
if (ADAPTER_LORA_DATA_TYPE_JOIN == gateway_recv_data->data_type) {
|
||||
LoraGatewayState = LORA_JOIN_NET;
|
||||
} else if (ADAPTER_LORA_DATA_TYPE_QUIT == gateway_recv_data->data_type) {
|
||||
|
@ -754,19 +805,30 @@ int AdapterLoraTest(void)
|
|||
|
||||
//create lora gateway task
|
||||
#ifdef AS_LORA_GATEWAY_ROLE
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
pthread_attr_t lora_gateway_attr = PTHREAD_ATTR_INITIALIZER;
|
||||
lora_gateway_attr.priority = 20;
|
||||
lora_gateway_attr.stacksize = 2048;
|
||||
#else
|
||||
pthread_attr_t lora_gateway_attr;
|
||||
lora_gateway_attr.schedparam.sched_priority = 20;
|
||||
lora_gateway_attr.stacksize = 2048;
|
||||
#endif
|
||||
|
||||
PrivTaskCreate(&lora_gateway_task, &lora_gateway_attr, &LoraGatewayTask, (void *)adapter);
|
||||
PrivTaskStartup(&lora_gateway_task);
|
||||
|
||||
#else //AS_LORA_CLIENT_ROLE
|
||||
//create lora client task
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
pthread_attr_t lora_client_attr = PTHREAD_ATTR_INITIALIZER;
|
||||
lora_client_attr.priority = 20;
|
||||
lora_client_attr.stacksize = 2048;
|
||||
#else
|
||||
pthread_attr_t lora_client_attr;
|
||||
lora_client_attr.schedparam.sched_priority = 20;
|
||||
lora_client_attr.stacksize = 2048;
|
||||
|
||||
#endif
|
||||
//create lora client task
|
||||
PrivTaskCreate(&lora_client_data_task, &lora_client_attr, &LoraClientDataTask, (void *)adapter);
|
||||
PrivTaskStartup(&lora_client_data_task);
|
||||
|
||||
|
@ -778,4 +840,7 @@ int AdapterLoraTest(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterLoraTest, AdapterLoraTest, show adapter lora information);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@ if ADD_XIZI_FETURES
|
|||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
config ADAPTER_SX1278_DRIVER
|
||||
string "SX1278 device spi driver path"
|
||||
default "/dev/spi2_lora"
|
||||
|
||||
endif
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/connection/lora/sx1278/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_ADAPTER_LORA_SX1278),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/connection/lora/sx1278
|
||||
endif
|
|
@ -1,3 +1,13 @@
|
|||
SRC_FILES := sx1278.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += sx1278.c
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_FILES := sx1278.c
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
endif
|
||||
|
|
|
@ -20,6 +20,35 @@
|
|||
|
||||
#include <adapter.h>
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
* fd
|
||||
* buf - Data to write
|
||||
* nbytes - Length of data to write
|
||||
/**
|
||||
* @description: Sx127x_Nuttx_Write function for nuttx
|
||||
* @param fd - file descriptor to write to
|
||||
* @param buf - Data to write
|
||||
* @param buf - Length of data to write
|
||||
* @return On success, the number of bytes written are returned (zero indicates nothing was written). On error, -1 is returned.
|
||||
*/
|
||||
static int Sx127x_Nuttx_Write(int fd, const void *buf, size_t len)
|
||||
{
|
||||
int ret;
|
||||
|
||||
unsigned char *buffer = (unsigned char*)PrivMalloc(256);
|
||||
if (!buffer)
|
||||
{
|
||||
printf("failed to allocate buffer\n");
|
||||
}
|
||||
memset(buffer, 0, 256);
|
||||
memcpy(buffer,(unsigned char *)buf,len);
|
||||
|
||||
ret = PrivWrite(fd, buffer, len);
|
||||
PrivFree(buffer);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @description: Open SX1278 spi function
|
||||
* @param adapter - Lora device pointer
|
||||
|
@ -47,9 +76,14 @@ static int Sx1278Open(struct Adapter *adapter)
|
|||
static int Sx1278Close(struct Adapter *adapter)
|
||||
{
|
||||
/*step1: close sx1278 spi port*/
|
||||
PrivClose(adapter->fd);
|
||||
int ret;
|
||||
ret = PrivClose(adapter->fd);
|
||||
if(ret < 0){
|
||||
printf("Sx1278 close failed: %d!\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ADAPTER_DEBUG("Sx1278Close done\n");
|
||||
ADAPTER_DEBUG("Sx1278 Close done\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -73,13 +107,30 @@ static int Sx1278Ioctl(struct Adapter *adapter, int cmd, void *args)
|
|||
* @param priv_net_group - priv_net_group params
|
||||
* @return success: 0, failure: -1
|
||||
*/
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
static int Sx1278Join(struct Adapter *adapter, unsigned char *priv_net_group)
|
||||
{
|
||||
int ret;
|
||||
ret = Sx127x_Nuttx_Write(adapter->fd, (void *)priv_net_group, 144);
|
||||
if(ret < 0){
|
||||
printf("Sx1278 Join net group failed: %d!\n", ret);
|
||||
}
|
||||
|
||||
PrivWrite(adapter->fd, (void *)priv_net_group, 144);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
static int Sx1278Join(struct Adapter *adapter, unsigned char *priv_net_group)
|
||||
{
|
||||
int ret;
|
||||
ret = PrivWrite(adapter->fd, (void *)priv_net_group, 144);
|
||||
if(ret < 0){
|
||||
printf("Sx1278 Join net group failed: %d!\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @description: SX1278 send data function
|
||||
|
@ -88,11 +139,28 @@ static int Sx1278Join(struct Adapter *adapter, unsigned char *priv_net_group)
|
|||
* @param len - data len
|
||||
* @return success: 0, failure: -1
|
||||
*/
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
static int Sx1278Send(struct Adapter *adapter, const void *buf, size_t len)
|
||||
{
|
||||
PrivWrite(adapter->fd, buf, len);
|
||||
return 0;
|
||||
int ret;
|
||||
ret = Sx127x_Nuttx_Write(adapter->fd, buf, len);
|
||||
if(ret < 0){
|
||||
printf("send failed %d!\n", ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
static int Sx1278Send(struct Adapter *adapter, const void *buf, size_t len)
|
||||
{
|
||||
int ret;
|
||||
ret = PrivWrite(adapter->fd, buf, len);
|
||||
if(ret < 0){
|
||||
printf("send failed %d!\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @description: SX1278 receive data function
|
||||
|
@ -101,10 +169,25 @@ static int Sx1278Send(struct Adapter *adapter, const void *buf, size_t len)
|
|||
* @param len - data len
|
||||
* @return success: 0, failure: -1
|
||||
*/
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
static int Sx1278Recv(struct Adapter *adapter, void *buf, size_t len)
|
||||
{
|
||||
int ret;
|
||||
struct sx127x_read_hdr_s recv_data;
|
||||
ret = read(adapter->fd, &recv_data, sizeof(struct sx127x_read_hdr_s));
|
||||
if (ret <= 0){
|
||||
printf("Read failed %d!\n", ret);
|
||||
return ret;
|
||||
}
|
||||
memcpy((uint8 *)buf, (uint8 *)(&recv_data), len);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
static int Sx1278Recv(struct Adapter *adapter, void *buf, size_t len)
|
||||
{
|
||||
return PrivRead(adapter->fd, buf, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @description: SX1278 quit lora net group function
|
||||
|
@ -112,12 +195,30 @@ static int Sx1278Recv(struct Adapter *adapter, void *buf, size_t len)
|
|||
* @param priv_net_group - priv_net_group params
|
||||
* @return success: 0, failure: -1
|
||||
*/
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
static int Sx1278Quit(struct Adapter *adapter, unsigned char *priv_net_group)
|
||||
{
|
||||
PrivWrite(adapter->fd, (void *)priv_net_group, 144);
|
||||
int ret;
|
||||
ret = Sx127x_Nuttx_Write(adapter->fd, (void *)priv_net_group, 144);
|
||||
if(ret < 0){
|
||||
printf("Sx1278 quit net group failed %d!\n", ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
static int Sx1278Quit(struct Adapter *adapter, unsigned char *priv_net_group)
|
||||
{
|
||||
int ret;
|
||||
ret = PrivWrite(adapter->fd, (void *)priv_net_group, 144);
|
||||
if(ret < 0){
|
||||
printf("Sx1278 quit net group failed %d!\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static const struct PrivProtocolDone sx1278_done =
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <nuttx/time.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <nuttx/wireless/lpwan/sx127x.h>
|
||||
|
||||
typedef uint8_t uint8;
|
||||
typedef uint16_t uint16;
|
||||
|
@ -108,7 +109,7 @@ struct PinDevIrq
|
|||
struct PinParam
|
||||
{
|
||||
int cmd;//< cmd:GPIO_CONFIG_MODE/GPIO_IRQ_REGISTER/GPIO_IRQ_FREE/GPIO_IRQ_DISABLE/GPIO_IRQ_ENABLE
|
||||
long pin;//< pin number
|
||||
long pin;//< pin number
|
||||
int mode;//< pin mode: input/output
|
||||
struct PinDevIrq irq_set;//< pin irq set
|
||||
uint64 arg;
|
||||
|
@ -171,6 +172,9 @@ int PrivMutexDelete(pthread_mutex_t *p_mutex);
|
|||
int PrivMutexObtain(pthread_mutex_t *p_mutex);
|
||||
int PrivMutexAbandon(pthread_mutex_t *p_mutex);
|
||||
|
||||
|
||||
|
||||
|
||||
/*********************semaphore**********************/
|
||||
|
||||
int PrivSemaphoreCreate(sem_t *sem, int pshared, unsigned int value);
|
||||
|
|
Loading…
Reference in New Issue