transport modify

This commit is contained in:
huang
2023-09-27 16:24:11 +08:00
parent 40cedd339c
commit cf565f5d69
2 changed files with 45 additions and 93 deletions
@@ -1,3 +1,23 @@
/*
* Copyright (c) 2022 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file transport.c
* @brief mqtt transport function
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.8.10
*/
#include "transport.h"
#include "lwip/opt.h"
#include "lwip/arch.h"
@@ -8,13 +28,7 @@
static int mysock;
/************************************************************************
** : transport_sendPacketBuffer
** : TCPʽ
** ڲ: unsigned char* bufݻ
** int buflenݳ
** ڲ: <0ʧ
************************************************************************/
int32_t transport_sendPacketBuffer( uint8_t* buf, int32_t buflen)
{
int32_t rc;
@@ -22,13 +36,7 @@ int32_t transport_sendPacketBuffer( uint8_t* buf, int32_t buflen)
return rc;
}
/************************************************************************
** : transport_getdata
** : ķʽTCP
** ڲ: unsigned char* bufݻ
** int countݳ
** ڲ: <=0ʧ
************************************************************************/
int transport_getdata(unsigned char* buf, int count)
{
int32_t rc;
@@ -39,57 +47,6 @@ int transport_getdata(unsigned char* buf, int count)
}
/************************************************************************
** : transport_open
** : һӿڣҺͷ
** ڲ: char* servip:
** int port:˿ں
** ڲ: <0ʧ
************************************************************************/
// int32_t transport_open(int8_t* servip, int32_t port)
// {
// int32_t *sock = &mysock;
// int32_t ret;
// // int32_t opt;
// struct sockaddr_in addr;
// //ʼϢ
// memset(&addr,0,sizeof(addr));
// addr.sin_len = sizeof(addr);
// addr.sin_family = AF_INET;
// //д˿ں
// addr.sin_port = PP_HTONS(port);
// //дIPַ
// addr.sin_addr.s_addr = inet_addr((const char*)servip);
// //SOCK
// *sock = socket(AF_INET,SOCK_STREAM,0);
// //ӷ
// ret = connect(*sock,(struct sockaddr*)&addr,sizeof(addr));
// if(ret != 0)
// {
// //ر
// close(*sock);
// //ʧ
// return -1;
// }
// //ӳɹ,óʱʱ1000ms
// // opt = 1000;
// // setsockopt(*sock,SOL_SOCKET,SO_RCVTIMEO,&opt,sizeof(int));
// //׽
// return *sock;
// }
/************************************************************************
** : transport_close
** : ر׽
** ڲ: unsigned char* bufݻ
** int buflenݳ
** ڲ: <0ʧ
************************************************************************/
int32_t transport_close(void)
{
@@ -1,43 +1,38 @@
/*
* Copyright (c) 2022 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file transport.h
* @brief mqtt transport function
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.8.10
*/
#ifndef __TRANSPORT_H
#define __TRANSPORT_H
#include <stdint.h>
/************************************************************************
** : transport_sendPacketBuffer
** : TCPʽ
** ڲ: unsigned char* bufݻ
** int buflenݳ
** ڲ: <0ʧ
************************************************************************/
int32_t transport_sendPacketBuffer( uint8_t* buf, int32_t buflen);
/************************************************************************
** : transport_getdata
** : ķʽTCP
** ڲ: unsigned char* bufݻ
** int countݳ
** ڲ: <=0ʧ
************************************************************************/
int transport_getdata(unsigned char* buf, int count);
/************************************************************************
** : transport_open
** : һӿڣҺͷ
** ڲ: char* servip:
** int port:˿ں
** ڲ: <0ʧ
************************************************************************/
int32_t transport_open(int8_t* servip, int32_t port);
/************************************************************************
** : transport_close
** : ر׽
** ڲ: unsigned char* bufݻ
** int buflenݳ
** ڲ: <0ʧ
************************************************************************/
int32_t transport_close(void);