mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2025-02-17 01:30:02 +00:00
!8410 make timeout config works for unicast. for internal auto-reply unicast, make its type to NON-confirmable
Merge pull request !8410 from wanghan985406/master
This commit is contained in:
commit
9292eca2b3
@ -288,6 +288,7 @@ static coap_session_t *CoapGetSessionEx(coap_context_t *ctx, const char *localAd
|
||||
/* reuse the existed session */
|
||||
session = coap_session_get_by_peer(ctx, dst, 0);
|
||||
if (session != NULL) {
|
||||
CoapSetAckTimeOut(session);
|
||||
(void)coap_session_reference(session);
|
||||
return session;
|
||||
}
|
||||
|
@ -224,7 +224,11 @@ static int32_t CoapResponseService(CoapCtxType *ctx, const char *remoteUrl, uint
|
||||
return NSTACKX_EFAILED;
|
||||
}
|
||||
|
||||
int ret = CoapSendRequest(ctx, COAP_MESSAGE_CON, remoteUrl, data, strlen(data) + 1);
|
||||
// for internal auto-reply unicast, make its type to NON-confirmable
|
||||
// reliablity depends on the number of broadcast
|
||||
uint8_t coapMsgType = (ShouldAutoReplyUnicast(businessType) == NSTACKX_TRUE) ? COAP_MESSAGE_NON : COAP_MESSAGE_CON;
|
||||
int32_t ret = CoapSendRequest(ctx, coapMsgType, remoteUrl, data, strlen(data) + 1);
|
||||
|
||||
cJSON_free(data);
|
||||
return ret;
|
||||
}
|
||||
@ -274,7 +278,7 @@ static void CoapResponseServiceDiscovery(const char *remoteUrl, const coap_conte
|
||||
coap_pdu_t *response, uint8_t businessType)
|
||||
{
|
||||
if (remoteUrl != NULL) {
|
||||
if (CheckBusinessTypeReplyUnicast(businessType) == NSTACKX_EOK) {
|
||||
if (ShouldAutoReplyUnicast(businessType) == NSTACKX_TRUE) {
|
||||
CoapCtxType *ctx = CoapGetCoapCtxType(currCtx);
|
||||
if (ctx != NULL) {
|
||||
(void)CoapResponseService(ctx, remoteUrl, businessType);
|
||||
|
@ -133,7 +133,7 @@ static void CoapResponseServiceDiscovery(const char *remoteUrl, const CoapPacket
|
||||
(void)inet_ntop(AF_INET, ip, wifiIpAddr, sizeof(wifiIpAddr));
|
||||
GetBuildCoapParam(pkt, remoteUrl, wifiIpAddr, ¶m);
|
||||
if (remoteUrl != NULL) {
|
||||
if (CheckBusinessTypeReplyUnicast(businessType) == NSTACKX_EOK) {
|
||||
if (ShouldAutoReplyUnicast(businessType) == NSTACKX_TRUE) {
|
||||
(void)CoapSendMessage(¶m, NSTACKX_FALSE, businessType, false);
|
||||
}
|
||||
} else {
|
||||
|
@ -120,18 +120,18 @@ void NotifyDFinderMsgRecver(DFinderMsgType msgType)
|
||||
}
|
||||
}
|
||||
|
||||
int32_t CheckBusinessTypeReplyUnicast(uint8_t businessType)
|
||||
int32_t ShouldAutoReplyUnicast(uint8_t businessType)
|
||||
{
|
||||
switch (businessType) {
|
||||
case NSTACKX_BUSINESS_TYPE_SOFTBUS:
|
||||
case NSTACKX_BUSINESS_TYPE_AUTONET:
|
||||
case NSTACKX_BUSINESS_TYPE_STRATEGY:
|
||||
return NSTACKX_EFAILED;
|
||||
return NSTACKX_FALSE;
|
||||
case NSTACKX_BUSINESS_TYPE_NULL:
|
||||
case NSTACKX_BUSINESS_TYPE_HICOM:
|
||||
case NSTACKX_BUSINESS_TYPE_NEARBY:
|
||||
default:
|
||||
return NSTACKX_EOK;
|
||||
return NSTACKX_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,8 +123,7 @@ static int32_t UpdateDeviceDbInDeviceList(const CoapCtxType *coapCtx, const Devi
|
||||
DFINDER_LOGE(TAG, "update remote node by deviceinfo failed");
|
||||
return NSTACKX_EFAILED;
|
||||
}
|
||||
// for non-automatic reply businessType, report each unicast received, even if the content is same
|
||||
if (!receiveBcast && (CheckBusinessTypeReplyUnicast(deviceInfo->businessType) != NSTACKX_EOK)) {
|
||||
if (!receiveBcast && (ShouldAutoReplyUnicast(deviceInfo->businessType) != NSTACKX_TRUE)) {
|
||||
return updated ? DeviceInfoNotify(deviceInfo) : NSTACKX_EOK;
|
||||
}
|
||||
if (updated || forceUpdate) {
|
||||
|
@ -52,7 +52,7 @@ void NotifyDFinderMsgRecver(DFinderMsgType msgType);
|
||||
EpollDesc GetMainLoopEpollFd(void);
|
||||
List *GetMainLoopEvendChain(void);
|
||||
uint32_t GetDefaultDiscoverInterval(uint32_t discoverCount);
|
||||
int32_t CheckBusinessTypeReplyUnicast(uint8_t businessType);
|
||||
int32_t ShouldAutoReplyUnicast(uint8_t businessType);
|
||||
int32_t GetServiceDiscoverInfo(const uint8_t *buf, size_t size, struct DeviceInfo *deviceInfo, char **remoteUrlPtr);
|
||||
int32_t GetServiceNotificationInfo(const uint8_t *buf, size_t size, NSTACKX_NotificationConfig *notification);
|
||||
List *GetEventNodeChain(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user