• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sl_NetCfgGet函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sl_NetCfgGet函数的典型用法代码示例。如果您正苦于以下问题:C++ sl_NetCfgGet函数的具体用法?C++ sl_NetCfgGet怎么用?C++ sl_NetCfgGet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sl_NetCfgGet函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main0

int main0(void){  
  // "Embedded Systems: Real Time Interfacing to ARM Cortex M Microcontrollers",
  // ISBN: 978-1463590154, Jonathan Valvano, copyright (c) 2014, Volume 2, Program 11.2
  UINT8             IsDHCP = 0;
  _NetCfgIpV4Args_t ipV4;
  SlSockAddrIn_t    Addr;
  UINT16            AddrSize = 0;
  INT16             SockID = 0;
  UINT32            data;
  unsigned char     len = sizeof(_NetCfgIpV4Args_t);
  initClk();         // PLL 50 MHz, ADC needs PPL active          15
  ADC0_InitSWTriggerSeq3(7);  // Ain7 is on PD0                   16
  sl_Start(0, 0, 0); // Initializing the CC3100 device            17
  WlanConnect();     // connect to AP                             18
  sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&IsDHCP,&len,       // 19
               (unsigned char *)&ipV4);                        // 20
  Addr.sin_family = SL_AF_INET;                       //          21 
  Addr.sin_port = sl_Htons((UINT16)PORT_NUM);         //          22
  Addr.sin_addr.s_addr = sl_Htonl((UINT32)IP_ADDR);   //          23
  AddrSize = sizeof(SlSockAddrIn_t);                  //          24
  SockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);    //          25
  while(1){
    uBuf[0] = ATYPE;      // analog data type                     26
    uBuf[1] = '=';        //                                      27
    data = ADC0_InSeq3(); // 0 to 4095, Ain7 is on PD0            28
    Int2Str(data,(char*)&uBuf[2]); // 6 digit number              29
    sl_SendTo(SockID, uBuf, BUF_SIZE, 0,        //                30
                         (SlSockAddr_t *)&Addr, AddrSize); //     31
    ROM_SysCtlDelay(ROM_SysCtlClockGet() / 25);  // 40ms          32
  }
}
开发者ID:manavm,项目名称:Classes,代码行数:31,代码来源:starter1.c


示例2: RegisterSocketServices

static int RegisterSocketServices(void)
{
    int retval;
    char servicename[MDNS_SERVICE_NAME_MAXLEN];

    LOG(LOG_IMPORTANT, "%sRegistering services on mDNS...",wifi_log_prefix);

    //retreive the device mac address
    char macstring[20];
    unsigned char mac[SL_MAC_ADDR_LEN];
    unsigned char maclen = SL_MAC_ADDR_LEN;
    retval = sl_NetCfgGet(SL_MAC_ADDRESS_GET,
            NULL,
            &maclen,
            mac);
    if(retval < 0) { RETURN_ERROR(retval, "Sock: Unable to get MAC address."); }
    sprintf(macstring, "[%02X:%02X:%02X:%02X:%02X:%02X]", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);

    for(int i=0; i<NUM_SOCKETS; i++){
        sprintf(servicename, "%s - %s", macstring, socket_mdns_names_fixedpart[i]);
        retval = sl_NetAppMDNSRegisterService((signed char*)servicename,
                (unsigned char)strlen(servicename),
                (signed char*)socket_mdns_descriptions[i],
                (unsigned char)strlen(socket_mdns_descriptions[i]),
                socket_ports[i],MDNS_SERVICE_TTL,1);
        if(retval < 0) { RETURN_ERROR(retval, "Sock: Unable to register mDNS."); }
    }

    LOG(LOG_IMPORTANT, "%sServices registered.",wifi_log_prefix);

    return RET_SUCCESS;
}
开发者ID:Mindtribe,项目名称:Leash-Debugger,代码行数:32,代码来源:serialsock.c


示例3: DisplayIP

