Add new features:-
1. AP Auto shut off 2. Energy Detect Threshold Change-Id: I454dd0c999131a0d0910b415cf73590d3458f2ad
This commit is contained in:
@@ -43,6 +43,14 @@ static int rtnl_fd = -1;
|
|||||||
static char evt_buf[MAX_EVT_BUF_SIZE];
|
static char evt_buf[MAX_EVT_BUF_SIZE];
|
||||||
static int evt_len;
|
static int evt_len;
|
||||||
|
|
||||||
|
static void softap_handle_custom_event(char * buf, int len)
|
||||||
|
{
|
||||||
|
if (strncmp(buf, "AUTO-SHUT.indication ", strlen("AUTO-SHUT.indication ")) == 0)
|
||||||
|
{
|
||||||
|
LOGD("EVENT: Custom Event\n");
|
||||||
|
snprintf(evt_buf, sizeof(evt_buf), "105 AP Shutdown");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void softap_handle_associated_event(char *mac_addr)
|
static void softap_handle_associated_event(char *mac_addr)
|
||||||
{
|
{
|
||||||
@@ -70,8 +78,7 @@ static void softap_handle_wireless_event(char *atr, int atrlen)
|
|||||||
if (iwe.len <= IW_EV_LCP_LEN)
|
if (iwe.len <= IW_EV_LCP_LEN)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
LOGD("Received Wireless Event: cmd=0x%x len=%d",
|
LOGD("Received Wireless Event: cmd=0x%x len=%d", iwe.cmd, iwe.len);
|
||||||
iwe.cmd, iwe.len);
|
|
||||||
|
|
||||||
switch (iwe.cmd) {
|
switch (iwe.cmd) {
|
||||||
case IWEVEXPIRED:
|
case IWEVEXPIRED:
|
||||||
@@ -84,6 +91,11 @@ static void softap_handle_wireless_event(char *atr, int atrlen)
|
|||||||
softap_handle_associated_event(iwe.u.addr.sa_data);
|
softap_handle_associated_event(iwe.u.addr.sa_data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IWEVCUSTOM:
|
||||||
|
LOGD("EVENT: Custom Event\n");
|
||||||
|
softap_handle_custom_event(buffer + len + IW_EV_POINT_LEN, iwe.u.data.length);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ s32 wifi_qsap_load_driver(void)
|
|||||||
|
|
||||||
if ( ret != 0 ) {
|
if ( ret != 0 ) {
|
||||||
LOGE("init_module failed sdioif\n");
|
LOGE("init_module failed sdioif\n");
|
||||||
|
ret = eERR_LOAD_FAILED_SDIOIF;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,11 +200,20 @@ s32 wifi_qsap_load_driver(void)
|
|||||||
ret = insmod(WIFI_DRIVER_MODULE_PATH, WIFI_DRIVER_MODULE_ARG, WIFI_DRIVER_MODULE_NAME " ");
|
ret = insmod(WIFI_DRIVER_MODULE_PATH, WIFI_DRIVER_MODULE_ARG, WIFI_DRIVER_MODULE_NAME " ");
|
||||||
|
|
||||||
if ( ret != 0 ) {
|
if ( ret != 0 ) {
|
||||||
|
if ( check_driver_loaded(WIFI_SDIO_IF_DRIVER_MODULE_NAME " ") ) {
|
||||||
|
if ( rmmod(WIFI_SDIO_IF_DRIVER_MODULE_NAME) ) {
|
||||||
|
LOGE("Unable to unload the station mode librasdioif driver\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
LOGE("init_module failed libra_softap\n");
|
LOGE("init_module failed libra_softap\n");
|
||||||
goto end;
|
ret = eERR_LOAD_FAILED_SOFTAP;
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
sched_yield();
|
sched_yield();
|
||||||
|
|
||||||
|
ret = eSUCCESS;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if(system(SDIO_POLLING_OFF)) {
|
if(system(SDIO_POLLING_OFF)) {
|
||||||
LOGE("Could not turn off the polling...");
|
LOGE("Could not turn off the polling...");
|
||||||
@@ -248,7 +258,7 @@ end:
|
|||||||
|
|
||||||
s32 wifi_qsap_unload_driver()
|
s32 wifi_qsap_unload_driver()
|
||||||
{
|
{
|
||||||
s32 ret = 0;
|
s32 ret = eSUCCESS;
|
||||||
|
|
||||||
if(system(SDIO_POLLING_ON)) {
|
if(system(SDIO_POLLING_ON)) {
|
||||||
LOGE("Could not turn on the polling...");
|
LOGE("Could not turn on the polling...");
|
||||||
@@ -257,7 +267,7 @@ s32 wifi_qsap_unload_driver()
|
|||||||
if ( check_driver_loaded(WIFI_DRIVER_MODULE_NAME " ") ) {
|
if ( check_driver_loaded(WIFI_DRIVER_MODULE_NAME " ") ) {
|
||||||
if ( rmmod(WIFI_DRIVER_MODULE_NAME) ) {
|
if ( rmmod(WIFI_DRIVER_MODULE_NAME) ) {
|
||||||
LOGE("Unable to unload the libra_softap driver\n");
|
LOGE("Unable to unload the libra_softap driver\n");
|
||||||
ret = 1;
|
ret = eERR_UNLOAD_FAILED_SOFTAP;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,7 +277,7 @@ s32 wifi_qsap_unload_driver()
|
|||||||
if ( check_driver_loaded(WIFI_SDIO_IF_DRIVER_MODULE_NAME " ") ) {
|
if ( check_driver_loaded(WIFI_SDIO_IF_DRIVER_MODULE_NAME " ") ) {
|
||||||
if ( rmmod(WIFI_SDIO_IF_DRIVER_MODULE_NAME) ) {
|
if ( rmmod(WIFI_SDIO_IF_DRIVER_MODULE_NAME) ) {
|
||||||
LOGE("Unable to unload the librasdioif driver\n");
|
LOGE("Unable to unload the librasdioif driver\n");
|
||||||
ret = 1;
|
ret = eERR_UNLOAD_FAILED_SDIO;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,7 +286,7 @@ end:
|
|||||||
LOGE("Could not turn off the polling...");
|
LOGE("Could not turn off the polling...");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 wifi_qsap_stop_bss(void)
|
s32 wifi_qsap_stop_bss(void)
|
||||||
@@ -291,6 +301,11 @@ s32 wifi_qsap_stop_bss(void)
|
|||||||
struct iwreq wrq;
|
struct iwreq wrq;
|
||||||
struct iw_priv_args *priv_ptr;
|
struct iw_priv_args *priv_ptr;
|
||||||
|
|
||||||
|
if(ENABLE != is_softap_enabled()) {
|
||||||
|
ret = eERR_BSS_NOT_STARTED;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if(NULL == (iface = qsap_get_config_value(CONFIG_FILE, "interface", interface, (u32*)&len))) {
|
if(NULL == (iface = qsap_get_config_value(CONFIG_FILE, "interface", interface, (u32*)&len))) {
|
||||||
LOGE("%s :interface error \n", __func__);
|
LOGE("%s :interface error \n", __func__);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -348,7 +363,7 @@ s32 commit(void)
|
|||||||
|
|
||||||
if ( is_softap_enabled() ) {
|
if ( is_softap_enabled() ) {
|
||||||
/** Stop BSS */
|
/** Stop BSS */
|
||||||
if(eSUCCESS != wifi_qsap_stop_bss()) {
|
if(eSUCCESS != (ret = wifi_qsap_stop_bss())) {
|
||||||
LOGE("%s: stop bss failed \n", __func__);
|
LOGE("%s: stop bss failed \n", __func__);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -372,6 +387,11 @@ s32 wifi_qsap_start_softap()
|
|||||||
|
|
||||||
LOGD("Starting Soft AP...\n");
|
LOGD("Starting Soft AP...\n");
|
||||||
|
|
||||||
|
/* Delete control interface if it was left over because of previous crash */
|
||||||
|
if ( !is_softap_enabled() ) {
|
||||||
|
qsap_del_ctrl_iface();
|
||||||
|
}
|
||||||
|
|
||||||
while(--retry ) {
|
while(--retry ) {
|
||||||
/** Stop hostapd */
|
/** Stop hostapd */
|
||||||
if(0 != property_set("ctl.start", "hostapd")) {
|
if(0 != property_set("ctl.start", "hostapd")) {
|
||||||
@@ -393,18 +413,20 @@ s32 wifi_qsap_start_softap()
|
|||||||
|
|
||||||
s32 wifi_qsap_stop_softap()
|
s32 wifi_qsap_stop_softap()
|
||||||
{
|
{
|
||||||
|
s32 ret = eSUCCESS;
|
||||||
|
|
||||||
if ( is_softap_enabled() ) {
|
if ( is_softap_enabled() ) {
|
||||||
LOGD("Stopping BSS ..... ");
|
LOGD("Stopping BSS ..... ");
|
||||||
|
|
||||||
/** Stop the BSS */
|
/** Stop the BSS */
|
||||||
if (eSUCCESS != wifi_qsap_stop_bss()) {
|
if (eSUCCESS != (ret = wifi_qsap_stop_bss()) ) {
|
||||||
LOGE("failed \n");
|
LOGE("failed \n");
|
||||||
return eERR_STOP_SAP;
|
return ret;
|
||||||
}
|
}
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return eSUCCESS;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 wifi_qsap_reload_softap()
|
s32 wifi_qsap_reload_softap()
|
||||||
@@ -412,23 +434,23 @@ s32 wifi_qsap_reload_softap()
|
|||||||
s32 ret = eERR_RELOAD_SAP;
|
s32 ret = eERR_RELOAD_SAP;
|
||||||
|
|
||||||
/** SDK API to reload the firmware */
|
/** SDK API to reload the firmware */
|
||||||
if (eSUCCESS != wifi_qsap_stop_softap()) {
|
if (eSUCCESS != (ret = wifi_qsap_stop_softap())) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eSUCCESS != wifi_qsap_unload_driver()) {
|
if (eSUCCESS != (ret = wifi_qsap_unload_driver())) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(500000);
|
usleep(500000);
|
||||||
|
|
||||||
if (eSUCCESS != wifi_qsap_load_driver()) {
|
if (eSUCCESS != (ret = wifi_qsap_load_driver())) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
if (eSUCCESS != wifi_qsap_start_softap()) {
|
if (eSUCCESS != (ret = wifi_qsap_start_softap())) {
|
||||||
wifi_qsap_unload_driver();
|
wifi_qsap_unload_driver();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
#define QCSAP_IOCTL_GET_CHANNEL (SIOCIWFIRSTPRIV+9)
|
#define QCSAP_IOCTL_GET_CHANNEL (SIOCIWFIRSTPRIV+9)
|
||||||
#define QCSAP_IOCTL_ASSOC_STA_MACADDR (SIOCIWFIRSTPRIV+10)
|
#define QCSAP_IOCTL_ASSOC_STA_MACADDR (SIOCIWFIRSTPRIV+10)
|
||||||
#define QCSAP_IOCTL_DISASSOC_STA (SIOCIWFIRSTPRIV+11)
|
#define QCSAP_IOCTL_DISASSOC_STA (SIOCIWFIRSTPRIV+11)
|
||||||
|
#define QCSAP_IOCTL_AP_STATS (SIOCIWFIRSTPRIV+12)
|
||||||
|
|
||||||
//#define LOG_TAG "QCSDK-"
|
//#define LOG_TAG "QCSDK-"
|
||||||
|
|
||||||
@@ -134,6 +135,9 @@ static s8 *cmd_list[eCMD_LAST] = {
|
|||||||
"country_code",
|
"country_code",
|
||||||
"intra_bss_forward",
|
"intra_bss_forward",
|
||||||
"regulatory_domain",
|
"regulatory_domain",
|
||||||
|
"apstat",
|
||||||
|
"auto_shut_off_time",
|
||||||
|
"energy_detect_threshold",
|
||||||
};
|
};
|
||||||
|
|
||||||
static s8 *qsap_str[eSTR_LAST] = {
|
static s8 *qsap_str[eSTR_LAST] = {
|
||||||
@@ -153,7 +157,9 @@ static s8 *qsap_str[eSTR_LAST] = {
|
|||||||
"ieee80211n",
|
"ieee80211n",
|
||||||
"ctrl_interface",
|
"ctrl_interface",
|
||||||
"interface",
|
"interface",
|
||||||
"eap_server"
|
"eap_server",
|
||||||
|
"gAPAutoShutOff",
|
||||||
|
"gEnablePhyAgcListenMode",
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Supported operating mode */
|
/** Supported operating mode */
|
||||||
@@ -775,7 +781,7 @@ static void qsap_remove_from_file(s8 *pfile, s8 *pVal, s8 *presp, u32 *plen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(MAX_CONF_LINE_LEN == snprintf(buf, MAX_CONF_LINE_LEN, "%s~", pfile)) {
|
if(MAX_CONF_LINE_LEN == snprintf(buf, MAX_CONF_LINE_LEN, "%s~", pfile)) {
|
||||||
buf[MAX_CONF_LINE_LEN] = '\0';
|
buf[MAX_CONF_LINE_LEN-1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Open a temporary file */
|
/** Open a temporary file */
|
||||||
@@ -827,7 +833,7 @@ static void qsap_remove_from_file(s8 *pfile, s8 *pVal, s8 *presp, u32 *plen)
|
|||||||
fclose(ftmp);
|
fclose(ftmp);
|
||||||
|
|
||||||
if(MAX_CONF_LINE_LEN == snprintf(buf, MAX_CONF_LINE_LEN, "%s~", pfile)) {
|
if(MAX_CONF_LINE_LEN == snprintf(buf, MAX_CONF_LINE_LEN, "%s~", pfile)) {
|
||||||
buf[MAX_CONF_LINE_LEN] = '\0';
|
buf[MAX_CONF_LINE_LEN-1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Restore the configuration file */
|
/** Restore the configuration file */
|
||||||
@@ -1106,6 +1112,10 @@ int qsap_get_operating_channel(s32 *pchan)
|
|||||||
s8 *pif;
|
s8 *pif;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if(ENABLE != is_softap_enabled()) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if(NULL == (pif = qsap_get_config_value(pconffile, qsap_str[STR_INTERFACE], interface, &len))) {
|
if(NULL == (pif = qsap_get_config_value(pconffile, qsap_str[STR_INTERFACE], interface, &len))) {
|
||||||
LOGE("%s :interface error \n", __func__);
|
LOGE("%s :interface error \n", __func__);
|
||||||
goto error;
|
goto error;
|
||||||
@@ -1209,6 +1219,10 @@ void qsap_get_associated_sta_mac(s8 *presp, u32 *plen)
|
|||||||
u32 recvLen;
|
u32 recvLen;
|
||||||
u32 tlen;
|
u32 tlen;
|
||||||
|
|
||||||
|
if(ENABLE != is_softap_enabled()) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if(NULL == (pif = qsap_get_config_value(pconffile, qsap_str[STR_INTERFACE], interface, &len))) {
|
if(NULL == (pif = qsap_get_config_value(pconffile, qsap_str[STR_INTERFACE], interface, &len))) {
|
||||||
LOGE("%s :interface error \n", __func__);
|
LOGE("%s :interface error \n", __func__);
|
||||||
goto error;
|
goto error;
|
||||||
@@ -1290,6 +1304,90 @@ static void qsap_read_wep_key(s8 *pfile, s8 *pcmd, s8 *presp, u32 *plen, s8 *var
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qsap_read_ap_stats(s8 *presp, u32 *plen)
|
||||||
|
{
|
||||||
|
int sock, ret;
|
||||||
|
struct iwreq wrq;
|
||||||
|
s8 interface[MAX_CONF_LINE_LEN];
|
||||||
|
u32 len = MAX_CONF_LINE_LEN;
|
||||||
|
s8 *pif;
|
||||||
|
s8 *pbuf, *pout;
|
||||||
|
u32 recvLen;
|
||||||
|
u32 tlen;
|
||||||
|
|
||||||
|
if(ENABLE != is_softap_enabled()) {
|
||||||
|
*plen = snprintf(presp, *plen, "%s", ERR_SOFTAP_NOT_STARTED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(NULL == (pif = qsap_get_config_value(pconffile, qsap_str[STR_INTERFACE], interface, &len))) {
|
||||||
|
LOGE("%s :interface error \n", __func__);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
interface[len] = '\0';
|
||||||
|
|
||||||
|
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
if(sock < 0) {
|
||||||
|
LOGE("%s :socket failure \n", __func__);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
pbuf = (s8 *)malloc(MAX_RESP_LEN);
|
||||||
|
if(NULL == pbuf) {
|
||||||
|
LOGE("%s :No memory \n", __func__);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(wrq.ifr_name, pif, sizeof(wrq.ifr_name));
|
||||||
|
wrq.u.data.length = MAX_RESP_LEN;
|
||||||
|
wrq.u.data.pointer = (void *)pbuf;
|
||||||
|
wrq.u.data.flags = 0;
|
||||||
|
|
||||||
|
ret = ioctl(sock, QCSAP_IOCTL_AP_STATS, &wrq);
|
||||||
|
if(ret < 0) {
|
||||||
|
LOGE("%s :ioctl failure \n", __func__);
|
||||||
|
free(pbuf);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*plen == (recvLen = snprintf(presp, *plen, "%s %s=%s", SUCCESS, cmd_list[eCMD_AP_STATISTICS], pbuf))){
|
||||||
|
presp[recvLen-1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
*plen = recvLen;
|
||||||
|
|
||||||
|
free(pbuf);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
error:
|
||||||
|
*plen = snprintf(presp, *plen, "%s", ERR_UNKNOWN);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void qsap_read_autoshutoff(s8 *presp, u32 *plen)
|
||||||
|
{
|
||||||
|
u32 tlen, time = 0;
|
||||||
|
s8 *ptime;
|
||||||
|
|
||||||
|
tlen = *plen;
|
||||||
|
|
||||||
|
if(NULL == (ptime = qsap_get_config_value(fIni, qsap_str[STR_AP_AUTOSHUTOFF], presp, &tlen))) {
|
||||||
|
/** unable to read the AP shutoff time */
|
||||||
|
LOGE("%s :Failed to read AP shutoff time\n", __func__);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
time = atoi(ptime);
|
||||||
|
time = time / 60; /** Convert seconds to minutes */
|
||||||
|
}
|
||||||
|
|
||||||
|
*plen = snprintf(presp, *plen, "success %s=%ld", cmd_list[eCMD_AP_AUTOSHUTOFF], time);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
* Get the configuration information from the softAP configuration
|
* Get the configuration information from the softAP configuration
|
||||||
@@ -1429,6 +1527,18 @@ static void qsap_get_from_config(esap_cmd_t cNum, s8 *presp, u32 *plen)
|
|||||||
qsap_read_cfg(fIni, qsap_str[STR_COUNTRY_CODE_IN_INI], presp, plen, cmd_list[eCMD_COUNTRY_CODE], GET_ENABLED_ONLY);
|
qsap_read_cfg(fIni, qsap_str[STR_COUNTRY_CODE_IN_INI], presp, plen, cmd_list[eCMD_COUNTRY_CODE], GET_ENABLED_ONLY);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case eCMD_AP_STATISTICS:
|
||||||
|
qsap_read_ap_stats(presp, plen);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case eCMD_AP_AUTOSHUTOFF:
|
||||||
|
qsap_read_autoshutoff(presp, plen);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case eCMD_AP_ENERGY_DETECT_TH:
|
||||||
|
qsap_read_cfg(fIni, qsap_str[STR_AP_ENERGY_DETECT_TH], presp, plen, cmd_list[eCMD_AP_ENERGY_DETECT_TH], GET_ENABLED_ONLY);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/** Error case */
|
/** Error case */
|
||||||
*plen = snprintf(presp, *plen, "%s", ERR_INVALID_ARG);
|
*plen = snprintf(presp, *plen, "%s", ERR_INVALID_ARG);
|
||||||
@@ -1576,7 +1686,7 @@ static s16 wifi_qsap_reset_to_default(s8 *pcfgfile, s8 *pdefault)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(MAX_CONF_LINE_LEN == snprintf(buf, MAX_CONF_LINE_LEN, "%s~", pcfgfile)) {
|
if(MAX_CONF_LINE_LEN == snprintf(buf, MAX_CONF_LINE_LEN, "%s~", pcfgfile)) {
|
||||||
buf[MAX_CONF_LINE_LEN] = '\0';
|
buf[MAX_CONF_LINE_LEN-1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
ftmp = fopen(buf, "w+");
|
ftmp = fopen(buf, "w+");
|
||||||
@@ -1594,7 +1704,7 @@ static s16 wifi_qsap_reset_to_default(s8 *pcfgfile, s8 *pdefault)
|
|||||||
fclose(ftmp);
|
fclose(ftmp);
|
||||||
|
|
||||||
if(MAX_CONF_LINE_LEN == snprintf(buf, MAX_CONF_LINE_LEN, "%s~", pcfgfile)) {
|
if(MAX_CONF_LINE_LEN == snprintf(buf, MAX_CONF_LINE_LEN, "%s~", pcfgfile)) {
|
||||||
buf[MAX_CONF_LINE_LEN] = '\0';
|
buf[MAX_CONF_LINE_LEN-1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(eERR_UNKNOWN == rename(buf, pcfgfile))
|
if(eERR_UNKNOWN == rename(buf, pcfgfile))
|
||||||
@@ -1607,6 +1717,39 @@ static s16 wifi_qsap_reset_to_default(s8 *pcfgfile, s8 *pdefault)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define CTRL_IFACE_PATH_LEN (128)
|
#define CTRL_IFACE_PATH_LEN (128)
|
||||||
|
|
||||||
|
void qsap_del_ctrl_iface(void)
|
||||||
|
{
|
||||||
|
u32 len;
|
||||||
|
s8 dst_path[CTRL_IFACE_PATH_LEN], *pcif, *pif;
|
||||||
|
s8 interface[64];
|
||||||
|
s8 path[CTRL_IFACE_PATH_LEN + 64];
|
||||||
|
|
||||||
|
len = CTRL_IFACE_PATH_LEN;
|
||||||
|
|
||||||
|
if(NULL == (pcif = qsap_get_config_value(pconffile, qsap_str[STR_CTRL_INTERFACE], dst_path, &len))) {
|
||||||
|
LOGE("%s :ctrl_iface path error \n", __func__);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = 64;
|
||||||
|
|
||||||
|
if(NULL == (pif = qsap_get_config_value(pconffile, qsap_str[STR_INTERFACE], interface, &len))) {
|
||||||
|
LOGE("%s :interface error \n", __func__);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((int)sizeof(path) <= snprintf(path, sizeof(path)-1, "%s/%s", pcif, pif)) {
|
||||||
|
LOGE("Iface path : error, %s \n", path);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
unlink(path);
|
||||||
|
|
||||||
|
error:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static int qsap_send_cmd_to_hostapd(s8 *pcmd)
|
static int qsap_send_cmd_to_hostapd(s8 *pcmd)
|
||||||
{
|
{
|
||||||
int sock;
|
int sock;
|
||||||
@@ -1895,6 +2038,10 @@ void qsap_disassociate_sta(s8 *pVal, s8 *presp, u32 *plen)
|
|||||||
u32 len = MAX_CONF_LINE_LEN;
|
u32 len = MAX_CONF_LINE_LEN;
|
||||||
s8 *pif;
|
s8 *pif;
|
||||||
|
|
||||||
|
if(ENABLE != is_softap_enabled()) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
if(NULL == (pif = qsap_get_config_value(pconffile, qsap_str[STR_INTERFACE], pbuf, &len))) {
|
if(NULL == (pif = qsap_get_config_value(pconffile, qsap_str[STR_INTERFACE], pbuf, &len))) {
|
||||||
LOGE("%s :interface error \n", __func__);
|
LOGE("%s :interface error \n", __func__);
|
||||||
goto end;
|
goto end;
|
||||||
@@ -2561,6 +2708,26 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen)
|
|||||||
ini = INI_CONF_FILE;
|
ini = INI_CONF_FILE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case eCMD_AP_AUTOSHUTOFF:
|
||||||
|
value = atoi(pVal);
|
||||||
|
if(TRUE != IS_VALID_APSHUTOFFTIME(value))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
snprintf(pVal, MAX_INT_STR, "%ld", value*60);
|
||||||
|
cNum = STR_AP_AUTOSHUTOFF;
|
||||||
|
ini = INI_CONF_FILE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case eCMD_AP_ENERGY_DETECT_TH:
|
||||||
|
value = atoi(pVal);
|
||||||
|
if(TRUE != IS_VALID_ENERGY_DETECT_TH(value))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
snprintf(pVal, MAX_INT_STR, "%ld", value);
|
||||||
|
cNum = STR_AP_ENERGY_DETECT_TH;
|
||||||
|
ini = INI_CONF_FILE;
|
||||||
|
break;
|
||||||
|
|
||||||
default: ;
|
default: ;
|
||||||
/** Do not goto error, in default case */
|
/** Do not goto error, in default case */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,22 +43,24 @@ typedef unsigned long int u32;
|
|||||||
typedef signed long int s32;
|
typedef signed long int s32;
|
||||||
|
|
||||||
/** Success and error messages */
|
/** Success and error messages */
|
||||||
#define SUCCESS "success"
|
#define SUCCESS "success"
|
||||||
#define ERR_INVALID_ARG "failure invalid arguments"
|
#define ERR_INVALID_ARG "failure invalid arguments"
|
||||||
#define ERR_INVALID_PARAM "failure invalid parameter"
|
#define ERR_INVALID_PARAM "failure invalid parameter"
|
||||||
#define ERR_UNKNOWN "failure unknown error"
|
#define ERR_UNKNOWN "failure unknown error"
|
||||||
#define ERR_INVALIDCMD "failure invalid command"
|
#define ERR_INVALIDCMD "failure invalid command"
|
||||||
#define ERR_INVALIDREQ "failure invalid request"
|
#define ERR_INVALIDREQ "failure invalid request"
|
||||||
#define ERR_FEATURE_NOT_ENABLED "failure feature not enabled"
|
#define ERR_FEATURE_NOT_ENABLED "failure feature not enabled"
|
||||||
#define ERR_NOT_SUPPORTED "failure not supported"
|
#define ERR_NOT_SUPPORTED "failure not supported"
|
||||||
#define ERR_NOT_READY "failure not ready"
|
#define ERR_NOT_READY "failure not ready"
|
||||||
#define ERR_RES_UNAVAILABLE "failure resource unavailable"
|
#define ERR_RES_UNAVAILABLE "failure resource unavailable"
|
||||||
|
#define ERR_SOFTAP_NOT_STARTED "failure softap not started"
|
||||||
|
|
||||||
/** Error numbers used with the SDK */
|
/** Error numbers used with the SDK */
|
||||||
enum error_val {
|
enum error_val {
|
||||||
eERR_UNKNOWN = -1,
|
eERR_UNKNOWN = -1,
|
||||||
eSUCCESS = 0,
|
eSUCCESS = 0,
|
||||||
eERR_STOP_BSS,
|
eERR_STOP_BSS,
|
||||||
|
eERR_BSS_NOT_STARTED,
|
||||||
eERR_COMMIT,
|
eERR_COMMIT,
|
||||||
eERR_START_SAP,
|
eERR_START_SAP,
|
||||||
eERR_STOP_SAP,
|
eERR_STOP_SAP,
|
||||||
@@ -69,7 +71,11 @@ enum error_val {
|
|||||||
eERR_SEND_TO_HOSTAPD,
|
eERR_SEND_TO_HOSTAPD,
|
||||||
eERR_CONFIG_PARAM_MISSING,
|
eERR_CONFIG_PARAM_MISSING,
|
||||||
eERR_CHAN_READ,
|
eERR_CHAN_READ,
|
||||||
eERR_FEATURE_NOT_ENABLED
|
eERR_FEATURE_NOT_ENABLED,
|
||||||
|
eERR_UNLOAD_FAILED_SDIO,
|
||||||
|
eERR_UNLOAD_FAILED_SOFTAP,
|
||||||
|
eERR_LOAD_FAILED_SDIOIF,
|
||||||
|
eERR_LOAD_FAILED_SOFTAP
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Soft AP SDK version */
|
/** Soft AP SDK version */
|
||||||
@@ -207,6 +213,16 @@ enum error_val {
|
|||||||
#define GET_COMMENTED_VALUE 1
|
#define GET_COMMENTED_VALUE 1
|
||||||
#define GET_ENABLED_ONLY 0
|
#define GET_ENABLED_ONLY 0
|
||||||
|
|
||||||
|
#define MAX_RESP_LEN 255
|
||||||
|
|
||||||
|
/** AP shutoff time */
|
||||||
|
#define AP_SHUTOFF_MIN (0)
|
||||||
|
#define AP_SHUTOFF_MAX (120)
|
||||||
|
|
||||||
|
/** AP shutoff time */
|
||||||
|
#define AP_ENERGY_DETECT_TH_MIN (0)
|
||||||
|
#define AP_ENERGY_DETECT_TH_MAX (100)
|
||||||
|
|
||||||
/** command request index - in the array Cmd_req[] */
|
/** command request index - in the array Cmd_req[] */
|
||||||
enum eCmd_req {
|
enum eCmd_req {
|
||||||
eCMD_GET = 0,
|
eCMD_GET = 0,
|
||||||
@@ -285,6 +301,9 @@ typedef enum esap_cmd {
|
|||||||
eCMD_COUNTRY_CODE = 53,
|
eCMD_COUNTRY_CODE = 53,
|
||||||
eCMD_INTRA_BSS_FORWARD = 54,
|
eCMD_INTRA_BSS_FORWARD = 54,
|
||||||
eCMD_REGULATORY_DOMAIN = 55,
|
eCMD_REGULATORY_DOMAIN = 55,
|
||||||
|
eCMD_AP_STATISTICS = 56,
|
||||||
|
eCMD_AP_AUTOSHUTOFF = 57,
|
||||||
|
eCMD_AP_ENERGY_DETECT_TH = 58,
|
||||||
|
|
||||||
eCMD_LAST /** New command numbers should be added above this */
|
eCMD_LAST /** New command numbers should be added above this */
|
||||||
} esap_cmd_t;
|
} esap_cmd_t;
|
||||||
@@ -308,6 +327,8 @@ typedef enum esap_str {
|
|||||||
STR_CTRL_INTERFACE = 14,
|
STR_CTRL_INTERFACE = 14,
|
||||||
STR_INTERFACE = 15,
|
STR_INTERFACE = 15,
|
||||||
STR_EAP_SERVER = 16,
|
STR_EAP_SERVER = 16,
|
||||||
|
STR_AP_AUTOSHUTOFF = 17,
|
||||||
|
STR_AP_ENERGY_DETECT_TH = 18,
|
||||||
eSTR_LAST
|
eSTR_LAST
|
||||||
} esap_str_t;
|
} esap_str_t;
|
||||||
|
|
||||||
@@ -495,10 +516,17 @@ enum eChoose_conf_file {
|
|||||||
/** Validate the 802dot11d state */
|
/** Validate the 802dot11d state */
|
||||||
#define IS_VALID_802DOT11D_STATE(x) (((x == ENABLE) || (x == DISABLE)) ? TRUE: FALSE)
|
#define IS_VALID_802DOT11D_STATE(x) (((x == ENABLE) || (x == DISABLE)) ? TRUE: FALSE)
|
||||||
|
|
||||||
|
/** Validate the AP shutoff time */
|
||||||
|
#define IS_VALID_APSHUTOFFTIME(x) (((x >= AP_SHUTOFF_MIN) && (x <= AP_SHUTOFF_MAX)) ? TRUE : FALSE)
|
||||||
|
|
||||||
|
/** Validate the AP shutoff time */
|
||||||
|
#define IS_VALID_ENERGY_DETECT_TH(x) (((x >= AP_ENERGY_DETECT_TH_MIN) && (x <= AP_ENERGY_DETECT_TH_MAX)) ? TRUE : FALSE)
|
||||||
|
|
||||||
/** Function declartion */
|
/** Function declartion */
|
||||||
void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen);
|
void qsap_hostd_exec_cmd(s8 *pcmd, s8 *presp, u32 *plen);
|
||||||
s8 *qsap_get_config_value(s8 *pfile, s8 *pcmd, s8 *pbuf, u32 *plen);
|
s8 *qsap_get_config_value(s8 *pfile, s8 *pcmd, s8 *pbuf, u32 *plen);
|
||||||
int qsapsetSoftap(int argc, char *argv[]);
|
int qsapsetSoftap(int argc, char *argv[]);
|
||||||
|
void qsap_del_ctrl_iface(void);
|
||||||
|
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}; // extern "C"
|
}; // extern "C"
|
||||||
|
|||||||
Reference in New Issue
Block a user