merge new qcloud sdk

1. qcloud has a great revolution, the protocol has been changed to implement data template, so the old TencentCloud_SDK developed by us will not work fine now(mqtt still works, but data template will not works fine for recently created product/devices).

2. I merge the official qlcoud sdk(include both the iot-hub and iot-explorer sdk) into the componet/conectivity to support new protocol of data template

3. iot-hub sdk, supply the fundamental iot protocol(like mqtt coap, etc.)
iot-explorer sdk, supply the high level service like data template based on mqtt

4. To know how it works, see qcloud_iot_explorer_sdk_data_template、qcloud_iot_hub_sdk_mqtt example(keil project in board\TencentOS_tiny_EVB_MX_Plus\KEIL\qcloud_iot_explorer_sdk_data_template and  board\TencentOS_tiny_EVB_MX_Plus\KEIL\qcloud_iot_hub_sdk_mqtt)
This commit is contained in:
daishengdong
2019-11-14 15:09:00 +08:00
parent 5d86548c23
commit 943db74fc7
705 changed files with 297267 additions and 0 deletions

View File

@@ -0,0 +1,131 @@
/*
* Tencent is pleased to support the open source community by making IoT Hub available.
* Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "network_interface.h"
#include "qcloud_iot_export_error.h"
#include "qcloud_iot_import.h"
#include "utils_param_check.h"
/*
* TCP/UDP socket API
*/
int network_tcp_init(Network *pNetwork)
{
return QCLOUD_RET_SUCCESS;
}
int network_tcp_connect(Network *pNetwork)
{
POINTER_SANITY_CHECK(pNetwork, QCLOUD_ERR_INVAL);
pNetwork->handle = HAL_TCP_Connect(pNetwork->host, pNetwork->port);
if (0 == pNetwork->handle) {
return -1;
}
return 0;
}
int network_tcp_read(Network *pNetwork, unsigned char *data, size_t datalen, uint32_t timeout_ms, size_t *read_len)
{
POINTER_SANITY_CHECK(pNetwork, QCLOUD_ERR_INVAL);
int rc = 0;
rc = HAL_TCP_Read(pNetwork->handle, data, (uint32_t)datalen, timeout_ms, read_len);
return rc;
}
int network_tcp_write(Network *pNetwork, unsigned char *data, size_t datalen, uint32_t timeout_ms, size_t *written_len)
{
POINTER_SANITY_CHECK(pNetwork, QCLOUD_ERR_INVAL);
int rc = 0;
rc =HAL_TCP_Write(pNetwork->handle, data, datalen, timeout_ms, written_len);
return rc;
}
void network_tcp_disconnect(Network *pNetwork)
{
POINTER_SANITY_CHECK_RTN(pNetwork);
if (0 == pNetwork->handle) {
return;
}
HAL_TCP_Disconnect(pNetwork->handle);
pNetwork->handle = 0;
return;
}
#if (defined COAP_COMM_ENABLED) && (defined AUTH_WITH_NOTLS)
int network_udp_init(Network *pNetwork)
{
return QCLOUD_RET_SUCCESS;
}
int network_udp_read(Network *pNetwork, unsigned char *data, size_t datalen, uint32_t timeout_ms, size_t *read_len)
{
POINTER_SANITY_CHECK(pNetwork, QCLOUD_ERR_INVAL);
int ret = HAL_UDP_ReadTimeout(pNetwork->handle, data, datalen, timeout_ms);
if (ret > 0) {
*read_len = ret;
ret = 0;
}
return ret;
}
int network_udp_write(Network *pNetwork, unsigned char *data, size_t datalen, uint32_t timeout_ms, size_t *written_len)
{
POINTER_SANITY_CHECK(pNetwork, QCLOUD_ERR_INVAL);
int ret = HAL_UDP_Write(pNetwork->handle, data, datalen);
if (ret > 0) {
*written_len = ret;
ret = 0;
}
return ret;
}
void network_udp_disconnect(Network *pNetwork)
{
POINTER_SANITY_CHECK_RTN(pNetwork);
HAL_UDP_Disconnect(pNetwork->handle);
pNetwork->handle = 0;
return ;
}
int network_udp_connect(Network *pNetwork)
{
POINTER_SANITY_CHECK(pNetwork, QCLOUD_ERR_INVAL);
pNetwork->handle = HAL_UDP_Connect(pNetwork->host, pNetwork->port);
if (0 == pNetwork->handle) {
return -1;
}
return 0;
}
#endif