//****************************************************************************
//
//! \brief Display the IP Adderess of device
//!
//! \param[in]      none
//!
//! \return         none
//!
//
//****************************************************************************
static void DisplayIP()
{
    unsigned long mask, dns, gateway;
    unsigned char len, dhcpIsOn;

    if(g_ulDeviceIp == 0)
    {
        /* Device is in GO mode, Get the IP of Device */
        len = sizeof(_NetCfgIpV4Args_t);
		dhcpIsOn = 0;
		_NetCfgIpV4Args_t ipV4 = {0};
		sl_NetCfgGet(SL_IPV4_AP_P2P_GO_GET_INFO,&dhcpIsOn,&len,(unsigned char *)&ipV4);
		g_ulDeviceIp=ipV4.ipV4;
		mask=ipV4.ipV4Mask;
		gateway=ipV4.ipV4Gateway;
		dns=ipV4.ipV4DnsServer;
    }

    UNUSED(mask);
    UNUSED(gateway);
    UNUSED(dns);

    UART_PRINT("CC3200 Device IP : IP=%d.%d.%d.%d \n\r", SL_IPV4_BYTE(g_ulDeviceIp,3),
                SL_IPV4_BYTE(g_ulDeviceIp,2), SL_IPV4_BYTE(g_ulDeviceIp,1),
                SL_IPV4_BYTE(g_ulDeviceIp,0));
}
开发者ID:Balu1991,项目名称:Wifly_Light,代码行数:36,代码来源:main.c


示例4: init

void WiFiClass::config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet)
{
    if (!_initialized) {
        init();
    }

    //
    // Set the local_IP indicating that the network
    // is configured for static IP.
    //
    local_IP = local_ip;

    //
    //get current configuration
    //
    SlNetCfgIpV4Args_t config = {0};
    unsigned char len = sizeof(SlNetCfgIpV4Args_t);
    sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO, NULL, &len, (unsigned char*)&config);
    
    //
    //Assign new ip address and new dns server to current config
    //and use netcfgset to set the new configuration in memory
    //
    config.ipV4 = sl_Ntohl((uint32_t)local_ip);
    config.ipV4DnsServer = sl_Ntohl((uint32_t)dns_server);
    config.ipV4Gateway = sl_Ntohl((uint32_t)gateway);
    config.ipV4Mask = sl_Ntohl((uint32_t)subnet);
    sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE, 1, sizeof(SlNetCfgIpV4Args_t), (unsigned char*)&config);
    
}
开发者ID:ArduCAM,项目名称:Energia,代码行数:30,代码来源:WiFi.cpp


示例5: init

void WiFiClass::config(IPAddress local_ip)
{
    if (!_initialized) {
        init();
    }

    //
    // Set the local_IP indicating that the network
    // is configured for static IP.
    //
    local_IP = local_ip;

    //
    //get current configuration
    //
    _NetCfgIpV4Args_t config = {0};
    unsigned char len = sizeof(_NetCfgIpV4Args_t);
    sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO, NULL, &len, (unsigned char*)&config);
    
    //
    //Assign new ip address to current config
    //and use netcfgset to set the new configuration in memory
    //
    config.ipV4 = sl_Ntohl((uint32_t)local_ip);
    sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE, 1, sizeof(_NetCfgIpV4Args_t), (unsigned char*)&config);
}
开发者ID:Ryan1014,项目名称:Energia,代码行数:26,代码来源:WiFi.cpp


示例6: NetMACAddressGet

//****************************************************************************
//
//! Get the device mac address
//!
//! \brief This function gets the MAC address of the device
//!
//! \param pMACAddress is pointer to variable where MAC address will be stored
//!
//! \return None.
//
//****************************************************************************
void NetMACAddressGet(unsigned char *pMACAddress)
{
    unsigned char macAddressLen = SL_MAC_ADDR_LEN;

    //
    // Get the MAC address
    //
    sl_NetCfgGet(SL_MAC_ADDRESS_GET, NULL, &macAddressLen, pMACAddress);

}
开发者ID:CaptFrank,项目名称:CC3200-Linux-SDK,代码行数:21,代码来源:net.c


示例7: DisplayIP

