你好 cc3200 sl_WlanProfileAdd 把ssid 和 password添加到配置文件中
1.请问可以添加多个吗?
2.怎么判断是否有配置文件?
3.上电后 如果有配置文件 会自动连接吗?不需要执行sl_WlanConnect吗?
谢谢!
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
你好 cc3200 sl_WlanProfileAdd 把ssid 和 password添加到配置文件中
1.请问可以添加多个吗?
2.怎么判断是否有配置文件?
3.上电后 如果有配置文件 会自动连接吗?不需要执行sl_WlanConnect吗?
谢谢!
你好:
1.如果配置多个策略 是否是把addprofile的参数Priority 更改下,如果Priority值是一样的 那么就会覆盖吧?
2.profile文件存在flash中 那么怎么去判断profle文件中是否有存入ssid和password呢? 有read的接口吗
3.上电后 自动连接 这个是在代码中哪里执行的,或者说 连接ap之后 会有什么接口回调吗(便于判断是否连接成功)
谢谢!
static long SetConnectionPolicy() { unsigned char policyVal; long lRetVal = -1; /* Clear all stored profiles and reset the policies */ lRetVal = sl_WlanProfileDel(0xFF); ASSERT_ON_ERROR(lRetVal); lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(0,0,0,0,0), 0, 0); ASSERT_ON_ERROR(lRetVal); //Add Profile /* user needs to change SSID_NAME = "<Secured AP>" SECURITY_TYPE = SL_SEC_TYPE_WPA SECURITY_KEY = "<password>" and set the priority as per requirement to connect with a secured AP */ SlSecParams_t secParams; secParams.Key = SECURITY_KEY; secParams.KeyLen = strlen(SECURITY_KEY); secParams.Type = SECURITY_TYPE; lRetVal = sl_WlanProfileAdd(SSID_NAME,strlen(SSID_NAME),0,&secParams,0,1,0); ASSERT_ON_ERROR(lRetVal); //set AUTO policy lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1,0,0,0,0), &policyVal, 1 /*PolicyValLen*/); ASSERT_ON_ERROR(lRetVal); while(1) { //wait until IP is acquired while((!IS_CONNECTED(g_ulStatus)) || (!IS_IP_ACQUIRED(g_ulStatus))) { _SlNonOsMainLoopTask(); } UART_PRINT("\n\r===>>> Device connected to AP\n\r"); // Wait while(IS_CONNECTED(g_ulStatus)) { _SlNonOsMainLoopTask(); } CLR_STATUS_BIT(g_ulStatus, STATUS_BIT_CONNECTION); CLR_STATUS_BIT(g_ulStatus, STATUS_BIT_IP_AQUIRED); UART_PRINT("\n\r===>>> Device disconnected from AP\n\r"); } } ************************************************* CC3200 CONNECTION_POLICY Application ************************************************* Host Driver Version: 1.0.0.1 Build Version 2.2.0.1.31.1.2.0.2.1.0.3.23 Device is configured in default state Device started as STATION [WLAN EVENT] STA Connected to the AP: TP-LINK-APK2 ,BSSID: a0:f3:c1:b1:d6:6e [NETAPP EVENT] IP Acquired: IP=192.168.0.100 , Gateway=192.168.0.1 ===>>> Device connected to AP [WLAN ERROR]Device disconnected from the AP AP: TP-LINK-APK2,BSSID: a0:f3:c1:b1:d6:6e on an ERROR..!! ===>>> Device disconnected from AP [WLAN EVENT] STA Connected to the AP: TP-LINK-APK2 ,BSSID: a0:f3:c1:b1:d6:6e [NETAPP EVENT] IP Acquired: IP=192.168.0.100 , Gateway=192.168.0.1 ===>>> Device connected to AP [WLAN ERROR]Device disconnected from the AP AP: TP-LINK-APK2,BSSID: a0:f3:c1:b1:d6:6e on an ERROR..!! ===>>> Device disconnected from AP [WLAN EVENT] STA Connected to the AP: TP-LINK-APK2 ,BSSID: a0:f3:c1:b1:d6:6e [WLAN ERROR]Device disconnected from the AP AP: TP-LINK-APK2,BSSID: a0:f3:c1:b1:d6:6e on an ERROR..!! [WLAN EVENT] STA Connected to the AP: TP-LINK-APK2 ,BSSID: a0:f3:c1:b1:d6:6e [NETAPP EVENT] IP Acquired: IP=192.168.0.100 , Gateway=192.168.0.1 ===>>> Device connected to AP [WLAN ERROR]Device disconnected from the AP AP: TP-LINK-APK2,BSSID: a0:f3:c1:b1:d6:6e on an ERROR..!! ===>>> Device disconnected from AP [WLAN EVENT] STA Connected to the AP: TP-LINK-APK2 ,BSSID: a0:f3:c1:b1:d6:6e [NETAPP EVENT] IP Acquired: IP=192.168.0.100 , Gateway=192.168.0.1 ===>>> Device connected to AP
优先级可以一样, 以通过API调用(sl_WlanProfileAdd,sl_WlanProfileDel,sl_WlanProfileGet)管理连接配置文件,
但是get时不允许获取密码,这是用户无法操作的。你各种状态都有对应的event SL_WLAN_CONNECT_EVENT
你好 关于 断电之前 add profile了
但是上电后 程序里什么都不操作
1.直接执行main方法 这样 不能触发联网操作
2.尝试上电后 在main里面执行lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(1,0,0,0,0),NULL, 1 /*PolicyValLen*/);
还是不能联网。
所以想问下 存profile之后 断电开机 需要在main里面执行什么 才会触发联网
user5951870 说:你好 关于 断电之前 add profile了
但是上电后 程序里什么都不操作
1.直接执行main方法 这样 不能触发联网操作
2.尝试上电后 在main里面执行lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(1,0,0,0,0),NULL, 1 /*PolicyValLen*/);
还是不能联网。
所以想问下 存profile之后 断电开机 需要在main里面执行什么 才会触发联网
这个问题有人回复吗
log 不知道 怎么抓取 程序是在调用 setpolicy 之前有 的 sl_Start(0,0,0)函数 执行失败了 这个函数的返回值是1
开机上电后的程序是(在main函数中 执行 sl_Start(0,0,0) 再执行setpolicy)
问题1:执行sl_Start之前需要什么必要操作吗? 为什么会调用这个失败
现在目的就是 profile之前add上了 想在开机后 自动连接Ap
首先没有API可以在 sl_Start()之前调用,你的操作时对的,你需要先sl_Start 然后setpolicy。sl_Start 为 1 ROLE_UNKNOWN ,你怎么启动的?
mode = sl_Start(0, 0, 0);
if (mode < 0)
{
Display_printf(display, 0, 0,"\n\r[line:%d, error code:%d] %s\n\r", __LINE__, mode, DEVICE_ERROR);
}
if(mode != ROLE_STA)
{
/* Set NWP role as STA */
mode = sl_WlanSetMode(ROLE_STA);
if (mode < 0)
{
Display_printf(display, 0, 0,"\n\r[line:%d, error code:%d] %s\n\r", __LINE__, mode, WLAN_ERROR);
}
/* For changes to take affect, we restart the NWP */
status = sl_Stop(SL_STOP_TIMEOUT);
if (status < 0)
{
Display_printf(display, 0, 0,"\n\r[line:%d, error code:%d] %s\n\r", __LINE__, status, DEVICE_ERROR);
}
mode = sl_Start(0, 0, 0);
if (mode < 0)
{
Display_printf(display, 0, 0,"\n\r[line:%d, error code:%d] %s\n\r", __LINE__, mode, DEVICE_ERROR);
}
}
if(mode != ROLE_STA)
{
printError("Failed to configure device to it's default state", mode);
}
SetConnectionPolicy
我是怀疑你是否add 成功了。