跳到主要内容

RK3308 WIFI Interface Introduction

:::info 文档信息

文档标识:RK-KF-YF-338 · 发布版本:V1.0.1 · 发布日期:2020-02-28 · 页数:7 · 语言:英文

原始文档:Rockchip_Introduction_RK3308_DeviceIo_WIFI_EN.pdf

:::

章节大纲​

  • RK3308 WIFI Interface Introduction(P1)
    • Preface(P2)
    • Contents(P3)
      1. Overview(P4)
      1. Interface Introduction(P5)
      1. Application Demo(P7)

在线预览​

若预览无法显示,请直接下载 PDF 后用本地阅读器打开。


Preface​

Preface

This document mainly introduce the interfaces in the RK3308 DeviceIo library

Chipset

RK3308

Intended Audience

This document (this guide) is mainly intended for:

Technical support engineers Software development engineers

Revision History

DateVersionAuthorRevision History
2019-3-29V1.0.0Jacky GeInitial version
2020-02-28V1.0.1Ruby ZhangUpdate the format and the name of document

Contents​

RK3308 WIFI Interface Introduction Preface Contents 1. Overview 2. Interface Introduction 3. Application Demo

1. Overview​

This code module is integrated in the libDeviceIo.so dynamic library and it is a WIFI operation interface based on WPA package.

2. Interface Introduction​

RK_WIFI_RUNNING_State_e

About several status definitions of WIFI :

1 typedef enum { 2 RK WIFI State IDLE = 0, _ _ _ 3 RK WIFI State CONNECTING, _ _ _ 4 RK WIFI State CONNECTFAILED, _ _ _ 5 RK WIFI State CONNECTFAILED WRONG KEY, _ _ _ _ _ 6 RK WIFI State CONNECTED, _ _ _ 7 RK WIFI State DISCONNECTED _ _ _ 8 } RK WIFI RUNNING State e; _ _ _ _
1 2 3 4 5 6 7 8typedef enum { RK WIFI State IDLE = 0, _ _ _ RK WIFI State CONNECTING, _ _ _ RK WIFI State CONNECTFAILED, _ _ _ RK WIFI State CONNECTFAILED WRONG KEY, _ _ _ _ _ RK WIFI State CONNECTED, _ _ _ RK WIFI State DISCONNECTED _ _ _ } RK WIFI RUNNING State e; _ _ _ _
RK WIFI CONNECTION Encryp e _ _ _ _

There are three WIFI encryption types: passwordless, WPA and WEP.

1 typedef enum { 2 NONE = 0, 3 WPA, 4 WEP 5 } RK WIFI CONNECTION Encryp e; _ _ _ _
1 2 3 4 5typedef enum { NONE = 0, WPA, WEP } RK WIFI CONNECTION Encryp e; _ _ _ _
RK WIFI INFO Connection s _ _ _ _

Please refer to wpa_cli -iwlan0 status for WIFI status information.

1 typedef struct { 2 int id; 3 char bssid[20]; 4 char ssid[64]; 5 int freq; 6 char mode[20]; 7 char wpa state[20]; _ 8 char ip address[20]; _ 9 char mac address[20]; _ 10 } RK WIFI INFO Connection s; _ _ _ _
1 2 3 4 5 6 7 8 9 10typedef struct { int id; char bssid[20]; char ssid[64]; int freq; char mode[20]; char wpa state[20]; _ char ip address[20]; _ char mac address[20]; _ } RK WIFI INFO Connection s; _ _ _ _
i

To register the WIFI status callback interface, and callback when WIFI status changes.

int RK_wifi_ble_register_callback(RK_wifi_state_callback cb)

The BLE WIFI callback interface, which is used for callback status during BLE network configuration.

int RK_wifi_running_getState(RK_WIFI_RUNNING_State_e* pState)

To get current WIFI status and return 0 if successful.

int RK_wifi_running_getConnectionInfo(RK_WIFI_INFO_Connection_s* pInfo)

To get current WIFI connection information.

int RK_wifi_enable_ap(const char* ssid, const char* psk, const char* ip)

To enable softAp based on the value of ssid, psk and ip.

int RK_wifi_disable_ap()

Close softAp.

int RK_wifi_scan(void)

Please refer to wpa_cli -iwlan0 scan and execute WIFI sacn operation .

char* RK_wifi_scan_r(void)