//****************************************************************************
//
//! \brief Display the IP Adderess of device
//!
//! \param[in]      none
//!
//! \return         none
//!
//
//****************************************************************************
static signed long DisplayIP()
{
    unsigned long mask, dns, gateway;
    long lRetVal = -1;
    unsigned char len, dhcpIsOn;

    if(g_ulDeviceIp == 0)
    {
        /* Device is in GO mode, Get the IP of Device */
        len = sizeof(SlNetCfgIpV4Args_t);
        dhcpIsOn = 0;
        SlNetCfgIpV4Args_t ipV4 = {0};

        // Get the IP address of device
#ifdef P2P_ROLE_TYPE_NEGOTIATE
        lRetVal = sl_NetCfgGet(SL_IPV4_AP_P2P_GO_GET_INFO,&dhcpIsOn,
                                        &len,(unsigned char *)&ipV4);
#else
        lRetVal = sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&dhcpIsOn,
                                                &len,(unsigned char *)&ipV4)
#endif
        ASSERT_ON_ERROR(lRetVal);

        g_ulDeviceIp=ipV4.ipV4;
        mask=ipV4.ipV4Mask;
        gateway=ipV4.ipV4Gateway;
        dns=ipV4.ipV4DnsServer;
    }

    UNUSED(mask);
    UNUSED(gateway);
    UNUSED(dns);

    UART_PRINT("CC3200 Device IP : IP=%d.%d.%d.%d \n\r",
                SL_IPV4_BYTE(g_ulDeviceIp,3), SL_IPV4_BYTE(g_ulDeviceIp,2),
                SL_IPV4_BYTE(g_ulDeviceIp,1), SL_IPV4_BYTE(g_ulDeviceIp,0));
    return 0;
}
开发者ID:dlugaz,项目名称:All,代码行数:48,代码来源:main.c


示例8: main3

  // "Embedded Systems: Real Time Interfacing to ARM Cortex M Microcontrollers",
  // ISBN: 978-1463590154, Jonathan Valvano, copyright (c) 2014, Volume 2, Program 11.3
int main3(void){
  UINT8             IsDHCP = 0;
  _NetCfgIpV4Args_t ipV4;
  SlSockAddrIn_t    Addr, LocalAddr;
  UINT16            AddrSize = 0;
  INT16             SockID = 0;
  INT16             Status = 1;  // ok
  UINT32            data;
  unsigned char     len = sizeof(_NetCfgIpV4Args_t);
  initClk();        // PLL 50 MHz, ADC needs PPL active           16
  ST7735_InitR(INITR_REDTAB);                  // Initialize      17
  ST7735_OutString("Internet of Things\n");    //                 18
  ST7735_OutString("Embedded Systems\n");      //                 19
  ST7735_OutString("Vol. 2, Valvano");         //                 20
  ST7735_PlotClear(0,4095);  // range from 0 to 4095              21
  sl_Start(0, 0, 0); // Initializing the CC3100 device            22
  WlanConnect();     // connect to AP                             23
  sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&IsDHCP,&len,   //     24
               (unsigned char *)&ipV4);                    //     25
  LocalAddr.sin_family = SL_AF_INET;                       //     26
  LocalAddr.sin_port = sl_Htons((UINT16)PORT_NUM);         //     27
  LocalAddr.sin_addr.s_addr = 0;                           //     28
  AddrSize = sizeof(SlSockAddrIn_t);                       //     29
  while(1){
    SockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);       //     31   
    Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr,   //     32
                       AddrSize);                          //     33
    Status = sl_RecvFrom(SockID, uBuf, BUF_SIZE, 0,        //     34
          (SlSockAddr_t *)&Addr, (SlSocklen_t*)&AddrSize );//     35
    if((uBuf[0]==ATYPE)&&(uBuf[1]== '=')){                 //     36
      int i,bOk; uint32_t place;                           //     37
      data = 0; bOk = 1;                                   //     38
      i=4;  // ignore possible negative sign                      39
      for(place = 1000; place; place = place/10){          //     40
        if((uBuf[i]&0xF0)==0x30){ // ignore spaces                41
          data += place*(uBuf[i]-0x30);                    //     42
        }else{                                             //     43
          if((uBuf[i]&0xF0)!= ' '){                        //     44
            bOk = 0;                                       //     45
          }                                                //     46
        }                                                  //     47
        i++;                                               //     48
      }                                                    //     49
      if(bOk){                                             //     50
        ST7735_PlotLine(data);                             //     51
        ST7735_PlotNextErase();                            //     51
      }
    }
  }
}
开发者ID:manavm,项目名称:Classes,代码行数:52,代码来源:starter1.c


