1# IWlanInterface 2 3 4## 概述 5 6WLAN模块向上层WLAN服务提供了统一接口。 7 8上层服务调用相关的接口,可以建立/关闭WLAN热点,扫描/关联/去关联WLAN热点,设置国家码,管理网络设备等。 9 10**Since:** 113.2 12**Version:** 131.0 14**相关模块:** 15 16[WLAN](_w_l_a_n.md) 17 18 19## 汇总 20 21 22### Public 成员函数 23 24 | 名称 | 描述 | 25| -------- | -------- | 26| [Start](#start) () | 创建HAL和驱动之间的通道及获取驱动网卡信息,该函数调用在创建IWiFi实体后进行。 | 27| [Stop](#stop) () | 销毁HAL和驱动之间的通道,该函数调用在销毁IWiFi实体前进行。 | 28| [CreateFeature](#createfeature) ([in] int type, [out] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature) | 根据输入类型创建对应的feature对象。 | 29| [DestroyFeature](#destroyfeature) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature) | 销毁feature对象。 | 30| [GetAsscociatedStas](#getasscociatedstas) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [out] struct [HdfStaInfo](_hdf_sta_info.md)[] staInfo, [out] unsigned int num) | 获取与AP连接的所有STA的信息(目前只包含MAC地址)。 | 31| [GetChipId](#getchipid) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [out] unsigned char chipId) | 获得当前驱动的芯片ID。 | 32| [GetDeviceMacAddress](#getdevicemacaddress) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [out] unsigned char[] mac, [in] unsigned char len) | 获取设备的MAC地址。 | 33| [GetFeatureByIfName](#getfeaturebyifname) ([in] String ifName, [out] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature) | 通过网卡名称获取对应的feature对象。 | 34| [GetFeatureType](#getfeaturetype) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [out] int featureType) | 获取feature对象的类型。 | 35| [GetFreqsWithBand](#getfreqswithband) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [in] struct [HdfWifiInfo](_hdf_wifi_info.md) wifiInfo, [out] int[] freq) | 获取指定频段(2.4G或者5G)下支持的频率。 | 36| [GetIfNamesByChipId](#getifnamesbychipid) ([in] unsigned char chipId, [out] String ifName, [out] unsigned int num) | 通过芯片ID获得当前芯片所有的网卡名称。 | 37| [GetNetworkIfaceName](#getnetworkifacename) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [out] String ifName) | 根据feature对象获取网卡名称。 | 38| [GetSupportCombo](#getsupportcombo) ([out] unsigned long combo) | 获取多网卡共存情况。 | 39| [GetSupportFeature](#getsupportfeature) ([out] unsigned char[] supType) | 获取该设备支持的WLAN特性(不考虑当前的使用状态)。 | 40| [RegisterEventCallback](#registereventcallback) ([in] [IWlanCallback](interface_i_wlan_callback.md) cbFunc, [in] String ifName) | 注册IWiFi的回调函数,监听异步事件。 | 41| [UnregisterEventCallback](#unregistereventcallback) ([in] [IWlanCallback](interface_i_wlan_callback.md) cbFunc, [in] String ifName) | 去注册IWiFi的回调函数。 | 42| [ResetDriver](#resetdriver) ([in] unsigned char chipId, [in] String ifName) | 重启指定芯片ID的WLAN驱动程序。 | 43| [SetCountryCode](#setcountrycode) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [in] String code, [in] unsigned int len) | 设置国家码(表示AP射频所在的国家,规定了AP射频特性,包括AP的发送功率、支持的信道等。其目的是为了使AP的射频特性符合不同国家或区域的法律法规要求)。 | 44| [SetMacAddress](#setmacaddress) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [in] unsigned char[] mac) | 根据传入参数设置对应网卡的MAC地址。 | 45| [SetScanningMacAddress](#setscanningmacaddress) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [in] unsigned char[] scanMac) | 设置扫描单个MAC地址。 | 46| [SetTxPower](#settxpower) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [in] int power) | 设置发射功率。 | 47| [GetNetDevInfo](#getnetdevinfo) ([out] struct [HdfNetDeviceInfoResult](_hdf_net_device_info_result.md) netDeviceInfoResult) | 获取网络设备信息(设备索引、网卡名字、MAC等信息)。 | 48| [StartScan](#startscan) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [in] struct [HdfWifiScan](_hdf_wifi_scan.md) scan) | 启动扫描。 | 49| [GetPowerMode](#getpowermode) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [out] unsigned char mode) | 获取正在使用的功率模式。 | 50| [SetPowerMode](#setpowermode) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [in] unsigned char mode) | 设置功率模式。 | 51| [StartChannelMeas](#startchannelmeas) ([in] String ifName, [in] struct [MeasChannelParam](_meas_channel_param.md) measChannelParam) | 启动信道测量。 | 52| [GetChannelMeasResult](#getchannelmeasresult) ([in] String ifName, [out] struct [MeasChannelResult](_meas_channel_result.md) measChannelResult) | 获取信道测量结果。 | 53| [SetProjectionScreenParam](#setprojectionscreenparam) ([in] String ifName, [in] struct [ProjectionScreenCmdParam](_projection_screen_cmd_param.md) param) | 设置投屏参数。 | 54| [WifiSendCmdIoctl](#wifisendcmdioctl) ([in] String ifName, [in] int cmdId, [in] byte[] paramBuf) | 向驱动发送IO控制命令。 | 55| [GetStaInfo](#getstainfo) ([in] String ifName, [out] struct [WifiStationInfo](_wifi_station_info.md) info, [in] unsigned char[] mac) | 获取指定网卡的STA的信息。 | 56 57 58## 成员函数说明 59 60 61### CreateFeature() 62 63 64``` 65IWlanInterface::CreateFeature ([in] int type, [out] struct HdfFeatureInfo ifeature ) 66``` 67**描述:** 68根据输入类型创建对应的feature对象。 69 70**参数:** 71 72 | 名称 | 描述 | 73| -------- | -------- | 74| type | 创建的feature类型。 | 75| ifeature | 获取创建的feature对象。 | 76 77**返回:** 78 79如果操作成功,则返回0。 80 81如果操作失败,则返回负值。 82 83 84### DestroyFeature() 85 86 87``` 88IWlanInterface::DestroyFeature ([in] struct HdfFeatureInfo ifeature) 89``` 90**描述:** 91销毁feature对象。 92 93**参数:** 94 95 | 名称 | 描述 | 96| -------- | -------- | 97| ifeature | 销毁的feature对象。 | 98 99**返回:** 100 101如果操作成功,则返回0。 102 103如果操作失败,则返回负值。 104 105 106### GetAsscociatedStas() 107 108 109``` 110IWlanInterface::GetAsscociatedStas ([in] struct HdfFeatureInfo ifeature, [out] struct HdfStaInfo[] staInfo, [out] unsigned int num ) 111``` 112**描述:** 113获取与AP连接的所有STA的信息(目前只包含MAC地址)。 114 115**参数:** 116 117 | 名称 | 描述 | 118| -------- | -------- | 119| ifeature | feature对象。 | 120| staInfo | 保存与AP连接的STA的基本信息。 | 121| num | 实际连接的STA的个数。 | 122 123**返回:** 124 125如果操作成功,则返回0。 126 127如果操作失败,则返回负值。 128 129 130### GetChannelMeasResult() 131 132 133``` 134IWlanInterface::GetChannelMeasResult ([in] String ifName, [out] struct MeasChannelResult measChannelResult ) 135``` 136**描述:** 137获取信道测量结果。 138 139**参数:** 140 141 | 名称 | 描述 | 142| -------- | -------- | 143| ifName | 网卡名称。 | 144| measChannelResult | 信道测量结果(信道号、信道负载、信道噪声)。 | 145 146**返回:** 147 148如果操作成功,则返回0。 149 150如果操作失败,则返回负值。 151 152 153### GetChipId() 154 155 156``` 157IWlanInterface::GetChipId ([in] struct HdfFeatureInfo ifeature, [out] unsigned char chipId ) 158``` 159**描述:** 160获得当前驱动的芯片ID。 161 162**参数:** 163 164 | 名称 | 描述 | 165| -------- | -------- | 166| ifeature | feature对象。 | 167| chipId | 获得的芯片ID。 | 168 169**返回:** 170 171如果操作成功,则返回0。 172 173如果操作失败,则返回负值。 174 175 176### GetDeviceMacAddress() 177 178 179``` 180IWlanInterface::GetDeviceMacAddress ([in] struct HdfFeatureInfo ifeature, [out] unsigned char[] mac, [in] unsigned char len ) 181``` 182**描述:** 183获取设备的MAC地址。 184 185**参数:** 186 187 | 名称 | 描述 | 188| -------- | -------- | 189| ifeature | feature对象。 | 190| mac | 获得的MAC地址。 | 191| len | mac数组的长度。 | 192 193**返回:** 194 195如果操作成功,则返回0。 196 197如果操作失败,则返回负值。 198 199 200### GetFeatureByIfName() 201 202 203``` 204IWlanInterface::GetFeatureByIfName ([in] String ifName, [out] struct HdfFeatureInfo ifeature ) 205``` 206**描述:** 207通过网卡名称获取对应的feature对象。 208 209**参数:** 210 211 | 名称 | 描述 | 212| -------- | -------- | 213| ifName | 网卡名称。 | 214| ifeature | 获取该网卡的feature对象。 | 215 216**返回:** 217 218如果操作成功,则返回0。 219 220如果操作失败,则返回负值。 221 222 223### GetFeatureType() 224 225 226``` 227IWlanInterface::GetFeatureType ([in] struct HdfFeatureInfo ifeature, [out] int featureType ) 228``` 229**描述:** 230获取feature对象的类型。 231 232**参数:** 233 234 | 名称 | 描述 | 235| -------- | -------- | 236| ifeature | feature对象。 | 237| featureType | feature对象的类型。 | 238 239**返回:** 240 241如果操作成功,则返回0。 242 243如果操作失败,则返回负值。 244 245 246### GetFreqsWithBand() 247 248 249``` 250IWlanInterface::GetFreqsWithBand ([in] struct HdfFeatureInfo ifeature, [in] struct HdfWifiInfo wifiInfo, [out] int[] freq ) 251``` 252**描述:** 253获取指定频段(2.4G或者5G)下支持的频率。 254 255**参数:** 256 257 | 名称 | 描述 | 258| -------- | -------- | 259| ifeature | feature对象。 | 260| wifiInfo | 频段信息。 | 261| freq | 保存支持的频率。 | 262 263**返回:** 264 265如果操作成功,则返回0。 266 267如果操作失败,则返回负值。 268 269 270### GetIfNamesByChipId() 271 272 273``` 274IWlanInterface::GetIfNamesByChipId ([in] unsigned char chipId, [out] String ifName, [out] unsigned int num ) 275``` 276**描述:** 277通过芯片ID获得当前芯片所有的网卡名称。 278 279**参数:** 280 281 | 名称 | 描述 | 282| -------- | -------- | 283| chipId | 需要获取网卡名称的芯片ID。 | 284| ifNames | 网卡名称。 | 285| num | 网卡的数量。 | 286 287**返回:** 288 289如果操作成功,则返回0。 290 291如果操作失败,则返回负值。 292 293 294### GetNetDevInfo() 295 296 297``` 298IWlanInterface::GetNetDevInfo ([out] struct HdfNetDeviceInfoResult netDeviceInfoResult) 299``` 300**描述:** 301获取网络设备信息(设备索引、网卡名字、MAC等信息)。 302 303**参数:** 304 305 | 名称 | 描述 | 306| -------- | -------- | 307| netDeviceInfoResult | 输出参数,得到的网络设备信息。 | 308 309**返回:** 310 311如果操作成功,则返回0。 312 313如果操作失败,则返回负值。 314 315 316### GetNetworkIfaceName() 317 318 319``` 320IWlanInterface::GetNetworkIfaceName ([in] struct HdfFeatureInfo ifeature, [out] String ifName ) 321``` 322**描述:** 323根据feature对象获取网卡名称。 324 325**参数:** 326 327 | 名称 | 描述 | 328| -------- | -------- | 329| ifeature | feature对象。 | 330| ifName | 网卡名称。 | 331 332**返回:** 333 334如果操作成功,则返回0。 335 336如果操作失败,则返回负值。 337 338 339### GetPowerMode() 340 341 342``` 343IWlanInterface::GetPowerMode ([in] struct HdfFeatureInfo ifeature, [out] unsigned char mode ) 344``` 345**描述:** 346获取正在使用的功率模式。 347 348**参数:** 349 350 | 名称 | 描述 | 351| -------- | -------- | 352| ifeature | feature对象。 | 353| mode | 功率模式,包括睡眠模式(待机状态运行)、一般模式(正常额定功率运行)、穿墙模式(最大功率运行,提高信号强度和覆盖面积)。 | 354 355**返回:** 356 357如果操作成功,则返回0。 358 359如果操作失败,则返回负值。 360 361 362### GetStaInfo() 363 364 365``` 366IWlanInterface::GetStaInfo ([in] String ifName, [out] struct WifiStationInfo info, [in] unsigned char[] mac ) 367``` 368**描述:** 369获取指定网卡的STA的信息。 370 371**参数:** 372 373 | 名称 | 描述 | 374| -------- | -------- | 375| ifName | 网卡名称。 | 376| info | 获取的STA的信息,详情请参考[WifiStationInfo](_wifi_station_info.md)。 | 377| mac | STA的MAC地址。 | 378 379**返回:** 380 381如果操作成功,则返回0。 382 383如果操作失败,则返回负值。 384 385 386### GetSupportCombo() 387 388 389``` 390IWlanInterface::GetSupportCombo ([out] unsigned long combo) 391``` 392**描述:** 393获取多网卡共存情况。 394 395**参数:** 396 397 | 名称 | 描述 | 398| -------- | -------- | 399| combo | 基于芯片的能力保存当前所有支持的多网卡共存情况(比如支持AP、STA、P2P等不同组合的共存)。 | 400 401**返回:** 402 403如果操作成功,则返回0。 404 405如果操作失败,则返回负值。 406 407 408### GetSupportFeature() 409 410 411``` 412IWlanInterface::GetSupportFeature ([out] unsigned char[] supType) 413``` 414**描述:** 415获取该设备支持的WLAN特性(不考虑当前的使用状态)。 416 417**参数:** 418 419 | 名称 | 描述 | 420| -------- | -------- | 421| supType | 保存当前设备支持的特性。 | 422 423**返回:** 424 425如果操作成功,则返回0。 426 427如果操作失败,则返回负值。 428 429 430### RegisterEventCallback() 431 432 433``` 434IWlanInterface::RegisterEventCallback ([in] IWlanCallback cbFunc, [in] String ifName ) 435``` 436**描述:** 437注册IWiFi的回调函数,监听异步事件。 438 439**参数:** 440 441 | 名称 | 描述 | 442| -------- | -------- | 443| cbFunc | 注册的回调函数。 | 444| ifName | 网卡名称。 | 445 446**返回:** 447 448如果操作成功,则返回0。 449 450如果操作失败,则返回负值。 451 452 453### ResetDriver() 454 455 456``` 457IWlanInterface::ResetDriver ([in] unsigned char chipId, [in] String ifName ) 458``` 459**描述:** 460重启指定芯片ID的WLAN驱动程序。 461 462**参数:** 463 464 | 名称 | 描述 | 465| -------- | -------- | 466| chipId | 需要进行重启驱动的芯片ID。 | 467| ifName | 网卡名称。 | 468 469**返回:** 470 471如果操作成功,则返回0。 472 473如果操作失败,则返回负值。 474 475 476### SetCountryCode() 477 478 479``` 480IWlanInterface::SetCountryCode ([in] struct HdfFeatureInfo ifeature, [in] String code, [in] unsigned int len ) 481``` 482**描述:** 483设置国家码(表示AP射频所在的国家,规定了AP射频特性,包括AP的发送功率、支持的信道等。其目的是为了使AP的射频特性符合不同国家或区域的法律法规要求)。 484 485**参数:** 486 487 | 名称 | 描述 | 488| -------- | -------- | 489| ifeature | feature对象。 | 490| code | 设置的国家码。 | 491| len | 国家码长度。 | 492 493**返回:** 494 495如果操作成功,则返回0。 496 497如果操作失败,则返回负值。 498 499 500### SetMacAddress() 501 502 503``` 504IWlanInterface::SetMacAddress ([in] struct HdfFeatureInfo ifeature, [in] unsigned char[] mac ) 505``` 506**描述:** 507根据传入参数设置对应网卡的MAC地址。 508 509**参数:** 510 511 | 名称 | 描述 | 512| -------- | -------- | 513| ifeature | feature对象。 | 514| mac | 设置的MAC地址。 | 515 516**返回:** 517 518如果操作成功,则返回0。 519 520如果操作失败,则返回负值。 521 522 523### SetPowerMode() 524 525 526``` 527IWlanInterface::SetPowerMode ([in] struct HdfFeatureInfo ifeature, [in] unsigned char mode ) 528``` 529**描述:** 530设置功率模式。 531 532**参数:** 533 534 | 名称 | 描述 | 535| -------- | -------- | 536| ifeature | feature对象。 | 537| mode | 功率模式,包括睡眠模式(待机状态运行)、一般模式(正常额定功率运行)、穿墙模式(最大功率运行,提高信号强度和覆盖面积)。 | 538 539**返回:** 540 541如果操作成功,则返回0。 542 543如果操作失败,则返回负值。 544 545 546### SetProjectionScreenParam() 547 548 549``` 550IWlanInterface::SetProjectionScreenParam ([in] String ifName, [in] struct ProjectionScreenCmdParam param ) 551``` 552**描述:** 553设置投屏参数。 554 555**参数:** 556 557 | 名称 | 描述 | 558| -------- | -------- | 559| ifName | 网卡名称。 | 560| param | 投屏参数。 | 561 562**返回:** 563 564如果操作成功,则返回0。 565 566如果操作失败,则返回负值。 567 568 569### SetScanningMacAddress() 570 571 572``` 573IWlanInterface::SetScanningMacAddress ([in] struct HdfFeatureInfo ifeature, [in] unsigned char[] scanMac ) 574``` 575**描述:** 576设置扫描单个MAC地址。 577 578**参数:** 579 580 | 名称 | 描述 | 581| -------- | -------- | 582| ifeature | feature对象。 | 583| scanMac | 设置STA扫描的MAC地址。 | 584 585**返回:** 586 587如果操作成功,则返回0。 588 589如果操作失败,则返回负值。 590 591 592### SetTxPower() 593 594 595``` 596IWlanInterface::SetTxPower ([in] struct HdfFeatureInfo ifeature, [in] int power ) 597``` 598**描述:** 599设置发射功率。 600 601**参数:** 602 603 | 名称 | 描述 | 604| -------- | -------- | 605| ifeature | feature对象。 | 606| power | 设置的发射功率。 | 607 608**返回:** 609 610如果操作成功,则返回0。 611 612如果操作失败,则返回负值。 613 614 615### Start() 616 617 618``` 619IWlanInterface::Start () 620``` 621**描述:** 622创建HAL和驱动之间的通道及获取驱动网卡信息,该函数调用在创建IWiFi实体后进行。 623 624**返回:** 625 626如果操作成功,则返回0。 627 628如果操作失败,则返回负值。 629 630 631### StartChannelMeas() 632 633 634``` 635IWlanInterface::StartChannelMeas ([in] String ifName, [in] struct MeasChannelParam measChannelParam ) 636``` 637**描述:** 638启动信道测量。 639 640**参数:** 641 642 | 名称 | 描述 | 643| -------- | -------- | 644| ifName | 网卡名称。 | 645| measChannelParam | 信道测量参数(信道号、测量时间)。 | 646 647**返回:** 648 649如果操作成功,则返回0。 650 651如果操作失败,则返回负值。 652 653 654### StartScan() 655 656 657``` 658IWlanInterface::StartScan ([in] struct HdfFeatureInfo ifeature, [in] struct HdfWifiScan scan ) 659``` 660**描述:** 661启动扫描。 662 663**参数:** 664 665 | 名称 | 描述 | 666| -------- | -------- | 667| ifeature | feature对象。 | 668| scan | 扫描参数。 | 669 670**返回:** 671 672如果操作成功,则返回0。 673 674如果操作失败,则返回负值。 675 676 677### Stop() 678 679 680``` 681IWlanInterface::Stop () 682``` 683**描述:** 684销毁HAL和驱动之间的通道,该函数调用在销毁IWiFi实体前进行。 685 686**返回:** 687 688如果操作成功,则返回0。 689 690如果操作失败,则返回负值。 691 692 693### UnregisterEventCallback() 694 695 696``` 697IWlanInterface::UnregisterEventCallback ([in] IWlanCallback cbFunc, [in] String ifName ) 698``` 699**描述:** 700去注册IWiFi的回调函数。 701 702**参数:** 703 704 | 名称 | 描述 | 705| -------- | -------- | 706| cbFunc | 去注册的回调函数。 | 707| ifName | 网卡名称。 | 708 709**返回:** 710 711如果操作成功,则返回0。 712 713如果操作失败,则返回负值。 714 715 716### WifiSendCmdIoctl() 717 718 719``` 720IWlanInterface::WifiSendCmdIoctl ([in] String ifName, [in] int cmdId, [in] byte[] paramBuf ) 721``` 722**描述:** 723向驱动发送IO控制命令。 724 725**参数:** 726 727 | 名称 | 描述 | 728| -------- | -------- | 729| ifName | 网卡名称。 | 730| cmdId | 命令ID。 | 731| paramBuf | 命令内容。 | 732 733**返回:** 734 735如果操作成功,则返回0。 736 737如果操作失败,则返回负值。 738