Пример #1
0
int32_t ResetSimpleLink() {
	int32_t i32Mode = -1, i32RetVal = -1;
	uint8_t ui8Val = 1;

	i32Mode = sl_Start(0, 0, 0);

	i32RetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION,
			SL_CONNECTION_POLICY(1, 0, 0, 0, 1), NULL, 0);
	if (i32RetVal != 0) {
		return -1;
	}

	i32RetVal = sl_WlanProfileDel(0xFF);
	if (i32RetVal != 0) {
		return -1;
	}

	if (ROLE_STA != i32Mode) {
		if (ROLE_AP == i32Mode) {
			while (!STATUS_GET(g_sSLCon.Status, STATUS_BIT_IP_ACQUIRED)) {

			}
		}

		sl_WlanSetMode(ROLE_STA);
		sl_Stop(0);

		g_sSLCon.Status = 0;

		i32RetVal = sl_Start(0, 0, 0);

		if (ROLE_STA != i32RetVal) {
			return -1;
		}
	}

	i32RetVal = sl_WlanDisconnect();
	if (i32RetVal == 0) {
		while (STATUS_GET(g_sSLCon.Status, STATUS_BIT_CONNECTED)) {

		}
	}

	sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE, 1, 1, &ui8Val);
	sl_WlanPolicySet(SL_POLICY_SCAN, SL_SCAN_POLICY(0), NULL, NULL);

	ui8Val = 0;
	sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,
	WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (unsigned char *) &ui8Val);

	sl_WlanPolicySet(SL_POLICY_PM, SL_NORMAL_POLICY, NULL, 0);
	sl_NetAppMDNSUnRegisterService(0, 0);
	sl_Stop(0);

	InitVariables();

	return 0;
}
Пример #2
0
void NetStop()
{
    unsigned long lRetVal;

    //
    // Disconnect from the AP
    //
    lRetVal = sl_WlanDisconnect();
    if(0 == lRetVal)
    {
        // Wait
        while(IS_CONNECTED(g_ulStatus))
        {
#ifndef SL_PLATFORM_MULTI_THREADED
              _SlNonOsMainLoopTask();
#endif
        }
    }

    //
    // Stop the simplelink host
    //
    sl_Stop(SL_STOP_TIMEOUT);

    //
    // Reset all variables
    //
    g_ulStatus = 0;
    g_ulGatewayIP = 0;
    g_ucSimplelinkstarted = 0;
    g_ulIpAddr = 0;
}
Пример #3
0
int WiFiClass::beginNetwork(char *ssid, char *passphrase)
{
    long   retVal = -1;
    int i;

    if (!_initialized) {
        init();
    }

    // Initialize the AP-mode Connected Device array
    WiFiClass::_connectedDeviceCount = 0;
    _latestConnect = 0;
    for (i = 0; i < MAX_AP_DEVICE_REGISTRY; i++) {
        _connectedDevices[i].in_use = false;
        memset((uint8_t *)_connectedDevices[i].ipAddress, 0, 4);
        memset((uint8_t *)_connectedDevices[i].mac, 0, 6);
    }

    retVal = sl_WlanSetMode(ROLE_AP);

    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(ssid),
                            (unsigned char *)ssid);

    unsigned char  val = SL_SEC_TYPE_WPA;
    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, (unsigned char *)&val);

    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, strlen(passphrase),
                            (unsigned char *)passphrase);

    /* Restart Network processor */
    retVal = sl_Stop(30);

    role = ROLE_AP;
    return (retVal == 0 ? sl_Start(NULL, NULL, NULL) : retVal);
}
Пример #4
0
Файл: main.c Проект: dlugaz/All
//*****************************************************************************
//
//! Check the device mode and switch to P2P mode
//! restart the NWP to activate P2P mode
//!
//! \param  None
//!
//! \return status code - Success:0, Failure:-ve
//
//*****************************************************************************
long StartDeviceInP2P()
{
    long lRetVal = -1;
    // Reset CC3200 Network State Machine
    InitializeAppVariables();

    //
    // Following function configure the device to default state by cleaning
    // the persistent settings stored in NVMEM (viz. connection profiles &
    // policies, power policy etc)
    //
    // Applications may choose to skip this step if the developer is sure
    // that the device is in its default state at start of application
    //
    // Note that all profiles and persistent settings that were done on the
    // device will be lost
    //
    lRetVal = ConfigureSimpleLinkToDefaultState();
    if(lRetVal < 0)
    {
        if (DEVICE_NOT_IN_STATION_MODE == lRetVal)
            UART_PRINT("Failed to configure the device in its default state \n\r");

        LOOP_FOREVER();
    }

    UART_PRINT("Device is configured in default state \n\r");

    //
    // Assumption is that the device is configured in station mode already
    // and it is in its default state
    //

    lRetVal = sl_Start(NULL,NULL,NULL);
    ASSERT_ON_ERROR(lRetVal);

    if(lRetVal != ROLE_P2P)
    {
        lRetVal = sl_WlanSetMode(ROLE_P2P);
        ASSERT_ON_ERROR(lRetVal);

        lRetVal = sl_Stop(0xFF);

        // reset the Status bits
        CLR_STATUS_BIT_ALL(g_ulStatus);

        lRetVal = sl_Start(NULL,NULL,NULL);
        if(lRetVal < 0 || lRetVal != ROLE_P2P)
        {
            ASSERT_ON_ERROR(P2P_MODE_START_FAILED);
        }
        else
        {
            UART_PRINT("Started SimpleLink Device: P2P Mode\n\r");
            return SUCCESS;
        }
    }

    return SUCCESS;
}
Пример #5
0
//*****************************************************************************
//
//! Main 
//!
//! \param  none
//!
//! \return None
//!
//*****************************************************************************
void main()
{
    long lRetVal = -1;
    //
    // Initialize board configuration
    //
    BoardInit();

    PinMuxConfig();

    #ifndef NOTERM
        InitTerm();
    #endif

    lRetVal = ssl();
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
    }

    //
    // power off network processor
    //
    sl_Stop(SL_STOP_TIMEOUT);
    LOOP_FOREVER();
}
Пример #6
0
//****************************************************************************
//
//! Confgiures the mode in which the device will work
//!
//! \param iMode is the current mode of the device
//!
//! This function
//!    1. prompt user for desired configuration and accordingly configure the
//!          networking mode(STA or AP).
//!       2. also give the user the option to configure the ssid name in case of
//!       AP mode.
//!
//! \return sl_start return value(int).
//
//****************************************************************************
static int ConfigureMode(int iMode)
{
    char    pcSsidName[33];
    long   retVal = -1;

    UART_PRINT("Enter the AP SSID name: ");
    GetSsidName(pcSsidName,33);

    retVal = sl_WlanSetMode(ROLE_AP);
    ASSERT_ON_ERROR(__LINE__, retVal);

    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(pcSsidName),
                            (unsigned char*)pcSsidName);
    ASSERT_ON_ERROR(__LINE__, retVal);

    UART_PRINT("Device is configured in AP mode\n\r");

    /* Restart Network processor */
    retVal = sl_Stop(SL_STOP_TIMEOUT);
    ASSERT_ON_ERROR(__LINE__, retVal);

    // reset status bits
    CLR_STATUS_BIT_ALL(g_ulStatus);

    return sl_Start(NULL,NULL,NULL);
}
Пример #7
0
int WiFiClass::beginNetwork(char *ssid, char *passphrase)
{
    long   retVal = -1;

    if (!_initialized) {
        init();
    }

    retVal = sl_WlanSetMode(ROLE_AP);

    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(ssid),
                            (unsigned char *)ssid);

    unsigned char  val = SL_SEC_TYPE_WPA;
    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, (unsigned char *)&val);

    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, strlen(passphrase),
                            (unsigned char *)passphrase);

    /* Restart Network processor */
    retVal = sl_Stop(30);

    role = ROLE_AP;
    return sl_Start(NULL,NULL,NULL);
}
static unsigned long cc3200helpers_startIn(SlWlanMode_t eWlanMode)
{
  int iMode = 0;
  unsigned long dwResult = 0;

  s_flWLANConnected = 0;
  s_flAcquiredIP = 0;
  SlWlanMode_t s_eRequestedWlanMode = eWlanMode;

  dwResult = cc3200helpers_start(&iMode);

  if ( dwResult )
  {
    return dwResult;
  }

  if ( eWlanMode == iMode )
  {
    return cc3200Helpers_OK;
  }

  if (ROLE_AP == iMode)
  {
      // If the device is in AP mode, we need to wait for this event
      // before doing anything
      TRACE("Waiting for AP to initialize\n\r");
      while(!s_flAcquiredIP)
      {
#ifndef SL_PLATFORM_MULTI_THREADED
        _SlNonOsMainLoopTask();
#endif
      }
      s_flAcquiredIP = 0;
      TRACE("AP ready\n\r");
  }

  if ( sl_WlanSetMode(eWlanMode) )
  {
    return cc3200Helpers_SwitchFailed | cc3200Helpers_SetModeFailed;
  }

  if ( sl_Stop(0) )
  {
    return cc3200Helpers_SwitchFailed | cc3200Helpers_StopFailed;
  }

 dwResult = cc3200helpers_start(&iMode);

 if ( dwResult )
 {
   return cc3200Helpers_SwitchFailed | dwResult;
 }

 if ( iMode != eWlanMode )
 {
   return cc3200Helpers_SwitchFailed;
 }
  return cc3200Helpers_OK;
}
Пример #9
0
static int restart_nwp() {
  /* We don't need TI's web server. */
  sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID);
  sl_Stop(0);
  s_current_role = sl_Start(NULL, NULL, NULL);
  sl_restart_cb(&sj_mgr);
  return (s_current_role >= 0);
}
Пример #10
0
bool wifi_setup_ap(const char *ssid, const char *pass, int channel) {
    uint8_t v;
    if (sl_WlanSetMode(ROLE_AP) != 0) {
        return false;
    }
    if (sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(ssid),
                   (const uint8_t *) ssid) != 0) {
        return false;
    }
    v = strlen(pass) > 0 ? SL_SEC_TYPE_WPA : SL_SEC_TYPE_OPEN;
    if (sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, &v) != 0) {
        return false;
    }
    if (v == SL_SEC_TYPE_WPA &&
            sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, strlen(pass),
                       (const uint8_t *) pass) != 0) {
        return false;
    }
    v = channel;
    if (sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_CHANNEL, 1, &v) != 0) {
        return false;
    }
    sl_NetAppStop(SL_NET_APP_DHCP_SERVER_ID);
    {
        SlNetCfgIpV4Args_t ipcfg;
        memset(&ipcfg, 0, sizeof(ipcfg));
        if (!inet_pton(AF_INET, "192.168.4.1", &ipcfg.ipV4) ||
                !inet_pton(AF_INET, "255.255.255.0", &ipcfg.ipV4Mask) ||
                /* This means "disable". 0.0.0.0 won't do. */
                !inet_pton(AF_INET, "255.255.255.255", &ipcfg.ipV4DnsServer) ||
                /* We'd like to disable gateway too, but DHCP server refuses to start.
                   */
                !inet_pton(AF_INET, "192.168.4.1", &ipcfg.ipV4Gateway) ||
                sl_NetCfgSet(SL_IPV4_AP_P2P_GO_STATIC_ENABLE, IPCONFIG_MODE_ENABLE_IPV4,
                             sizeof(ipcfg), (uint8_t *) &ipcfg) != 0) {
            return false;
        }
    }
    {
        SlNetAppDhcpServerBasicOpt_t dhcpcfg;
        memset(&dhcpcfg, 0, sizeof(dhcpcfg));
        dhcpcfg.lease_time = 900;
        if (!inet_pton(AF_INET, "192.168.4.20", &dhcpcfg.ipv4_addr_start) ||
                !inet_pton(AF_INET, "192.168.4.200", &dhcpcfg.ipv4_addr_last) ||
                sl_NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT,
                             sizeof(dhcpcfg), (uint8_t *) &dhcpcfg) != 0) {
            return false;
        }
    }
    sl_Stop(0);
    sl_Start(NULL, NULL, NULL);
    if (sl_NetAppStart(SL_NET_APP_DHCP_SERVER_ID) != 0) {
        LOG(LL_ERROR, ("DHCP server failed to start"));
        return false;
    }
    LOG(LL_INFO, ("WiFi: AP %s configured", ssid));
    return true;
}
Пример #11
0
void wlan_stop (uint32_t timeout) {
    wlan_servers_stop();
    #ifdef SL_PLATFORM_MULTI_THREADED
    sl_LockObjLock (&wlan_LockObj, SL_OS_WAIT_FOREVER);
    #endif
    sl_Stop(timeout);
    wlan_clear_data();
    wlan_obj.mode = -1;
}
Пример #12
0
void
DeInitDriverAP(void)
{
    //
    // Stop the simplelink host
    //
    sl_Stop(10);

}
Пример #13
0
Файл: main.c Проект: dlugaz/All
//*****************************************************************************
//
//! Set all P2P Configuration to device
//!
//! \param  None
//!
//! \return status code - Success:0, Failure:-ve
//
//*****************************************************************************
long P2PConfiguration()
{
    unsigned char ucP2PParam[4];
    long lRetVal = -1;

    // Set any p2p option (SL_CONNECTION_POLICY(0,0,0,any_p2p,0)) to connect to
    // first available p2p device
    lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(1,0,0,0,0),NULL,0);
    ASSERT_ON_ERROR(lRetVal);

    // Set the negotiation role (SL_P2P_ROLE_NEGOTIATE).
    // CC3200 will negotiate with remote device GO/client mode.
    // Other valid options are:
    //             - SL_P2P_ROLE_GROUP_OWNER
    //             - SL_P2P_ROLE_CLIENT
    lRetVal = sl_WlanPolicySet(SL_POLICY_P2P, SL_P2P_POLICY(SL_P2P_ROLE_NEGOTIATE,
                                   SL_P2P_NEG_INITIATOR_ACTIVE),NULL,0);
    ASSERT_ON_ERROR(lRetVal);

    // Set P2P Device name
    lRetVal = sl_NetAppSet(SL_NET_APP_DEVICE_CONFIG_ID, \
                             NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN,
                           strlen(P2P_DEVICE_NAME), (unsigned char *)P2P_DEVICE_NAME);
    ASSERT_ON_ERROR(lRetVal);

    // Set P2P device type
    lRetVal = sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, WLAN_P2P_OPT_DEV_TYPE,
                         strlen(P2P_CONFIG_VALUE), (unsigned char*)P2P_CONFIG_VALUE);
    ASSERT_ON_ERROR(lRetVal);

    // setting P2P channel parameters
    ucP2PParam[0] = LISENING_CHANNEL;
    ucP2PParam[1] = REGULATORY_CLASS;
    ucP2PParam[2] = OPERATING_CHANNEL;
    ucP2PParam[3] = REGULATORY_CLASS;

    // Set P2P Device listen and open channel valid channels are 1/6/11
    lRetVal = sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, WLAN_P2P_OPT_CHANNEL_N_REGS,
                sizeof(ucP2PParam), ucP2PParam);
    ASSERT_ON_ERROR(lRetVal);

    // Restart as P2P device
    lRetVal = sl_Stop(SL_STOP_TIMEOUT);

    lRetVal = sl_Start(NULL,NULL,NULL);
    if(lRetVal < 0 || lRetVal != ROLE_P2P)
    {
        ASSERT_ON_ERROR(P2P_CONFIG_FAILED);
    }
    else
    {
        UART_PRINT("Connect to %s \n\r",P2P_DEVICE_NAME);
    }

    return SUCCESS;
}
Пример #14
0
void Task_WifiAP(void* params)
{
    (void)params; //avoid unused warning
    long retval;

    LOG(LOG_IMPORTANT, "Starting WiFi AP Mode.");
    SetLEDBlink(LED_1, LED_BLINK_PATTERN_WIFI_CONNECTING);

    if(WifiDefaultSettings() == RET_FAILURE)  {
        goto error;
    }

    if((retval = sl_Start(0,0,0)) < 0)  {
        goto error;
    }

    if(retval != ROLE_AP) {
        if(WifiSetModeAP() != ROLE_AP) {
            sl_Stop(SL_STOP_TIMEOUT);
            goto error;
        }
    }

    //Wait for an IP address to be acquired
    while(!IS_IP_ACQUIRED(wifi_state.status)) {};

    SetLEDBlink(LED_1, LED_BLINK_PATTERN_WIFI_AP);
    LOG(LOG_IMPORTANT, "AP Started - Ready for client.");

#ifdef DO_STACK_CHECK
    wifi_state.stack_watermark = uxTaskGetStackHighWaterMark(NULL);
#endif

    //start socket handler.
    xTaskCreate(Task_SocketServer,
                "Socket Server",
                SOCKET_TASK_STACK_SIZE/sizeof(portSTACK_TYPE),
                0,
                SOCKET_TASK_PRIORITY,
                0);

#ifdef DO_STACK_CHECK
    wifi_state.stack_watermark = uxTaskGetStackHighWaterMark(NULL);
#endif

    //exit (delete this task)
    WifiTaskEndCallback(&Task_WifiAP);
    vTaskDelete(NULL);

error:
    SetLED(LED_1, LED_BLINK_PATTERN_WIFI_FAILED);
    TASK_RETURN_ERROR(ERROR_UNKNOWN, "WIFI AP fail");
    return;

    return;
}
Пример #15
0
//--tested, working--//
bool WiFiClass::init()
{
    //
    //only initialize once
    //
    if (_initialized) {
        return true;
    }

    //
    //Initialize the UDMA
    //
    UDMAInit();

    //
    //start the SimpleLink driver (no callback)
    //
    int iRet = sl_Start(NULL, NULL, NULL);
    
    //
    //check if sl_start failed
    //
    if (iRet==ROLE_STA_ERR || iRet==ROLE_AP_ERR || iRet==ROLE_P2P_ERR) {
        return false;
    }
    
    //
    //set the mode to station if it's not already in station mode
    //
    if (iRet != ROLE_STA) {
        sl_WlanSetMode(ROLE_STA);
        sl_Stop(0);
        sl_Start(NULL, NULL, NULL);
    }
    
    //
    //Delete all profiles$
    //
    sl_WlanProfileDel(0xff);

    //
    //disconnect from anything if for some reason it's connected
    //
    sl_WlanDisconnect();
    
    sl_NetAppMDNSUnRegisterService(0, 0);

    _initialized = true;
    
    //
    // Start collecting statistics
    //
    sl_WlanRxStatStart();

    return true;
}
Пример #16
0
void cc32xx_reboot(void)
{
    sl_Stop(30);
    PRCMHibernateIntervalSet(330);
    PRCMHibernateWakeupSourceEnable(PRCM_HIB_SLOW_CLK_CTR);
    PRCMHibernateEnter();

    PRCMMCUReset(true);
    Utils_TriggerHibCycle();
}
Пример #17
0
long ResetNwp()
{
    long lRetVal = -1;
    /* Restart Network processor */
    lRetVal = sl_Stop(SL_STOP_TIMEOUT);
    
    lRetVal = sl_Start(NULL,NULL,NULL);
    ASSERT_ON_ERROR(lRetVal);
    return lRetVal;
}
Пример #18
0
static int restart_nwp(void) {
  /* Properly close FS container if it's open for writing. */
  cc3200_fs_flush();
  /* We don't need TI's web server. */
  sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID);
  /* Without a delay in sl_Stop subsequent sl_Start gets stuck sometimes. */
  sl_Stop(10);
  s_current_role = sl_Start(NULL, NULL, NULL);
  sl_restart_cb(miot_get_mgr());
  return (s_current_role >= 0);
}
Пример #19
0
void sj_system_restart() {
  /* Turns out to be not that easy. In particular, using *Reset functions is
   * not a good idea.
   * https://e2e.ti.com/support/wireless_connectivity/f/968/p/424736/1516404
   * Instead, the recommended way is to enter hibernation with immediate wakeup.
   */
  sl_Stop(50 /* ms */);
  MAP_PRCMHibernateIntervalSet(328 /* 32KHz ticks, 100 ms */);
  MAP_PRCMHibernateWakeupSourceEnable(PRCM_HIB_SLOW_CLK_CTR);
  MAP_PRCMHibernateEnter();
}
Пример #20
0
//*****************************************************************************
//
//! Check the device mode and switch to STATION(STA) mode
//! restart the NWP to activate STATION mode
//!
//! \param  iMode (device mode)
//!
//! \return None
//
//*****************************************************************************
void SwitchToStaMode(int iMode)
{
    if(iMode != ROLE_STA)
    {
        sl_WlanSetMode(ROLE_STA);
        MAP_UtilsDelay(80000);
        sl_Stop(10);
        MAP_UtilsDelay(80000);
        sl_Start(0,0,0);
    }

}
Пример #21
0
STATIC void wlan_reenable (SlWlanMode_t mode) {
    // stop and start again
    #ifdef SL_PLATFORM_MULTI_THREADED
    sl_LockObjLock (&wlan_LockObj, SL_OS_WAIT_FOREVER);
    #endif
    sl_Stop(SL_STOP_TIMEOUT);
    wlan_clear_data();
    wlan_obj.mode = sl_Start(0, 0, 0);
    #ifdef SL_PLATFORM_MULTI_THREADED
    sl_LockObjUnlock (&wlan_LockObj);
    #endif
    ASSERT (wlan_obj.mode == mode);
}
Пример #22
0
//*****************************************************************************
//
//! DeInitDriver
//! The function de-initializes a CC3200 device
//!
//! \param  None
//!
//! \return none
//
//*****************************************************************************
void
DeInitDriver(void)
{
    //
    // Disconnect from the AP
    //
    sl_WlanDisconnect();

    //
    // Stop the simplelink host
    //
    sl_Stop(10);
}
Пример #23
0
bool wifi_setup_sta(const char *ssid, const char *pass) {
    SlSecParams_t sp;
    LOG(LL_INFO, ("WiFi: connecting to %s", ssid));
    if (sl_WlanSetMode(ROLE_STA) != 0) return false;
    sl_Stop(0);
    sl_Start(NULL, NULL, NULL);
    sl_WlanDisconnect();
    sp.Key = (_i8 *) pass;
    sp.KeyLen = strlen(pass);
    sp.Type = sp.KeyLen ? SL_SEC_TYPE_WPA : SL_SEC_TYPE_OPEN;
    if (sl_WlanConnect((const _i8 *) ssid, strlen(ssid), 0, &sp, 0) != 0) {
        return false;
    }
    return true;
}
Пример #24
0
//****************************************************************************
//
//! Confgiures the mode in which the device will work
//!
//! \param iMode is the current mode of the device
//!
//!
//! \return   SlWlanMode_t
//!                        
//
//****************************************************************************
static int ConfigureMode(int iMode)
{
    long   lRetVal = -1;

    lRetVal = sl_WlanSetMode(iMode);
    ASSERT_ON_ERROR(lRetVal);

    /* Restart Network processor */
    lRetVal = sl_Stop(SL_STOP_TIMEOUT);

    // reset status bits
    CLR_STATUS_BIT_ALL(g_ulStatus);

    return sl_Start(NULL,NULL,NULL);
}
Пример #25
0
void wlan_configure()
{
    sl_Start(NULL, NULL, NULL);

    //
    // reset all network policies
    //
    unsigned char ucpolicyVal;
    int ret;
    ret = sl_WlanPolicySet(SL_POLICY_CONNECTION,
                    SL_CONNECTION_POLICY(0,0,0,0,0),
                    &ucpolicyVal,
                    1 /*PolicyValLen*/);
    if(ret < 0)
    {
        LOOP_FOREVER();
    }

    sl_WlanSetMode(ROLE_STA);
    sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1, 0, 0, 0, 1), NULL, 0);
    sl_WlanProfileDel(0xFF);
    sl_WlanDisconnect();

    _WlanRxFilterOperationCommandBuff_t  RxFilterIdMask;// = {0};
    memset(&RxFilterIdMask, 0, sizeof(RxFilterIdMask));

    unsigned char ucVal = 0;
    unsigned char ucConfigOpt = 0;
    // Enable DHCP client
    sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,1,1,&ucVal);
    // Disable scan
    ucConfigOpt = SL_SCAN_POLICY(0);
    sl_WlanPolicySet(SL_POLICY_SCAN , ucConfigOpt, NULL, 0);
    // Set Tx power level for station mode
    // Number between 0-15, as dB offset from max power - 0 will set max power
    unsigned char ucPower = 0;
    sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (unsigned char *)&ucPower);
    // Set PM policy to normal
    sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, NULL, 0);
    // Unregister mDNS services
    sl_NetAppMDNSUnRegisterService(0, 0);
    // Remove  all 64 filters (8*8)
    memset(RxFilterIdMask.FilterIdMask, 0xFF, 8);
    sl_WlanRxFilterSet(SL_REMOVE_RX_FILTER, (_u8 *)&RxFilterIdMask, sizeof(_WlanRxFilterOperationCommandBuff_t));
    sl_Stop(SL_STOP_TIMEOUT);
}
Пример #26
0
//****************************************************************************
//							MAIN FUNCTION
//****************************************************************************
void main()
{
    char cMode = 0;

    //
    // Board Initialization
    //
    BoardInit();

    //
    // Configure the pinmux settings for the peripherals exercised
    //
    PinMuxConfig();

    //
    // Configuring UART
    //
#ifndef NOTERM
    InitTerm();
#endif  //NOTERM
    //
    // Display banner
    //
    DisplayBanner(APP_NAME);

    //
    // staring simplelink
    //
    cMode = sl_Start(NULL,NULL,NULL);

    //
    // Display current mode and ssid name(for AP mode)
    //
    DisplayCurrentConfig(cMode);

    //
    // Configure the networking mode and ssid name(for AP mode)
    //
    ConfigureMode(cMode);

    UART_PRINT("Please restart the device \n\r");
    sl_Stop(SL_STOP_TIMEOUT);
    LOOP_FOREVER(line_number);

}
Пример #27
0
//*****************************************************************************
//
//! Main 
//!
//! \param  none
//!
//! \return None
//!
//*****************************************************************************
void main()
{
    long lRetVal = -1;
    //
    // Initialize board configuration
    //
    BoardInit();

    PinMuxConfig();
    //Initialize GPIO interrupt
    GPIOIntInit();
    //Initialize Systick interrupt
    SystickIntInit();
    //Initialize Uart interrupt
    UART1IntInit();
    //Initialize SPI
    SPIInit();
    //Initalize Adafruit
    Adafruit_Init();

    InitTerm();
    //Connect the CC3200 to the local access point
    lRetVal = connectToAccessPoint();
    //Set time so that encryption can be used
    lRetVal = set_time();
    if(lRetVal < 0)
    {
        UART_PRINT("Unable to set time in the device");
        LOOP_FOREVER();
    }
    //Connect to the website with TLS encryption
    lRetVal = tls_connect();
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
    }

    //remote calls sendMessage() which calls http_post() which requires the return value from tls_connect()
    remote(lRetVal);

    //http_post(lRetVal);

    sl_Stop(SL_STOP_TIMEOUT);
    LOOP_FOREVER();
}
void CC3200Helpers_HibernateNowFor(unsigned long dwSeconds, char flStopSL)
{
  unsigned long long qwTicks = dwSeconds;
  qwTicks *= SLOW_CLK_FREQ;
  MAP_PRCMHibernateIntervalSet(qwTicks);
  MAP_PRCMHibernateWakeupSourceEnable(PRCM_HIB_SLOW_CLK_CTR);
  MAP_UtilsDelay(80000);
  if ( flStopSL )
  {
    sl_WlanDisconnect();
    sl_Stop(0);
  }
  MAP_SPICSDisable(SSPI_BASE);
  MAP_SPICSEnable(SSPI_BASE);
  MAP_SPIDataPut(SSPI_BASE, 0xB9); // deep power down
  MAP_SPICSDisable(SSPI_BASE);
  MAP_PRCMHibernateEnter();
}
Пример #29
0
int WiFiClass::beginNetwork(char *ssid)
{
    long   retVal = -1;

    if (!_initialized) {
        init();
    }

    retVal = sl_WlanSetMode(ROLE_AP);

    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(ssid),
                            (unsigned char *)ssid);

    /* Restart Network processor */
    retVal = sl_Stop(30);

    role = ROLE_AP;
    return sl_Start(NULL,NULL,NULL);
}
Пример #30
0
Файл: main.c Проект: dlugaz/All
int main()
{
    long lRetVal = -1;

    //
    // Board Initialization
    //
    BoardInit();

    //
    // Configure the pinmux settings for the peripherals exercised
    //
    PinMuxConfig();

    //
    // Configuring UART
    //
    InitTerm();

    //
    // Display banner
    //
    DisplayBanner(APP_NAME);

    InitializeAppVariables();

    lRetVal = ServerFileDownload();

    if(lRetVal < 0)
    {
        UART_PRINT("Server file download failed\n\r");
        LOOP_FOREVER();
    }
    else
    {
        UART_PRINT("Downloading File Completed\n\r");
    }
    UART_PRINT("\nThank you\r\n");
    // Stop the CC3200 device
    lRetVal = sl_Stop(SL_STOP_TIMEOUT);
    
    LOOP_FOREVER();
}