示例9: Network_IF_IpConfigGet

//*****************************************************************************
//
//! Network_IF_IpConfigGet  Get the IP Address of the device.
//!
//! \param  pulIP IP Address of Device
//! \param  pulSubnetMask Subnetmask of Device
//! \param  pulDefaultGateway Default Gateway value
//! \param  pulDNSServer DNS Server
//!
//! \return none
//
//*****************************************************************************
int
Network_IF_IpConfigGet(unsigned long *pulIP, unsigned long *pulSubnetMask,
                       unsigned long *pulDefaultGateway, unsigned long *pulDNSServer)
{
    unsigned char isDhcp;
    unsigned char len = sizeof(_NetCfgIpV4Args_t);
    _NetCfgIpV4Args_t ipV4 = {0};

    sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&isDhcp,&len,(unsigned char *)&ipV4);

    *pulIP=ipV4.ipV4;
    *pulSubnetMask=ipV4.ipV4Mask;
    *pulDefaultGateway=ipV4.ipV4Gateway;
    *pulDefaultGateway=ipV4.ipV4DnsServer;

    return 1;
}
开发者ID:mike-kang,项目名称:CC3200CloudDemo,代码行数:29,代码来源:network_if.c


示例10: CMD_who

int
CMD_who(int argc, char **argv)
{
    UINT8 IsDHCP;
    _NetCfgIpV4Args_t ipV4;
    unsigned char len = sizeof(_NetCfgIpV4Args_t);
    sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&IsDHCP, &len,(unsigned char *)&ipV4);
    UARTprintf("  Server IP: %d.%d.%d.%d",
               SL_IPV4_BYTE(IP_ADDR,3), SL_IPV4_BYTE(IP_ADDR,2),
               SL_IPV4_BYTE(IP_ADDR,1), SL_IPV4_BYTE(IP_ADDR,0));
    UARTprintf("\n");
    UARTprintf("This node is at IP: %d.%d.%d.%d\n",
               SL_IPV4_BYTE(ipV4.ipV4,3), SL_IPV4_BYTE(ipV4.ipV4,2),
               SL_IPV4_BYTE(ipV4.ipV4,1), SL_IPV4_BYTE(ipV4.ipV4,0));
    
    return 0;
}
开发者ID:manavm,项目名称:Classes,代码行数:17,代码来源:starter1.c


示例11: CMD_ask

int
CMD_ask(int argc, char **argv)
{
    UINT8 IsDHCP;
    _NetCfgIpV4Args_t ipV4;
    unsigned char len = sizeof(_NetCfgIpV4Args_t);
    char packet[256];
    char last3[10];
    int temp;
    sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&IsDHCP, &len,(unsigned char *)&ipV4);
    temp = SL_IPV4_BYTE(ipV4.ipV4,0);
    sprintf(last3, "%d", temp);
    UARTprintf("%d", temp);
    UARTprintf("%s", last3);
    
    
    return 0;
}
开发者ID:manavm,项目名称:Classes,代码行数:18,代码来源:starter1.c


示例12: _SlNonOsMainLoopTask

