openharmony 鸿蒙 porting-minichip-subsys-communication

2022-12-05 浏览 (1101)

Porting the Communication Subsystem

The communication subsystem porting process involves Wi-Fi and Bluetooth adaptation. Vendors need to perform adaptation based on the chip conditions.

Procedure

To implement Wi-Fi adaptation, perform the following steps:

Path: foundation/communication/wifi_lite/BUILD.gn

group("wifi") {
  deps = [ "$ohos_board_adapter_dir/hals/communication/wifi_lite/wifiservice:wifiservice" ]
}

As shown above, the .c file of the vendor adaptation interfaces is stored in the $ohos_board_adapter_dir/hals/communication/wifi_lite/wifiservice directory, where the target in the BUILD.gn file is wifiservice. Table 1, Table 2, and Table 3 list the Wi-Fi interfaces that need to be adapted by vendors. Table 4 and Table 5 list the Bluetooth interfaces.

Table 1 wifi_device.h

APIDescription
EnableWifiEnables the Wi-Fi STA mode.
DisableWifiDisables the Wi-Fi STA mode.
IsWifiActiveCheck whether the Wi-Fi STA mode is enabled.
ScanScans for hotspots.
GetScanInfoListObtains the list of all found hotspots.
AddDeviceConfigAdds the information about the hotspot to be connected.
GetDeviceConfigsObtains the information about the connected hotspot.
RemoveDeviceDeletes the information about a specified hotspot.
ConnectToConnects to a specified hotspot.
DisconnectSevers the Wi-Fi connection.
GetLinkedInfoObtains hotspot connection information.
RegisterWifiEventRegisters a callback for a specified Wi-Fi event.
UnRegisterWifiEventDeregisters the callback previously registered for a specified Wi-Fi event.
GetDeviceMacAddressObtains the device MAC address.
AdvanceScanStarts Wi-Fi scanning based on specified parameters.

Table 2 wifi_hotspot_config.h

APIDescription
SetBandSets the frequency band of the hotspot.
GetBandObtains the frequency band of the hotspot.

Table 3 wifi_hotspot.h

APIDescription
EnableHotspotEnables AP hotspot mode.
DisableHotspotDisables AP hotspot mode.
SetHotspotConfigConfigures settings for a specified hotspot.
GetHotspotConfigObtains settings of a specified hotspot.
IsHotspotActiveChecks whether AP hotspot mode is enabled.
GetStationListObtains a list of STAs connected to the hotspot.
GetSignalLevelObtains the signal level of the specified received signal strength indicator (RSSI) and frequency band indicator.
DisassociateStaDisconnects from the STA that matches the specified MAC address.
AddTxPowerInfoSends the hotspot power to the beacon.

Table 4 ohos_bt_gatt.h

APIDescription
InitBtStackInitializes the Bluetooth protocol stack.
EnableBtStackEnables the Bluetooth protocol stack.
DisableBtStackDisables the Bluetooth protocol stack.
SetDeviceNameSets the Bluetooth device name.
BleSetAdvDataSets the data to advertise.
BleStartAdvStarts advertising.
BleStartAdvExTransfers the constructed advertising data and parameters to enable Bluetooth advertising.
BleStopAdvStops sending advertising messages.
BleUpdateAdvUpdates the advertising parameters.
BleSetSecurityIoCapSets the Bluetooth I/O capability to NONE and pairing mode to justworks.
BleSetSecurityAuthReqSets whether Bluetooth pairing is required.
BleGattSecurityRspResponds to a secure connection request.
ReadBtMacAddrObtains the device MAC address.
BleSetScanParametersSets scan parameters.
BleStartScanStarts scanning
BleStopScanStops scanning.
BleGattRegisterCallbacksRegisters a callback for GAP and GATT events.

Table 5 ohos_bt_gatt_server.h

APIDescription
BleGattsRegisterRegisters with the GATT server using the specified application UUID.
BleGattsUnRegisterDeregisters from the GATT server.
BleGattsDisconnectDisconnects the GATT server from the client.
BleGattsAddServiceAdds a service.
BleGattsAddIncludedServiceAdds an included service to a specified service.
BleGattsAddCharacteristicAdds a feature to a specified service.
BleGattsAddDescriptorAdds a descriptor to a specified feature.
BleGattsStartServiceStart a service.
BleGattsStopServiceStops a service.
BleGattsDeleteServiceDeletes a service.
BleGattsClearServicesClears all services.
BleGattsSendResponseSends a response to the client that receives the read or write request.
BleGattsSendIndicationSends Bluetooth data from the device to the application.
BleGattsSetEncryptionSets the encryption type of the GATT connection.
BleGattsRegisterCallbacksRegisters a GATT server callback.
BleGattsStartServiceExCreates a GATT service based on the passed service list.
BleGattsStopServiceExStops the GATT service based on the passed handle .

icon-note.gif NOTE

The APIs may vary according to the version. Adapt the APIs according to the specific file of the current version.

Example

  1. Add the communication subsystem to the config.json file.

    Path: vendor/MyVendorCompany/MyProduct/config.json

    The sample code is as follows:

    { 
        "subsystem": "communication", 
        "components": [ 
            { "component": "wifi_lite", "features":[] }
        ] 
    },
    
  2. Add an adaptation file.

    In the vendor/MyVendorCompany/MyProduct/config.json file, set ohos_board_adapter_dir to //vendor/MyVendorCompany/MyProduct/adapter.

    In the ohos_board_adapter_dir directory, adapt the Wi-Fi and Bluetooth APIs based on the aforementioned header files.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Introduction

harmony 鸿蒙Combo Solution – ASR Chip Porting Case

harmony 鸿蒙Mini-System Devices with Screens – Bestechnic SoC Porting Case

harmony 鸿蒙FAQs

harmony 鸿蒙IoT Solution - Chipsea CST85 Chip Porting Case

harmony 鸿蒙Standard System Solution – Rockchip RK3568 Porting Case

harmony 鸿蒙A Method for Rapidly Porting the OpenHarmony Linux Kernel

harmony 鸿蒙Kernel Porting

harmony 鸿蒙Overview

harmony 鸿蒙Porting Preparation

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/ae9327299fc94d269cf8050a2c037a64