mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-23 08:49:59 +00:00
!5690 optimize feature notification code
Merge pull request !5690 from wanghan985406/master
This commit is contained in:
commit
c483a1ecd6
@ -38,10 +38,8 @@ declare_args() {
|
||||
dsoftbus_feature_lnn_wifiservice_dependence = false
|
||||
|
||||
dsoftbus_feature_build_shared_sdk = false
|
||||
dsoftbus_feature_ifname_prefix = false
|
||||
|
||||
dsoftbus_feature_encrypt = 0
|
||||
dsoftbus_standard_feature_dfinder_support_multi_nif = false
|
||||
|
||||
dsoftbus_feature_ex_kits = false
|
||||
dsoftbus_feature_proxy_file = false
|
||||
|
@ -38,10 +38,8 @@ declare_args() {
|
||||
dsoftbus_feature_lnn_wifiservice_dependence = false
|
||||
|
||||
dsoftbus_feature_build_shared_sdk = true
|
||||
dsoftbus_feature_ifname_prefix = false
|
||||
|
||||
dsoftbus_feature_encrypt = 0
|
||||
dsoftbus_standard_feature_dfinder_support_multi_nif = true
|
||||
|
||||
dsoftbus_feature_ex_kits = false
|
||||
dsoftbus_feature_proxy_file = true
|
||||
|
@ -38,10 +38,8 @@ declare_args() {
|
||||
dsoftbus_feature_lnn_wifiservice_dependence = true
|
||||
|
||||
dsoftbus_feature_build_shared_sdk = true
|
||||
dsoftbus_feature_ifname_prefix = false
|
||||
|
||||
dsoftbus_feature_encrypt = 1
|
||||
dsoftbus_standard_feature_dfinder_support_multi_nif = true
|
||||
|
||||
dsoftbus_feature_ex_kits = false
|
||||
dsoftbus_feature_proxy_file = true
|
||||
|
@ -36,9 +36,7 @@
|
||||
"dsoftbus_feature_trans_udp_file",
|
||||
"dsoftbus_get_devicename",
|
||||
"dsoftbus_feature_product_config_path",
|
||||
"dsoftbus_feature_ifname_prefix",
|
||||
"dsoftbus_feature_lnn_wifiservice_dependence",
|
||||
"dsoftbus_standard_feature_dfinder_support_multi_nif",
|
||||
"dsoftbus_feature_protocol_newip",
|
||||
"dsoftbus_feature_ex_kits",
|
||||
"dsoftbus_feature_wifi_notify"
|
||||
|
@ -69,9 +69,9 @@ static uint32_t g_recvDiscoverMsgNum;
|
||||
static MsgIdList *g_msgIdList = NULL;
|
||||
static uint8_t g_subscribeCount;
|
||||
|
||||
static uint32_t *g_notificationIntervals = NULL;
|
||||
static uint32_t g_notificationTargetCnt = 0;
|
||||
static uint32_t g_notificationRunCnt = 0;
|
||||
static uint16_t *g_notificationIntervals = NULL;
|
||||
static uint8_t g_notificationTargetCnt = 0;
|
||||
static uint8_t g_notificationRunCnt = 0;
|
||||
static Timer *g_notificationTimer = NULL;
|
||||
|
||||
#ifdef DFINDER_SUPPORT_SET_SCREEN_STATUS
|
||||
@ -1023,17 +1023,13 @@ static int32_t CoapPostServiceNotification(void)
|
||||
return NSTACKX_EOK;
|
||||
}
|
||||
|
||||
static uint32_t GetNextNotificationInterval(uint32_t runCnt)
|
||||
static inline uint16_t GetNextNotificationInterval(uint8_t runCnt)
|
||||
{
|
||||
if (runCnt >= g_notificationTargetCnt) {
|
||||
return 0;
|
||||
}
|
||||
return g_notificationIntervals[runCnt];
|
||||
return (runCnt >= g_notificationTargetCnt) ? 0 : g_notificationIntervals[runCnt];
|
||||
}
|
||||
|
||||
void CoapServiceNotificationStop(void)
|
||||
static void ResetNotificationConfig(void)
|
||||
{
|
||||
(void)TimerSetTimeout(g_notificationTimer, 0, NSTACKX_FALSE);
|
||||
g_notificationRunCnt = 0;
|
||||
g_notificationTargetCnt = 0;
|
||||
if (g_notificationIntervals != NULL) {
|
||||
@ -1042,6 +1038,13 @@ void CoapServiceNotificationStop(void)
|
||||
}
|
||||
}
|
||||
|
||||
void CoapServiceNotificationStop(void)
|
||||
{
|
||||
(void)TimerSetTimeout(g_notificationTimer, 0, NSTACKX_FALSE);
|
||||
ResetNotificationConfig();
|
||||
DFINDER_LOGI(TAG, "caller stop send notifications, reset run cnt, target cnt all to 0");
|
||||
}
|
||||
|
||||
static void CoapServiceNotificationTimerHandle(void *argument)
|
||||
{
|
||||
(void)argument;
|
||||
@ -1053,15 +1056,15 @@ static void CoapServiceNotificationTimerHandle(void *argument)
|
||||
DFINDER_LOGE(TAG, "failed when post service notification");
|
||||
goto L_ERR_NOTIFICATION;
|
||||
}
|
||||
DFINDER_LOGI(TAG, "the %u time for sending notification", g_notificationRunCnt + 1);
|
||||
uint32_t nextInterval = GetNextNotificationInterval(++g_notificationRunCnt);
|
||||
DFINDER_LOGI(TAG, "the %hhu time for sending notification", g_notificationRunCnt + 1);
|
||||
uint16_t nextInterval = GetNextNotificationInterval(++g_notificationRunCnt);
|
||||
if (TimerSetTimeout(g_notificationTimer, nextInterval, NSTACKX_FALSE) != NSTACKX_EOK) {
|
||||
DFINDER_LOGE(TAG, "failed to set timer for service notification");
|
||||
goto L_ERR_NOTIFICATION;
|
||||
}
|
||||
return;
|
||||
L_ERR_NOTIFICATION:
|
||||
DFINDER_LOGE(TAG, "abort notification, tried %u request, now reset notification cnt to 0", g_notificationRunCnt);
|
||||
DFINDER_LOGE(TAG, "abort notification, tried %hhu request, now reset notification cnt to 0", g_notificationRunCnt);
|
||||
g_notificationRunCnt = 0;
|
||||
}
|
||||
|
||||
@ -1073,9 +1076,10 @@ static int32_t HndPostServiceNotificationEx(const coap_pdu_t *request)
|
||||
DFINDER_LOGE(TAG, "coap_get_data fail, size: %zu, coap rx buffer size: %d", size, COAP_RXBUFFER_SIZE);
|
||||
return NSTACKX_EFAILED;
|
||||
}
|
||||
NotificationConfig *notification = (NotificationConfig *)calloc(1, sizeof(NotificationConfig));
|
||||
NSTACKX_NotificationConfig *notification =
|
||||
(NSTACKX_NotificationConfig *)calloc(1, sizeof(NSTACKX_NotificationConfig));
|
||||
if (notification == NULL) {
|
||||
DFINDER_LOGE(TAG, "calloc for notification fail, size wanted: %zu", sizeof(NotificationConfig));
|
||||
DFINDER_LOGE(TAG, "calloc for notification fail, size wanted: %zu", sizeof(NSTACKX_NotificationConfig));
|
||||
return NSTACKX_ENOMEM;
|
||||
}
|
||||
notification->msg = (char *)calloc(NSTACKX_MAX_NOTIFICATION_DATA_LEN, sizeof(char));
|
||||
@ -1233,10 +1237,7 @@ void CoapDiscoverDeinit(void)
|
||||
free(g_coapIntervalArr);
|
||||
g_coapIntervalArr = NULL;
|
||||
}
|
||||
if (g_notificationIntervals != NULL) {
|
||||
free(g_notificationIntervals);
|
||||
g_notificationIntervals = NULL;
|
||||
}
|
||||
ResetNotificationConfig();
|
||||
}
|
||||
|
||||
void ResetCoapDiscoverTaskCount(uint8_t isBusy)
|
||||
@ -1329,9 +1330,9 @@ void SendDiscoveryRsp(const NSTACKX_ResponseSettings *responseSettings)
|
||||
}
|
||||
}
|
||||
|
||||
int32_t LocalizeNotificationInterval(const uint32_t *intervals, const uint32_t intervalLen)
|
||||
int32_t LocalizeNotificationInterval(const uint16_t *intervals, const uint8_t intervalLen)
|
||||
{
|
||||
uint32_t *tmp = (uint32_t *)malloc(intervalLen * sizeof(uint32_t));
|
||||
uint16_t *tmp = (uint16_t *)calloc(intervalLen, sizeof(uint16_t));
|
||||
if (tmp != NULL) {
|
||||
if (g_notificationIntervals != NULL) {
|
||||
free(g_notificationIntervals);
|
||||
@ -1343,7 +1344,7 @@ int32_t LocalizeNotificationInterval(const uint32_t *intervals, const uint32_t i
|
||||
g_notificationTargetCnt = intervalLen;
|
||||
return NSTACKX_EOK;
|
||||
}
|
||||
DFINDER_LOGW(TAG, "malloc for notification intervals fail, interval len %u", intervalLen);
|
||||
DFINDER_LOGW(TAG, "calloc for notification intervals fail, interval len %hhu", intervalLen);
|
||||
if (g_notificationIntervals != NULL) {
|
||||
DFINDER_LOGW(TAG, "going to use last success notification config");
|
||||
return NSTACKX_EOK;
|
||||
@ -1359,7 +1360,7 @@ static void CoapServiceNotificationFirstTime(void)
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t nextInterval = GetNextNotificationInterval(++g_notificationRunCnt);
|
||||
uint16_t nextInterval = GetNextNotificationInterval(++g_notificationRunCnt);
|
||||
if (TimerSetTimeout(g_notificationTimer, nextInterval, NSTACKX_FALSE) != NSTACKX_EOK) {
|
||||
DFINDER_LOGE(TAG, "failed to set timer when doing service notification");
|
||||
return;
|
||||
@ -1374,7 +1375,7 @@ void CoapServiceNotification(void)
|
||||
return;
|
||||
}
|
||||
if (g_notificationRunCnt != 0) {
|
||||
DFINDER_LOGI(TAG, "reset notification run cnt to 0, run cnt: %u, target cnt: %u",
|
||||
DFINDER_LOGI(TAG, "reset notification run cnt to 0, run cnt: %hhu, target cnt: %hhu",
|
||||
g_notificationRunCnt, g_notificationTargetCnt);
|
||||
g_notificationRunCnt = 0;
|
||||
(void)TimerSetTimeout(g_notificationTimer, 0, NSTACKX_FALSE);
|
||||
|
@ -584,15 +584,15 @@ char *PrepareServiceNotification(void)
|
||||
{
|
||||
char *str = PrepareServiceNotificationEx();
|
||||
if (str == NULL) {
|
||||
; // record exception here
|
||||
IncStatistics(STATS_PREPARE_SN_MSG_FAILED);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
int32_t ParseServiceNotification(const uint8_t *buf, NotificationConfig *notificaiton)
|
||||
int32_t ParseServiceNotification(const uint8_t *buf, NSTACKX_NotificationConfig *config)
|
||||
{
|
||||
if (buf == NULL || notificaiton == NULL) {
|
||||
DFINDER_LOGE(TAG, "buf or notification is null");
|
||||
if (buf == NULL || config == NULL) {
|
||||
DFINDER_LOGE(TAG, "buf or notification config is null");
|
||||
return NSTACKX_EINVAL;
|
||||
}
|
||||
cJSON *data = cJSON_Parse((char *)buf);
|
||||
@ -609,12 +609,13 @@ int32_t ParseServiceNotification(const uint8_t *buf, NotificationConfig *notific
|
||||
DFINDER_LOGE(TAG, "json notification data not in string format");
|
||||
goto LERR;
|
||||
}
|
||||
if (item->valuestring == NULL) {
|
||||
DFINDER_LOGE(TAG, "notification data item->valuestring is null");
|
||||
if (item->valuestring == NULL || strlen(item->valuestring) > NSTACKX_MAX_NOTIFICATION_DATA_LEN - 1) {
|
||||
DFINDER_LOGE(TAG, "parsed out illegal notification data len");
|
||||
goto LERR;
|
||||
}
|
||||
if (strcpy_s(notificaiton->msg, NSTACKX_MAX_NOTIFICATION_DATA_LEN, item->valuestring)) {
|
||||
DFINDER_LOGE(TAG, "parse service notification data fail, value string: %s", item->valuestring);
|
||||
config->msgLen = strlen(item->valuestring);
|
||||
if (strcpy_s(config->msg, NSTACKX_MAX_NOTIFICATION_DATA_LEN, item->valuestring) != EOK) {
|
||||
DFINDER_LOGE(TAG, "copy notification fail, errno: %d, desc: %s", errno, strerror(errno));
|
||||
goto LERR;
|
||||
}
|
||||
cJSON_Delete(data);
|
||||
@ -622,4 +623,4 @@ int32_t ParseServiceNotification(const uint8_t *buf, NotificationConfig *notific
|
||||
LERR:
|
||||
cJSON_Delete(data);
|
||||
return NSTACKX_EFAILED;
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ L_COAP_ERR:
|
||||
return NSTACKX_EFAILED;
|
||||
}
|
||||
|
||||
int32_t GetServiceNotificationInfo(const uint8_t *buf, size_t size, NotificationConfig *notification)
|
||||
int32_t GetServiceNotificationInfo(const uint8_t *buf, size_t size, NSTACKX_NotificationConfig *notification)
|
||||
{
|
||||
uint8_t *newBuf = NULL;
|
||||
if (buf[size - 1] != '\0') {
|
||||
@ -1698,7 +1698,7 @@ void NotifyDeviceFound(const NSTACKX_DeviceInfo *deviceList, uint32_t deviceCoun
|
||||
}
|
||||
}
|
||||
|
||||
void NotificationReceived(const NotificationConfig *notification)
|
||||
void NotificationReceived(const NSTACKX_NotificationConfig *notification)
|
||||
{
|
||||
if (g_parameter.onNotificationReceived != NULL) {
|
||||
DFINDER_LOGI(TAG, "notify callback: notification received");
|
||||
@ -1831,14 +1831,14 @@ int NSTACKX_DFinderSetEventFunc(void *softobj, DFinderEventFunc func)
|
||||
return SetEventFunc(softobj, func);
|
||||
}
|
||||
|
||||
static int32_t CheckNotificationConfig(const NotificationConfig *config)
|
||||
static int32_t CheckNotificationConfig(const NSTACKX_NotificationConfig *config)
|
||||
{
|
||||
if (config == NULL) {
|
||||
DFINDER_LOGE(TAG, "notification config passed in is null");
|
||||
return NSTACKX_EINVAL;
|
||||
}
|
||||
if (config->businessType >= NSTACKX_BUSINESS_TYPE_MAX) {
|
||||
DFINDER_LOGE(TAG, "invalid business type %d in notification config", config->businessType);
|
||||
DFINDER_LOGE(TAG, "invalid business type %hhu in notification config", config->businessType);
|
||||
return NSTACKX_EINVAL;
|
||||
}
|
||||
if (config->msg == NULL) {
|
||||
@ -1852,7 +1852,7 @@ static int32_t CheckNotificationConfig(const NotificationConfig *config)
|
||||
}
|
||||
// advertise count: [0, 100], first interval in intervalMs should be 0
|
||||
if (config->intervalLen == 0 || config->intervalLen > NSTACKX_MAX_ADVERTISE_COUNT) {
|
||||
DFINDER_LOGE(TAG, "invalid interval len %u in notification config, max support %d",
|
||||
DFINDER_LOGE(TAG, "invalid interval len %hhu in notification config, max support %d",
|
||||
config->intervalLen, NSTACKX_MAX_ADVERTISE_COUNT);
|
||||
return NSTACKX_EINVAL;
|
||||
}
|
||||
@ -1868,7 +1868,7 @@ static int32_t CheckNotificationConfig(const NotificationConfig *config)
|
||||
for (size_t i = 1; i < config->intervalLen; ++i) {
|
||||
if (config->intervalsMs[i] < NSTACKX_MIN_ADVERTISE_INTERVAL ||
|
||||
config->intervalsMs[i] > NSTACKX_MAX_ADVERTISE_INTERVAL) {
|
||||
DFINDER_LOGE(TAG, "invalid interval[%zu] = %u, support max: %d min: %d",
|
||||
DFINDER_LOGE(TAG, "invalid interval[%zu] = %hu, support max: %d min: %d",
|
||||
i, config->intervalsMs[i], NSTACKX_MAX_ADVERTISE_INTERVAL, NSTACKX_MIN_ADVERTISE_INTERVAL);
|
||||
return NSTACKX_EINVAL;
|
||||
}
|
||||
@ -1876,7 +1876,7 @@ static int32_t CheckNotificationConfig(const NotificationConfig *config)
|
||||
return NSTACKX_EOK;
|
||||
}
|
||||
|
||||
static int32_t CopyNotificationConfig(NotificationConfig *dst, const NotificationConfig *src)
|
||||
static int32_t CopyNotificationConfig(NSTACKX_NotificationConfig *dst, const NSTACKX_NotificationConfig *src)
|
||||
{
|
||||
dst->businessType = src->businessType;
|
||||
if (strncpy_s(dst->msg, src->msgLen + 1, src->msg, src->msgLen) != EOK) {
|
||||
@ -1893,7 +1893,7 @@ static int32_t CopyNotificationConfig(NotificationConfig *dst, const Notificatio
|
||||
|
||||
static void NotificationInner(void *argument)
|
||||
{
|
||||
NotificationConfig *config = (NotificationConfig *)argument;
|
||||
NSTACKX_NotificationConfig *config = (NSTACKX_NotificationConfig *)argument;
|
||||
int32_t retMsg = LocalizeNotificationMsg(config->msg);
|
||||
int32_t retInterval = LocalizeNotificationInterval(config->intervalsMs, config->intervalLen);
|
||||
free(config->intervalsMs);
|
||||
@ -1906,7 +1906,7 @@ static void NotificationInner(void *argument)
|
||||
CoapServiceNotification();
|
||||
}
|
||||
|
||||
int32_t NSTACKX_SendNotification(const NotificationConfig *config)
|
||||
int32_t NSTACKX_SendNotification(const NSTACKX_NotificationConfig *config)
|
||||
{
|
||||
DFINDER_LOGI(TAG, "begin to call NSTACKX_SendNotification");
|
||||
|
||||
@ -1917,9 +1917,9 @@ int32_t NSTACKX_SendNotification(const NotificationConfig *config)
|
||||
if (CheckNotificationConfig(config) != NSTACKX_EOK) {
|
||||
return NSTACKX_EINVAL;
|
||||
}
|
||||
NotificationConfig *dupConfig = (NotificationConfig *)malloc(sizeof(NotificationConfig));
|
||||
NSTACKX_NotificationConfig *dupConfig = (NSTACKX_NotificationConfig *)calloc(1, sizeof(NSTACKX_NotificationConfig));
|
||||
if (dupConfig == NULL) {
|
||||
DFINDER_LOGE(TAG, "malloc for notification config fail, size wanted: %zu", sizeof(NotificationConfig));
|
||||
DFINDER_LOGE(TAG, "calloc for notification config fail, size wanted: %zu", sizeof(NSTACKX_NotificationConfig));
|
||||
return NSTACKX_ENOMEM;
|
||||
}
|
||||
dupConfig->msg = (char *)calloc((config->msgLen + 1), sizeof(char));
|
||||
@ -1928,9 +1928,9 @@ int32_t NSTACKX_SendNotification(const NotificationConfig *config)
|
||||
free(dupConfig);
|
||||
return NSTACKX_ENOMEM;
|
||||
}
|
||||
dupConfig->intervalsMs = (uint32_t *)malloc(sizeof(uint32_t) * (config->intervalLen));
|
||||
dupConfig->intervalsMs = (uint16_t *)calloc(config->intervalLen, sizeof(uint16_t));
|
||||
if (dupConfig->intervalsMs == NULL) {
|
||||
DFINDER_LOGE(TAG, "malloc for intervals fail, size wanted: %zu", sizeof(uint32_t) * (config->intervalLen));
|
||||
DFINDER_LOGE(TAG, "calloc for intervals fail, size wanted: %zu", sizeof(uint16_t) * (config->intervalLen));
|
||||
free(dupConfig->msg);
|
||||
free(dupConfig);
|
||||
return NSTACKX_ENOMEM;
|
||||
@ -1965,9 +1965,13 @@ int32_t NSTACKX_StopSendNotification(uint8_t businessType)
|
||||
DFINDER_LOGE(TAG, "dfinder not inited");
|
||||
return NSTACKX_EFAILED;
|
||||
}
|
||||
if (businessType >= NSTACKX_BUSINESS_TYPE_MAX) {
|
||||
DFINDER_LOGE(TAG, "invalid business type %hhu to stop send notification", businessType);
|
||||
return NSTACKX_EINVAL;
|
||||
}
|
||||
if (PostEvent(&g_eventNodeChain, g_epollfd, NotificationStop, NULL) != NSTACKX_EOK) {
|
||||
DFINDER_LOGE(TAG, "post event failed to run stop device discover");
|
||||
return NSTACKX_EFAILED;
|
||||
}
|
||||
return NSTACKX_EOK;
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ void SetCoapDiscoverType(CoapBroadcastType type);
|
||||
void SetCoapUserDiscoverInfo(uint32_t advCount, uint32_t advDuration);
|
||||
int32_t SetCoapDiscConfig(const DFinderDiscConfig *discConfig);
|
||||
void SendDiscoveryRsp(const NSTACKX_ResponseSettings *responseSettings);
|
||||
int32_t LocalizeNotificationInterval(const uint32_t *intervals, const uint32_t intervalLen);
|
||||
int32_t LocalizeNotificationInterval(const uint16_t *intervals, const uint8_t intervalLen);
|
||||
void CoapServiceNotificationStop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -51,7 +51,7 @@ struct DeviceInfo;
|
||||
char *PrepareServiceDiscover(const char *localIpStr, uint8_t isBroadcast, uint8_t businessType);
|
||||
int32_t ParseServiceDiscover(const uint8_t *buf, struct DeviceInfo *deviceInfo, char **remoteUrlPtr);
|
||||
char *PrepareServiceNotification(void);
|
||||
int32_t ParseServiceNotification(const uint8_t *buf, NotificationConfig *config);
|
||||
int32_t ParseServiceNotification(const uint8_t *buf, NSTACKX_NotificationConfig *config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ void Coverity_Tainted_Set(void *buf);
|
||||
bool GetIsNotifyPerDevice(void);
|
||||
void NotifyDeviceListChanged(const NSTACKX_DeviceInfo *deviceList, uint32_t deviceCount);
|
||||
void NotifyDeviceFound(const NSTACKX_DeviceInfo *deviceList, uint32_t deviceCount);
|
||||
void NotificationReceived(const NotificationConfig *notification);
|
||||
void NotificationReceived(const NSTACKX_NotificationConfig *notification);
|
||||
|
||||
#ifndef DFINDER_USE_MINI_NSTACKX
|
||||
void NotifyMsgReceived(const char *moduleName, const char *deviceId, const uint8_t *data,
|
||||
@ -54,7 +54,7 @@ List *GetMainLoopEvendChain(void);
|
||||
uint32_t GetDefaultDiscoverInterval(uint32_t discoverCount);
|
||||
int32_t CheckBusinessTypeReplyUnicast(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, NotificationConfig *notification);
|
||||
int32_t GetServiceNotificationInfo(const uint8_t *buf, size_t size, NSTACKX_NotificationConfig *notification);
|
||||
List *GetEventNodeChain(void);
|
||||
EpollDesc GetEpollFD(void);
|
||||
|
||||
|
@ -53,6 +53,7 @@ typedef enum {
|
||||
STATS_FREE_RECORD_FAILED,
|
||||
STATS_OVER_DEVICE_LIMIT,
|
||||
STATS_COAP_RESOURCE_INIT_FAILED,
|
||||
STATS_PREPARE_SN_MSG_FAILED,
|
||||
STATS_MAX
|
||||
} StatisticsType;
|
||||
|
||||
|
@ -208,9 +208,9 @@ typedef struct {
|
||||
uint8_t businessType; /* service identify, see enum NSTACKX_BusinessType */
|
||||
char *msg; /* notification data in json format */
|
||||
size_t msgLen; /* strlen of notification data */
|
||||
uint32_t *intervalsMs; /* pointer to intervals to send notification, first element should be 0 */
|
||||
uint32_t intervalLen; /* configured number of intervals */
|
||||
} NotificationConfig;
|
||||
uint16_t *intervalsMs; /* pointer to intervals to send notification, first element should be 0 */
|
||||
uint8_t intervalLen; /* configured number of intervals */
|
||||
} NSTACKX_NotificationConfig;
|
||||
|
||||
/* Data receive callback type */
|
||||
typedef void (*NSTACKX_OnDFinderMsgReceived)(DFinderMsgType msgType);
|
||||
@ -218,9 +218,9 @@ typedef void (*NSTACKX_OnDFinderMsgReceived)(DFinderMsgType msgType);
|
||||
/**
|
||||
* @brief define function pointer type, used to report the notification data received
|
||||
*
|
||||
* @param [out] element: notification data to report, see struct NotificationReportType
|
||||
* @param [out] element: notification data to report, see struct NSTACKX_NotificationConfig
|
||||
*/
|
||||
typedef void (*NSTACKX_OnNotificationReceived)(const NotificationConfig *notificattion);
|
||||
typedef void (*NSTACKX_OnNotificationReceived)(const NSTACKX_NotificationConfig *notification);
|
||||
|
||||
/* NSTACKX parameter, which contains callback list */
|
||||
typedef struct {
|
||||
@ -496,7 +496,7 @@ DFINDER_EXPORT int32_t NSTACKX_SendDiscoveryRsp(const NSTACKX_ResponseSettings *
|
||||
/**
|
||||
* @brief start sending broadcast notifications
|
||||
*
|
||||
* @param [in] config: configurable properties to send notification, see struct NotificationConfig
|
||||
* @param [in] config: configurable properties to send notification, see struct NSTACKX_NotificationConfig
|
||||
*
|
||||
* @return (int32_t)
|
||||
* 0 operation success
|
||||
@ -507,7 +507,7 @@ DFINDER_EXPORT int32_t NSTACKX_SendDiscoveryRsp(const NSTACKX_ResponseSettings *
|
||||
* 2. caller should ensure the consistency of associated data
|
||||
* @exception
|
||||
*/
|
||||
DFINDER_EXPORT int32_t NSTACKX_SendNotification(const NotificationConfig *config);
|
||||
DFINDER_EXPORT int32_t NSTACKX_SendNotification(const NSTACKX_NotificationConfig *config);
|
||||
|
||||
/**
|
||||
* @brief stop sending broadcast notifications
|
||||
|
@ -17,9 +17,6 @@ import("$DSOFTBUS_ROOT_PATH/dsoftbus.gni")
|
||||
|
||||
NSTACKX_ROOT = "$DSOFTBUS_ROOT_PATH/components/nstackx"
|
||||
cflags = [ "-DENABLE_USER_LOG" ]
|
||||
if (dsoftbus_feature_ifname_prefix) {
|
||||
cflags += [ "-DETH_DEV_NAME_PRE=\"br\"" ]
|
||||
}
|
||||
if (defined(ohos_lite)) {
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "liteos_m") {
|
||||
|
@ -30,10 +30,10 @@ int32_t DiscCoapAssembleCapData(uint32_t capability, const char *capabilityData,
|
||||
void DiscFillBtype(uint32_t capability, uint32_t allCap, NSTACKX_DiscoverySettings *discSet);
|
||||
int32_t DiscCoapProcessDeviceInfo(const NSTACKX_DeviceInfo *nstackxInfo, DeviceInfo *devInfo,
|
||||
const DiscInnerCallback *discCb);
|
||||
void DiscCoapReportNotification(const NotificationConfig *notification);
|
||||
void DiscCoapReportNotification(const NSTACKX_NotificationConfig *notification);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // DISC_COAP_CAPABILITY_H
|
||||
#endif // DISC_COAP_CAPABILITY_H
|
||||
|
@ -79,7 +79,7 @@ int32_t DiscCoapProcessDeviceInfo(const NSTACKX_DeviceInfo *nstackxInfo, DeviceI
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
void DiscCoapReportNotification(const NotificationConfig *notification)
|
||||
void DiscCoapReportNotification(const NSTACKX_NotificationConfig *notification)
|
||||
{
|
||||
(void)notification;
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ static void OnDeviceFound(const NSTACKX_DeviceInfo *deviceList, uint32_t deviceC
|
||||
SoftBusFree(discDeviceInfo);
|
||||
}
|
||||
|
||||
static void OnNotificationReceived(const NotificationConfig *notification)
|
||||
static void OnNotificationReceived(const NSTACKX_NotificationConfig *notification)
|
||||
{
|
||||
DiscCoapReportNotification(notification);
|
||||
}
|
||||
@ -626,4 +626,4 @@ static int32_t NstackxLocalDevInfoDump(int fd)
|
||||
SOFTBUS_DPRINTF(fd, "businessType : %d\n", g_localDeviceInfo->businessType);
|
||||
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user