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