void printVersionInfo() { // get the host driver version information SlVersionFull ver; unsigned char configOptOpt = SL_DEVICE_GENERAL_VERSION; unsigned char configOptLen = sizeof(SlVersionFull); memset(&ver, 0, configOptLen); short status = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &configOptOpt, &configOptLen, (unsigned char *)(&ver)); if(status >= 0) { UART_PRINT("[QuickStart] Host Driver Version : %s\r\n", SL_DRIVER_VERSION); UART_PRINT("[QuickStart] Rom Version : %u\r\n", ver.RomVersion); UART_PRINT("[QuickStart] Chip ID : %u\r\n", ver.ChipFwAndPhyVersion.ChipId); UART_PRINT("[QuickStart] Network Processor Version : %lu.%lu.%lu.%lu\r\n", ver.NwpVersion[0], ver.NwpVersion[1], ver.NwpVersion[2], ver.NwpVersion[3]); UART_PRINT("[QuickStart] MAC Version : %lu.%lu.%lu.%lu\r\n", ver.ChipFwAndPhyVersion.FwVersion[0], ver.ChipFwAndPhyVersion.FwVersion[1], ver.ChipFwAndPhyVersion.FwVersion[2], ver.ChipFwAndPhyVersion.FwVersion[3]); UART_PRINT("[QuickStart] PHY Version : %lu.%lu.%lu.%lu\r\n", ver.ChipFwAndPhyVersion.PhyVersion[0], ver.ChipFwAndPhyVersion.PhyVersion[1], ver.ChipFwAndPhyVersion.PhyVersion[2], ver.ChipFwAndPhyVersion.PhyVersion[3]); } }
static void mg_init(struct mg_mgr *mgr) { LOG(LL_INFO, ("MG task running")); stop_nwp(); /* See function description in wifi.c */ LOG(LL_INFO, ("Starting NWP...")); int role = sl_Start(0, 0, 0); if (role < 0) { LOG(LL_ERROR, ("Failed to start NWP")); return; } { SlVersionFull ver; unsigned char opt = SL_DEVICE_GENERAL_VERSION; unsigned char len = sizeof(ver); memset(&ver, 0, sizeof(ver)); sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &opt, &len, (unsigned char *) (&ver)); LOG(LL_INFO, ("NWP v%d.%d.%d.%d started, host v%d.%d.%d.%d", ver.NwpVersion[0], ver.NwpVersion[1], ver.NwpVersion[2], ver.NwpVersion[3], SL_MAJOR_VERSION_NUM, SL_MINOR_VERSION_NUM, SL_VERSION_NUM, SL_SUB_VERSION_NUM)); } GPIO_IF_LedToggle(MCU_RED_LED_GPIO); data_init_sensors(TMP006_ADDR, BM222_ADDR); sl_fs_init(); #if defined(WIFI_STA_SSID) if (!wifi_setup_sta(WIFI_STA_SSID, WIFI_STA_PASS)) { LOG(LL_ERROR, ("Error setting up WiFi station")); } #elif defined(WIFI_AP_SSID) if (!wifi_setup_ap(WIFI_AP_SSID, WIFI_AP_PASS, WIFI_AP_CHAN)) { LOG(LL_ERROR, ("Error setting up WiFi AP")); } #else #error WiFi not configured #endif /* We don't need SimpleLink's web server. */ sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID); const char *err = ""; struct mg_bind_opts opts; memset(&opts, 0, sizeof(opts)); opts.error_string = &err; struct mg_connection *nc = mg_bind_opt(mgr, "80", mg_ev_handler, opts); if (nc != NULL) { mg_set_protocol_http_websocket(nc); nc->ev_timer_time = mg_time(); /* Start data collection */ } else { LOG(LL_ERROR, ("Failed to create listener: %s", err)); } }
//***************************************************************************** //! getDeviceTimeDate //! //! Gets the device time and date //! //! Returns: On success, zero is returned. On error, -1 is returned //! //**************************************************************************** int getDeviceTimeDate() { int iretVal; //dateTime = {0}; unsigned char configLen = (unsigned char)sizeof(SlDateTime_t); unsigned char configOpt = (unsigned char)SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME; iretVal = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &configOpt, &configLen, (unsigned char *)&dateTime); return iretVal; }
void fetchDeviceOSVersion(char *buf, size_t bufLen) { int status = -1; unsigned char configOpt = SL_DEVICE_GENERAL_VERSION; unsigned char configLen = sizeof(SlVersionFull); SlVersionFull ver; memset(&ver, 0, configLen); status = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &configOpt, &configLen, (unsigned char *)(&ver)); if(status >= 0) { snprintf(buf, bufLen, "%lu.%lu.%lu.%lu", ver.NwpVersion[0], ver.NwpVersion[1], ver.NwpVersion[2], ver.NwpVersion[3]); } }
//***************************************************************************** // //! \brief The Function gets the network firmware info //! //! \param[out] sVersion - Pointer to SlVersionFull Info structure //! //! \return None //! //***************************************************************************** long NetFwInfoGet(SlVersionFull *sVersion) { unsigned long lRetVal; unsigned char ucConfigOpt = 0; unsigned char ucConfigLen = 0; // // Get the device's version-information // ucConfigOpt = SL_DEVICE_GENERAL_VERSION; ucConfigLen = sizeof(SlVersionFull); lRetVal = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &ucConfigOpt, &ucConfigLen, (unsigned char *)(sVersion)); return lRetVal; }
int start_nwp() { int r = sl_Start(NULL, NULL, NULL); if (r < 0) return r; SlVersionFull ver; unsigned char opt = SL_DEVICE_GENERAL_VERSION; unsigned char len = sizeof(ver); memset(&ver, 0, sizeof(ver)); sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &opt, &len, (unsigned char *) (&ver)); LOG(LL_INFO, ("NWP v%d.%d.%d.%d started, host driver v%d.%d.%d.%d", ver.NwpVersion[0], ver.NwpVersion[1], ver.NwpVersion[2], ver.NwpVersion[3], SL_MAJOR_VERSION_NUM, SL_MINOR_VERSION_NUM, SL_VERSION_NUM, SL_SUB_VERSION_NUM)); return 0; }
//--tested, working--// const char* WiFiClass::firmwareVersion() { unsigned char ucConfigOpt = 0; unsigned char ucConfigLen = 0; SlVersionFull ver = {0}; ucConfigOpt = SL_DEVICE_GENERAL_VERSION; ucConfigLen = sizeof(ver); sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &ucConfigOpt, &ucConfigLen, (unsigned char *)(&ver)); snprintf(fwVersion, sizeof(fwVersion), "%ld.%ld.%ld.%ld:%ld.%ld.%ld.%ld:%d.%d.%d.%d", ver.NwpVersion[0], ver.NwpVersion[1], ver.NwpVersion[2], ver.NwpVersion[3], ver.ChipFwAndPhyVersion.FwVersion[0], ver.ChipFwAndPhyVersion.FwVersion[1], ver.ChipFwAndPhyVersion.FwVersion[2], ver.ChipFwAndPhyVersion.FwVersion[3], ver.ChipFwAndPhyVersion.PhyVersion[0], ver.ChipFwAndPhyVersion.PhyVersion[1], ver.ChipFwAndPhyVersion.PhyVersion[2], ver.ChipFwAndPhyVersion.PhyVersion[3]); return fwVersion; }
/*! \brief This function puts the device in its default state. It: - Set the mode to STATION - Configures connection policy to Auto and AutoSmartConfig - Deletes all the stored profiles - Enables DHCP - Disables Scan policy - Sets Tx power to maximum - Sets power policy to normal - Unregister mDNS services - Remove all filters \param[in] none \return On success, zero is returned. On error, negative is returned */ static _i32 configureSimpleLinkToDefaultState(_i8 *pConfig) { SlVersionFull ver = {0}; _WlanRxFilterOperationCommandBuff_t RxFilterIdMask = {0}; _u8 val = 1; _u8 configOpt = 0; _u8 configLen = 0; _u8 power = 0; _i32 retVal = -1; _i32 mode = -1; mode = sl_Start(0, pConfig, 0); ASSERT_ON_ERROR(mode); /* If the device is not in station-mode, try configuring it in station-mode */ if (ROLE_STA != mode) { if (ROLE_AP == mode) { /* If the device is in AP mode, we need to wait for this event before doing anything */ while(!IS_IP_ACQUIRED(g_Status)); } /* Switch to STA role and restart */ retVal = sl_WlanSetMode(ROLE_STA); ASSERT_ON_ERROR(retVal); retVal = sl_Stop(SL_STOP_TIMEOUT); ASSERT_ON_ERROR(retVal); retVal = sl_Start(0, pConfig, 0); ASSERT_ON_ERROR(retVal); /* Check if the device is in station again */ if (ROLE_STA != retVal) { /* We don't want to proceed if the device is not coming up in station-mode */ ASSERT_ON_ERROR(DEVICE_NOT_IN_STATION_MODE); } } /* Get the device's version-information */ configOpt = SL_DEVICE_GENERAL_VERSION; configLen = sizeof(ver); retVal = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &configOpt, &configLen, (_u8 *)(&ver)); ASSERT_ON_ERROR(retVal); printf("Host Driver Version: %s\n",SL_DRIVER_VERSION); printf("Build Version %d.%d.%d.%d.31.%d.%d.%d.%d.%d.%d.%d.%d\n", ver.NwpVersion[0],ver.NwpVersion[1],ver.NwpVersion[2],ver.NwpVersion[3], ver.ChipFwAndPhyVersion.FwVersion[0],ver.ChipFwAndPhyVersion.FwVersion[1], ver.ChipFwAndPhyVersion.FwVersion[2],ver.ChipFwAndPhyVersion.FwVersion[3], ver.ChipFwAndPhyVersion.PhyVersion[0],ver.ChipFwAndPhyVersion.PhyVersion[1], ver.ChipFwAndPhyVersion.PhyVersion[2],ver.ChipFwAndPhyVersion.PhyVersion[3]); /* Set connection policy to Auto + SmartConfig (Device's default connection policy) */ retVal = sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1, 0, 0, 0, 1), NULL, 0); ASSERT_ON_ERROR(retVal); /* Remove all profiles */ retVal = sl_WlanProfileDel(0xFF); ASSERT_ON_ERROR(retVal); /* * Device in station-mode. Disconnect previous connection if any * The function returns 0 if 'Disconnected done', negative number if already disconnected * Wait for 'disconnection' event if 0 is returned, Ignore other return-codes */ retVal = sl_WlanDisconnect(); if(0 == retVal) { /* Wait */ while(IS_CONNECTED(g_Status)); } /* Enable DHCP client*/ retVal = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,1,1,&val); ASSERT_ON_ERROR(retVal); /* Disable scan */ configOpt = SL_SCAN_POLICY(0); retVal = sl_WlanPolicySet(SL_POLICY_SCAN , configOpt, NULL, 0); ASSERT_ON_ERROR(retVal); /* Set Tx power level for station mode Number between 0-15, as dB offset from max power - 0 will set maximum power */ power = 0; retVal = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (_u8 *)&power); ASSERT_ON_ERROR(retVal); /* Set PM policy to normal */ retVal = sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, NULL, 0); ASSERT_ON_ERROR(retVal); /* Unregister mDNS services */ retVal = sl_NetAppMDNSUnRegisterService(0, 0); ASSERT_ON_ERROR(retVal); /* Remove all 64 filters (8*8) */ memset(RxFilterIdMask.FilterIdMask, 0xFF, 8); retVal = sl_WlanRxFilterSet(SL_REMOVE_RX_FILTER, (_u8 *)&RxFilterIdMask, sizeof(_WlanRxFilterOperationCommandBuff_t)); ASSERT_ON_ERROR(retVal); retVal = sl_Stop(SL_STOP_TIMEOUT); ASSERT_ON_ERROR(retVal); retVal = initializeAppVariables(); ASSERT_ON_ERROR(retVal); return retVal; /* Success */ }
//***************************************************************************** //! \brief This function puts the device in its default state. It: //! - Set the mode to STATION //! - Configures connection policy to Auto and AutoSmartConfig //! - Deletes all the stored profiles //! - Enables DHCP //! - Disables Scan policy //! - Sets Tx power to maximum //! - Sets power policy to normal //! - Unregister mDNS services //! - Remove all filters //! //! \param none //! \return On success, zero is returned. On error, negative is returned //***************************************************************************** static long ConfigureSimpleLinkToDefaultState() { SlVersionFull ver = {0}; _WlanRxFilterOperationCommandBuff_t RxFilterIdMask = {0}; unsigned char ucVal = 1; unsigned char ucConfigOpt = 0; unsigned char ucConfigLen = 0; unsigned char ucPower = 0; long lRetVal = -1; long lMode = -1; lMode = sl_Start(0, 0, 0); ASSERT_ON_ERROR(lMode); // If the device is not in station-mode, try configuring it in station-mode if (ROLE_STA != lMode) { if (ROLE_AP == lMode) { // If the device is in AP mode, we need to wait for this event // before doing anything while(!IS_IP_ACQUIRED(g_ulStatus)) { #ifndef SL_PLATFORM_MULTI_THREADED _SlNonOsMainLoopTask(); #endif } } // Switch to STA role and restart lRetVal = sl_WlanSetMode(ROLE_STA); ASSERT_ON_ERROR(lRetVal); lRetVal = sl_Stop(0xFF); ASSERT_ON_ERROR(lRetVal); lRetVal = sl_Start(0, 0, 0); ASSERT_ON_ERROR(lRetVal); // Check if the device is in station again if (ROLE_STA != lRetVal) { // We don't want to proceed if the device is not coming up in STA-mode return DEVICE_NOT_IN_STATION_MODE; } } // Get the device's version-information ucConfigOpt = SL_DEVICE_GENERAL_VERSION; ucConfigLen = sizeof(ver); lRetVal = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &ucConfigOpt, &ucConfigLen, (unsigned char *)(&ver)); ASSERT_ON_ERROR(lRetVal); UART_PRINT("Host Driver Version: %s\n\r",SL_DRIVER_VERSION); UART_PRINT("Build Version %d.%d.%d.%d.31.%d.%d.%d.%d.%d.%d.%d.%d\n\r", ver.NwpVersion[0],ver.NwpVersion[1],ver.NwpVersion[2],ver.NwpVersion[3], ver.ChipFwAndPhyVersion.FwVersion[0],ver.ChipFwAndPhyVersion.FwVersion[1], ver.ChipFwAndPhyVersion.FwVersion[2],ver.ChipFwAndPhyVersion.FwVersion[3], ver.ChipFwAndPhyVersion.PhyVersion[0],ver.ChipFwAndPhyVersion.PhyVersion[1], ver.ChipFwAndPhyVersion.PhyVersion[2],ver.ChipFwAndPhyVersion.PhyVersion[3]); // Set connection policy to Auto + SmartConfig // (Device's default connection policy) lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1, 0, 0, 0, 1), NULL, 0); ASSERT_ON_ERROR(lRetVal); // Remove all profiles lRetVal = sl_WlanProfileDel(0xFF); ASSERT_ON_ERROR(lRetVal); // // Device in station-mode. Disconnect previous connection if any // The function returns 0 if 'Disconnected done', negative number if already // disconnected Wait for 'disconnection' event if 0 is returned, Ignore // other return-codes // lRetVal = sl_WlanDisconnect(); if(0 == lRetVal) { // Wait while(IS_CONNECTED(g_ulStatus)) { #ifndef SL_PLATFORM_MULTI_THREADED _SlNonOsMainLoopTask(); #endif } } // Enable DHCP client lRetVal = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,1,1,&ucVal); ASSERT_ON_ERROR(lRetVal); // Disable scan ucConfigOpt = SL_SCAN_POLICY(0); lRetVal = sl_WlanPolicySet(SL_POLICY_SCAN , ucConfigOpt, NULL, 0); ASSERT_ON_ERROR(lRetVal); // Set Tx power level for station mode // Number between 0-15, as dB offset from max power - 0 will set max power ucPower = 0; lRetVal = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (unsigned char *)&ucPower); ASSERT_ON_ERROR(lRetVal); // Set PM policy to normal lRetVal = sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, NULL, 0); ASSERT_ON_ERROR(lRetVal); // Unregister mDNS services lRetVal = sl_NetAppMDNSUnRegisterService(0, 0); ASSERT_ON_ERROR(lRetVal); // Remove all 64 filters (8*8) memset(RxFilterIdMask.FilterIdMask, 0xFF, 8); lRetVal = sl_WlanRxFilterSet(SL_REMOVE_RX_FILTER, (_u8 *)&RxFilterIdMask, sizeof(_WlanRxFilterOperationCommandBuff_t)); ASSERT_ON_ERROR(lRetVal); lRetVal = sl_Stop(SL_STOP_TIMEOUT); ASSERT_ON_ERROR(lRetVal); InitializeAppVariables(); return lRetVal; // Success }
static int WifiDefaultSettings(void) { long retval = -1; unsigned char val = 1; unsigned char config, config_len; //filters _WlanRxFilterOperationCommandBuff_t filter_mask = { .Padding = {0} }; //initialize the SimpleLink API retval = sl_Start(0,0,0); if(retval < 0) { RETURN_ERROR(ERROR_UNKNOWN, "SL start fail"); } //set device in station mode if(retval != ROLE_STA) { if(retval == ROLE_AP) { //we need to wait for an event before doing anything while(!IS_IP_ACQUIRED(wifi_state.status)) { #ifndef SL_PLATFORM_MULTI_THREADED _SlNonOsMainLoopTask(); #endif } } //change mode to Station retval = sl_WlanSetMode(ROLE_STA); if(retval < 0) { RETURN_ERROR(ERROR_UNKNOWN, "WLAN mode fail"); } //restart retval = sl_Stop(0xFF); if(retval < 0) { RETURN_ERROR(ERROR_UNKNOWN, "SL stop fail"); } retval = sl_Start(0,0,0); if(retval < 0) { RETURN_ERROR(ERROR_UNKNOWN, "SL start fail"); } if(retval != ROLE_STA) { RETURN_ERROR(ERROR_UNKNOWN, "WLAN mode fail"); } } //get SimpleLink version config = SL_DEVICE_GENERAL_VERSION; config_len = sizeof(SlVersionFull); retval = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &config, &config_len, (unsigned char*)&wifi_state.version); if(retval<0) { RETURN_ERROR(retval, "WIFI conf fail"); } //default connection policy retval = sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1, 0, 0, 0, 0), NULL, 0); if(retval<0) { RETURN_ERROR(retval, "WIFI policy fail"); } //disconnect retval = sl_WlanDisconnect(); if(retval == 0) { //not yet disconnected while(IS_CONNECTED(wifi_state.status)) { #ifndef SL_PLATFORM_MULTI_THREADED _SlNonOsMainLoopTask(); #endif } } //Enable DHCP client retval = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,1,1,&val); if(retval<0) { RETURN_ERROR(retval, "WIFI conf fail"); } //Disable scan policy config = SL_SCAN_POLICY(0); retval = sl_WlanPolicySet(SL_POLICY_SCAN, config, NULL, 0); if(retval<0) { RETURN_ERROR(retval, "WIFI policy fail"); } //Set Tx power level for station mode //Number between 0-15, as dB offset from max power - 0 will set max power val = 0; retval = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (unsigned char *)&val); if(retval<0) { RETURN_ERROR(retval, "WIFI set fail"); } // Set PM policy to normal retval = sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, NULL, 0); if(retval<0) { RETURN_ERROR(retval, "WIFI policy fail"); } // Unregister mDNS services retval = sl_NetAppMDNSUnRegisterService(0, 0); if(retval<0) { RETURN_ERROR(retval, "mDNS fail"); } //Set mDNS device hostname char hostname[64]; char macstring[20]; unsigned char maclen = SL_MAC_ADDR_LEN; retval = sl_NetCfgGet(SL_MAC_ADDRESS_GET, NULL, &maclen, wifi_state.mac); if(retval < 0) { RETURN_ERROR(retval, "WIFI conf fail"); } snprintf(macstring, 20, "%02X%02X%02X%02X%02X%02X", wifi_state.mac[0], wifi_state.mac[1], wifi_state.mac[2], wifi_state.mac[3], wifi_state.mac[4], wifi_state.mac[5]); snprintf(hostname, 64, "LeashDebugger%s", macstring); retval = sl_NetAppSet (SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen((const char *)hostname), (unsigned char *) hostname); // Remove all 64 filters (8*8) memset(filter_mask.FilterIdMask, 0xFF, 8); retval = sl_WlanRxFilterSet(SL_REMOVE_RX_FILTER, (uint8_t*)&filter_mask, sizeof(_WlanRxFilterOperationCommandBuff_t)); if(retval<0) { RETURN_ERROR(retval, "WIFI filter fail"); } retval = sl_Stop(SL_STOP_TIMEOUT); if(retval < 0) { RETURN_ERROR(ERROR_UNKNOWN, "SL stop fail"); } wifi_state.status = 0; return RET_SUCCESS; }
/*! \brief This function puts the device in its default state. It: - Set the mode to STATION - Configures connection policy to Auto and AutoSmartConfig - Deletes all the stored profiles - Enables DHCP - Disables Scan policy - Sets Tx power to maximum - Sets power policy to normal - Unregister mDNS services \param[in] none \return On success, zero is returned. On error, negative is returned */ static int32_t configureSimpleLinkToDefaultState(char *pConfig){ SlVersionFull ver = {0}; UINT8 val = 1; UINT8 configOpt = 0; UINT8 configLen = 0; UINT8 power = 0; INT32 retVal = -1; INT32 mode = -1; mode = sl_Start(0, pConfig, 0); /* If the device is not in station-mode, try putting it in station-mode */ if (ROLE_STA != mode){ if (ROLE_AP == mode){ /* If the device is in AP mode, we need to wait for this event before doing anything */ while(!IS_IP_AQUIRED(g_Status)); } /* Switch to STA role and restart */ retVal = sl_WlanSetMode(ROLE_STA); retVal = sl_Stop(0xFF); retVal = sl_Start(0, pConfig, 0); /* Check if the device is in station again */ if (ROLE_STA != retVal){ /* We don't want to proceed if the device is not coming up in station-mode */ return DEVICE_NOT_IN_STATION_MODE; } } /* Get the device's version-information */ configOpt = SL_DEVICE_GENERAL_VERSION; configLen = sizeof(ver); retVal = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &configOpt, &configLen, (unsigned char *)(&ver)); /* Set connection policy to Auto + SmartConfig (Device's default connection policy) */ retVal = sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1, 0, 0, 0, 1), NULL, 0); /* Remove all profiles */ retVal = sl_WlanProfileDel(0xFF); /* * Device in station-mode. Disconnect previous connection if any * The function returns 0 if 'Disconnected done', negative number if already disconnected * Wait for 'disconnection' event if 0 is returned, Ignore other return-codes */ retVal = sl_WlanDisconnect(); if(0 == retVal){ /* Wait */ while(IS_CONNECTED(g_Status)); } /* Enable DHCP client*/ retVal = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,1,1,&val); /* Disable scan */ configOpt = SL_SCAN_POLICY(0); retVal = sl_WlanPolicySet(SL_POLICY_SCAN , configOpt, NULL, 0); /* Set Tx power level for station mode Number between 0-15, as dB offset from max power - 0 will set maximum power */ power = 0; retVal = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (unsigned char *)&power); /* Set PM policy to normal */ retVal = sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, NULL, 0); /* TBD - Unregister mDNS services */ retVal = sl_NetAppMDNSUnRegisterService(0, 0); retVal = sl_Stop(0xFF); g_Status = 0; memset(&Recvbuff,0,MAX_RECV_BUFF_SIZE); memset(&SendBuff,0,MAX_SEND_BUFF_SIZE); memset(&HostName,0,MAX_HOSTNAME_SIZE); DestinationIP = 0;; SockID = 0; return retVal; /* Success */ }
void getBoardTimeDate(SlDateTime_t *dateTime) { unsigned char configOpt = SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME; unsigned char configLen = sizeof(SlDateTime_t); memset(dateTime, 0, configLen); sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &configOpt, &configLen, (unsigned char *)dateTime); }