//--tested, working--//
IPAddress WiFiClass::localIP()
{
    //
    //the local IP is maintained with callbacks, so _SlNonOsMainLoopTask()
    //is critical. The IP is "written" into the buffer to avoid memory errors
    //
    _SlNonOsMainLoopTask();

    SlNetCfgIpV4Args_t config = {0};
    unsigned char len = sizeof(SlNetCfgIpV4Args_t);
    sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO, NULL, &len, (unsigned char*)&config);

    //
    //change the uint32_t IP to the IPAddress class and return
    //
    IPAddress retIP(0,0,0,0);
    retIP = sl_Htonl(config.ipV4);
    return retIP;
}
开发者ID:AmirRajabifar,项目名称:Energia,代码行数:20,代码来源:WiFi.cpp


示例13: init

//--tested, working--//
IPAddress WiFiClass::gatewayIP()
{
    if (!_initialized) {
        init();
    }
    //
    //get current configuration
    //
    _NetCfgIpV4Args_t config = {0};
    unsigned char len = sizeof(_NetCfgIpV4Args_t);
    sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO, NULL, &len, (unsigned char*)&config);
    
    //
    //change the uint32_t IP to the IPAddress class and return
    //
    IPAddress retIP(0,0,0,0);
    retIP = sl_Htonl(config.ipV4Gateway);
    return retIP;
}
开发者ID:LCPINAGE,项目名称:Energia,代码行数:20,代码来源:WiFi.cpp


示例14: CMD_ping

//*****************************************************************************
//
// Ping an IP Address
// Arguments:
//  [1] IP address to ping
//  [2] (optional) max number of tries
//  [3] (optional) timeout in milliseconds
//
//*****************************************************************************
int
CMD_ping(int argc, char **argv)
{
    SlPingStartCommand_t PingParams;
    SlPingReport_t Report;
    _NetCfgIpV4Args_t ipV4;

    unsigned char len = sizeof(_NetCfgIpV4Args_t);;
    unsigned char IsDHCP = 0;

    /* Read the IP parameter */
    sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&IsDHCP,&len,
            (unsigned char *)&ipV4);

    /* Set the ping parameters */
    PingParams.PingIntervalTime = PING_INTERVAL;
    PingParams.PingSize = PING_SIZE;
    PingParams.PingRequestTimeout = PING_TIMEOUT;
    PingParams.TotalNumberOfAttempts = NO_OF_ATTEMPTS;
    PingParams.Flags = 0;
    PingParams.Ip = ipV4.ipV4Gateway; /* Fill the GW IP address, which is our AP address */

    /* Check for LAN connection */
    UARTprintf("Pinging the Gateway...\n");
    sl_NetAppPingStart((SlPingStartCommand_t*)&PingParams, SL_AF_INET,
                       (SlPingReport_t*)&Report, SimpleLinkPingReport);

    while(0 == (g_Status & PING_DONE))
    {
        _SlNonOsMainLoopTask();
    }

    g_Status &= ~(1 << PING_DONE_STATUS_BIT);
    UARTprintf("Ping Done\n");
    if (!g_PingPacketsRecv)
    {
        /* Problem with LAN connection */
        UARTprintf("Problem with the LAN connection\n");
        return -1;
    }
  return 0;
}
开发者ID:manavm,项目名称:Classes,代码行数:51,代码来源:starter1.c


示例15: Network_IF_IpConfigGet

//*****************************************************************************
//
//! Network_IF_IpConfigGet  Get the IP Address of the device.
//!
//! \param  pulIP IP Address of Device
//! \param  pulSubnetMask Subnetmask of Device
//! \param  pulDefaultGateway Default Gateway value
//! \param  pulDNSServer DNS Server
//!
//! \return On success, zero is returned. On error, -1 is returned
//
//*****************************************************************************
long
Network_IF_IpConfigGet(unsigned long *pulIP, unsigned long *pulSubnetMask,
                unsigned long *pulDefaultGateway, unsigned long *pulDNSServer)
{
    unsigned char isDhcp;
    unsigned char len = sizeof(SlNetCfgIpV4Args_t);
    long lRetVal = -1;
    SlNetCfgIpV4Args_t ipV4 = {0};

    lRetVal = sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&isDhcp,&len,
                                  (unsigned char *)&ipV4);
    ASSERT_ON_ERROR(lRetVal);

    *pulIP=ipV4.ipV4;
    *pulSubnetMask=ipV4.ipV4Mask;
    *pulDefaultGateway=ipV4.ipV4Gateway;
    *pulDefaultGateway=ipV4.ipV4DnsServer;

    return lRetVal;
}
开发者ID:ClarePhang,项目名称:SimpleLink-CC3200,代码行数:32,代码来源:network_if.c


