• Lv3
    粉丝0

积分36 / 贡献0

提问4答案被采纳0文章0

请教一下通过什么方式可以调用@ohos.wifiManager被隐藏的wifiManager.getDeviceMacAddress()函数来获取MAC地址

sonia 显示全部楼层 发表于 2025-4-9 15:05:17

如题:请教一下专家,

通过什么方式可以调用@ohos.wifiManager被隐藏的wifiManager.getDeviceMacAddress()函数来获取MAC地址;

C:\Program Files\Huawei\DevEcoStudio507\sdk\default\openharmony\ets\api\@ohos.wifimanager.d.ts里getDeviceMacAddress()函数被隐藏了,

但是框架层是支持这个函数的,在interface/sdk-js/api/@ohos.wifimanager.d.ts里有该函数的定义,但是拷贝替换过去以后,dev-eco仍然不识别;提示以下编译错误:

有什么步骤操作能使用到这个函数或其它正规途径来获取OpenHarmony5.0下的WiFi MAC啊?

保存mac.png

您尚未登录,无法参与评论,登录后可以:
参与开源共建问题交流
认同或收藏高质量问答
获取积分成为开源共建先驱

精彩评论1

onefan

沙发 发表于 2025-4-9 16:22:54
1.你这是any类型

要改一下

let mac: string[] = wifiManager.getDeviceMacAddress();
2.

import wifiManager from '@ohos.wifiManager';
在@ohos.wifiManager中有getDeviceMacAddress不?需要full's'd'k

/**
* Obtain the MAC address of a Wi-Fi device. Wi-Fi must be enabled.
* The MAC address is unique and cannot be changed.
* @permission ohos.permission.GET_WIFI_LOCAL_MAC and ohos.permission.GET_WIFI_INFO
* @returns { string[] } Returns the MAC address of the Wi-Fi device.
* @throws {BusinessError} 201 - Permission denied.
* @throws {BusinessError} 202 - System API is not allowed called by Non-system application.
* @throws {BusinessError} 801 - Capability not supported.
* @throws {BusinessError} 2501000 - Operation failed.
* @throws {BusinessError} 2501001 - Wifi is closed.
* @syscap SystemCapability.Communication.WiFi.STA
* @systemapi Hide this for inner system use.
* @since 9
*/
function getDeviceMacAddress(): string[];

Copyright   ©2025  OpenHarmony开发者论坛  京ICP备2020036654号-3 |技术支持 Discuz!

返回顶部