Please refer to wpa_cli -iwlan0 scan_r,and get WIFI scan result, and return JSON.

char* RK_wifi_scan_r_sec(const unsigned int cols)

Please refer to RK_wifi_scan_r(void), and get specified column from WIFI scan result, and return JSON.

bssid / frequency / signal level / flags / ssid

To use 5 binary numbers to represent the above data in order from left to right. For example, RK_wifi_scan_r_sec (0x01) is used to get bssid data, RK_wifi_scan_r_sec (0x10) is used to get ssid data, and RK_wifi_scan_r_sec (0x1F) is used to get all data.

int RK_wifi_connect(const char* ssid, const char* psk)

Connect the specified hotspot by the default WPA encryption method.

int RK_wifi_connect1(const char* ssid, const char* psk, const
RK_WIFI_CONNECTION_Encryp_e encryp, const int hide)

Please see RK_wifi_connect interface for expanding encryption type, ssid hidden parameter.

int RK_wifi_disconnect_network(void)

To disconnect WIFI connection.

int RK_wifi_set_hostname(const char* name)

To configure hostname.

int RK_wifi_get_hostname(char* name, int len)

To get hostname.

int RK_wifi_get_mac(char *wifi_mac)

To get mac address.

int RK_wifi_has_config(void)

To check whether the network been configured.

int RK_wifi_ping(void)

To check whether the network is connected by ping.

3. Application Demo​

1 #include <stdio.h> 2 #include <string.h> 3 #include <DeviceIo/Rk wifi.h> _ 4 5 int RK wifi state callback(RK WIFI RUNNING State e state) _ _ _ _ _ _ _ _ 6 { 7 printf(" RK wifi state callback state:%d\n", state); _ _ _ _ 8 return 0; 9 } 10 11 int main(int argc, char **argv) 12 { 13 // To register WIFI status callback 14 RK wifi register callback( RK wifi state callback); _ _ _ _ _ _ _ 15 16 // To get printing after setting hostname 17 char hostname[16]; 18 RK wifi set hostname("RKWIFI"); _ _ _ 19 memset(hostname, 0, sizeof(hostname)); 20 RK wifi get hostname(hostname, sizeof(hostname)); _ _ _ 21 printf("hostname:%s\n", hostname); 22 23 // To get MAC address and print 24 char mac[32]; 25 memset(mac, 0, sizeof(mac)); 26 RK wifi get mac(mac); _ _ _ 27 printf("mac:%s\n", mac); 28 29 // If you have already configured WIFI, enable the WIFI will automatically connect to the configured WIFI 30 // Otherwise connect to the specified WIFI 31 if (RK wifi has config()) { _ _ _ 32 RK wifi enable(1); _ _ 33 } else { 34 RK wifi enable(1); _ _ 35 RK wifi connect("TP-LINK C734BC", "12345678"); _ _ _ 36 } 37 38 for (;;); 39 // Disconnect WIFI and turn off the WIFI module 40 RK wifi enable(0); _ _ 41 42 return 0; 43 }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43#include <stdio.h> #include <string.h> #include <DeviceIo/Rk wifi.h> _ int RK wifi state callback(RK WIFI RUNNING State e state) _ _ _ _ _ _ _ _ { printf(" RK wifi state callback state:%d\n", state); _ _ _ _ return 0; } int main(int argc, char **argv) { // To register WIFI status callback RK wifi register callback( RK wifi state callback); _ _ _ _ _ _ _ // To get printing after setting hostname char hostname[16]; RK wifi set hostname("RKWIFI"); _ _ _ memset(hostname, 0, sizeof(hostname)); RK wifi get hostname(hostname, sizeof(hostname)); _ _ _ printf("hostname:%s\n", hostname); // To get MAC address and print char mac[32]; memset(mac, 0, sizeof(mac)); RK wifi get mac(mac); _ _ _ printf("mac:%s\n", mac); // If you have already configured WIFI, enable the WIFI will automatically connect to the configured WIFI // Otherwise connect to the specified WIFI if (RK wifi has config()) { _ _ _ RK wifi enable(1); _ _ } else { RK wifi enable(1); _ _ RK wifi connect("TP-LINK C734BC", "12345678"); _ _ _ } for (;;); // Disconnect WIFI and turn off the WIFI module RK wifi enable(0); _ _ return 0; }