示例16: getMacAddress

//*****************************************************************************
//! getMacAddress
//!
//! Returns the MAC Address as string
//!
//****************************************************************************
char * getMacAddress()
{
	int i;

	unsigned char macAddressVal[SL_MAC_ADDR_LEN];
	unsigned char macAddressLen = SL_MAC_ADDR_LEN;

	sl_NetCfgGet(SL_MAC_ADDRESS_GET,NULL,&macAddressLen,(unsigned char *)macAddressVal);

	char macAddressPart[2];
	static char macAddressFull[18]; //18

	for (i = 0 ; i < 6 ; i++)
	{
		sprintf(macAddressPart, "%02X", macAddressVal[i]);
		strcat(macAddressFull, (char *)macAddressPart);
		strcat(macAddressFull, ":");
	}

	macAddressFull[17] = '\0'; // Replace the the last : with a zero termination

	return macAddressFull;
}
开发者ID:EmuxEvans,项目名称:LightServer,代码行数:29,代码来源:lsmdns.c


示例17: WlanAPMode

//****************************************************************************
//
//!    \brief start simplelink, wait for the sta to connect to the device and 
//!        run the ping test for that sta
//!
//!    \param  pvparameters is the pointer to the list of parameters that can be
//!         passed to the task while creating it
//!
//!    \return None
//
//****************************************************************************
void WlanAPMode( void *pvParameters )
{   
    int iTestResult = 0;
    unsigned char ucDHCP;
    long retVal = -1;

    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 applicaton
    //
    // Note that all profiles and persistent settings that were done on the
    // device will be lost
    //
    retVal = ConfigureSimpleLinkToDefaultState();
    if(retVal < 0)
    {
        if (DEVICE_NOT_IN_STATION_MODE == retVal)
            UART_PRINT("Failed to configure the device in its default state \n\r");

        LOOP_FOREVER(__LINE__);
    }

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

    //
    // Asumption is that the device is configured in station mode already
    // and it is in its default state
    //
    retVal = sl_Start(NULL,NULL,NULL);

    if (retVal < 0)
    {
        UART_PRINT("Failed to start the device \n\r");
        LOOP_FOREVER(__LINE__);
    }

    UART_PRINT("Device started as STATION \n\r");
    
    //
    // Configure the networking mode and ssid name(for AP mode)
    //
    if(retVal != ROLE_AP)
    {
        if(ConfigureMode(retVal) !=ROLE_AP)
        {
            UART_PRINT("Unable to set AP mode, exiting Application...\n\r");
            sl_Stop(SL_STOP_TIMEOUT);
            return;
        }
    }

    while(!IS_IP_ACQUIRED(g_ulStatus))
    {
      //looping till ip is acquired
    }

    unsigned char len = sizeof(_NetCfgIpV4Args_t);
    _NetCfgIpV4Args_t ipV4 = {0};

    retVal = sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&ucDHCP,&len,
                            (unsigned char *)&ipV4);
    if (retVal < 0)
    {
        UART_PRINT("Failed to get network configuration \n\r");
        LOOP_FOREVER(__LINE__);
    }
    
    UART_PRINT("Connect a client to Device\n\r");
    while(!IS_IP_LEASED(g_ulStatus))
    {
      //wating for the client to connect
    }
    UART_PRINT("Client is connected to Device\n\r");

    iTestResult = PingTest(g_ulStaIp);
    UNUSED(ucDHCP);
    UNUSED(iTestResult);
    sl_WlanSetMode(ROLE_STA);

    /* Switch off Network processor */
    sl_Stop(SL_STOP_TIMEOUT);
    UART_PRINT("Application exits\n\r");
    while(1);
//.........这里部分代码省略.........
开发者ID:Balu1991,项目名称:Wifly_Light,代码行数:101,代码来源:main.c


示例18: main

int main(void)
{
    UINT8  IsDHCP = 0;
    int32_t i32CommandStatus;
    _NetCfgIpV4Args_t ipV4;
		SlSockAddrIn_t    Addr; 
		UINT16            AddrSize = 0; 
		INT16             SockID = 0; 
		UINT32            data; 
		long x = 0; //counter
    unsigned char len = sizeof(_NetCfgIpV4Args_t);
    int Status = 0;
    /* Stop WDT */
    stopWDT();
    /* Initialize the system clock of MCU */
    initClk();
		Board_Init();       // initialize LaunchPad I/O and PD1 LED
    ConfigureUART();    // Initialize the UART.
    UARTprintf("Section 11.4 IoT example, Volume 2 Real-time interfacing\n");
    UARTprintf("This application is configured to generate text\n");
    UARTprintf("  and send UDP packets to IP: %d.%d.%d.%d  Port: %d\n\n",
      SL_IPV4_BYTE(IP_ADDR,3), SL_IPV4_BYTE(IP_ADDR,2), 
      SL_IPV4_BYTE(IP_ADDR,1), SL_IPV4_BYTE(IP_ADDR,0),PORT_NUM);
		//added code from the powerpoint slide
    /* Initializing the CC3100 device */
    sl_Start(0, 0, 0);
    /* Connecting to WLAN AP - Set with static parameters defined at the top
       After this call we will be connected and have IP address */
    WlanConnect();
    /* Read the IP parameter */
    sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&IsDHCP,&len,(unsigned char *)&ipV4);
    UARTprintf("This node is at IP: %d.%d.%d.%d\n", SL_IPV4_BYTE(ipV4.ipV4,3), SL_IPV4_BYTE(ipV4.ipV4,2), SL_IPV4_BYTE(ipV4.ipV4,1), SL_IPV4_BYTE(ipV4.ipV4,0));
    Addr.sin_family = SL_AF_INET;
    Addr.sin_port = sl_Htons((UINT16)PORT_NUM);
    Addr.sin_addr.s_addr = sl_Htonl((UINT32)IP_ADDR);
    AddrSize = sizeof(SlSockAddrIn_t);
    SockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);
    // Loop forever waiting  for commands from PC...
    //
    while(1)
    {
        // Print prompt for user.
        UARTprintf("\n>");
        // Peek to see if a full command is ready for processing.
        while(UARTPeek('\r') == -1)
						LED_On();
            // Approximately 1 millisecond delay.
            ROM_SysCtlDelay(ROM_SysCtlClockGet() / 3000);

        }
        // A '\r' was detected so get the line of text from the receive buffer.
		while(Status >= 0){
      UARTprintf("\nSending a UDP packet ...\n");
		
			UARTgets(g_cInput,sizeof(g_cInput)); //this function receives the input from the Putty and places it in a string

			
			
			//DO NOT CHANGE ANYTHING ABOVE THIS COMMENT
			
			//WHAT WE NEED TO DO:
			//work with the g_cInput to get the array of letters typed into the Putty
			//then send that Array using UARTprintf
			uBuf[0] = ATYPE;   // defines this as an analog data type
			uBuf[1] = '='; 
			data = 1000;

			Int2Str(data,(char*)&uBuf[2]); // [2] to [7] is 6 digit number
      UARTprintf(" %s ",uBuf); //this line sends a string to the receiver
      //the above 5 lines print out a = 1000;
			//everything below this is just error cases
			if( SockID < 0 ){
        UARTprintf("SockIDerror ");
        Status = -1; // error
      }else{
        LED_Toggle();
        Status = sl_SendTo(SockID, uBuf, BUF_SIZE, 0,
                           (SlSockAddr_t *)&Addr, AddrSize);
        if( Status <= 0 ){
          sl_Close(SockID);
          UARTprintf("SockIDerror %d ",Status);
        }else{
          UARTprintf("ok");
        }
      }
      ROM_SysCtlDelay(ROM_SysCtlClockGet() / 100); // 10ms
			LED_Off();
		}
   }
开发者ID:manavm,项目名称:Classes,代码行数:89,代码来源:starter.c


示例19: device_get_mac_address

void device_get_mac_address(uint8_t mac[6]) {
  uint8_t mac_len = 6;
  sl_NetCfgGet(SL_MAC_ADDRESS_GET, NULL, &mac_len, mac);
}
开发者ID:MrZANE42,项目名称:smart.js,代码行数:4,代码来源:cc3200_config.c


示例20: main2

int main2(void)
{
    UINT8  IsDHCP = 0;
    int32_t i32CommandStatus;
    _NetCfgIpV4Args_t ipV4;

    unsigned char len = sizeof(_NetCfgIpV4Args_t);
    int Status = 0;

    /* Stop WDT */
    stopWDT();

    /* Initialize the system clock of MCU */
    initClk();

    Board_Init();       // initialize LaunchPad I/O and PD1 LED
    ConfigureUART();    // Initialize the UART.
    UARTprintf("Section 11.4 IoT example, Volume 2 Real-time interfacing\n");
    UARTprintf("This application is configured to measure analog signals from Ain7=PD0\n");
    UARTprintf("  and send UDP packets to IP: %d.%d.%d.%d  Port: %d\n\n",
      SL_IPV4_BYTE(IP_ADDR,3), SL_IPV4_BYTE(IP_ADDR,2), 
      SL_IPV4_BYTE(IP_ADDR,1), SL_IPV4_BYTE(IP_ADDR,0),PORT_NUM);
    /* Initializing the CC3100 device */
    sl_Start(0, 0, 0);

    /* Connecting to WLAN AP - Set with static parameters defined at the top
       After this call we will be connected and have IP address */
    WlanConnect();

    /* Read the IP parameter */
    sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&IsDHCP,&len,
            (unsigned char *)&ipV4);

    //Print the IP
    UARTprintf("This node is at IP: %d.%d.%d.%d\n",  SL_IPV4_BYTE(ipV4.ipV4,3), SL_IPV4_BYTE(ipV4.ipV4,2), SL_IPV4_BYTE(ipV4.ipV4,1), SL_IPV4_BYTE(ipV4.ipV4,0));

    //
    // Loop forever waiting  for commands from PC...
    //
    while(1)
    {
        //
        // Print prompt for user.
        //
        UARTprintf("\n>");

        //
        // Peek to see if a full command is ready for processing.
        //
        while(UARTPeek('\r') == -1)
        {
            //
            // Approximately 1 millisecond delay.
            //
            ROM_SysCtlDelay(ROM_SysCtlClockGet() / 3000);
        }

        //
        // A '\r' was detected so get the line of text from the receive buffer.
        //
        UARTgets(g_cInput,sizeof(g_cInput));

        //
        // Pass the line from the user to the command processor.
        // It will be parsed and valid commands executed.
        //
        i32CommandStatus = CmdLineProcess(g_cInput);

        //
        // Handle the case of bad command.
        //
        if(i32CommandStatus == CMDLINE_BAD_CMD)
        {
            UARTprintf("    Bad command. Try again.\n");
        }
        //
        // Handle the case of too many arguments.
        //
        else if(i32CommandStatus == CMDLINE_TOO_MANY_ARGS)
        {
            UARTprintf("    Too many arguments for command. Try again.\n");
        }
        //
        // Handle the case of too few arguments.
        //
        else if(i32CommandStatus == CMDLINE_TOO_FEW_ARGS)
        {
            UARTprintf("    Too few arguments for command. Try again.\n");
        }
        //
        // Handle the case of too few arguments.
        //
        else if(i32CommandStatus == CMDLINE_INVALID_ARG)
        {
            UARTprintf("    Invalid command argument(s). Try again.\n");
        }
    }
    
}
开发者ID:manavm,项目名称:Classes,代码行数:99,代码来源:starter1.c



注:本文中的sl_NetCfgGet函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sl_Start函数代码示例发布时间:2022-05-30
下一篇:
C++ slReverse函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap