本文整理汇总了C++中sl_NetCfgGet函数的典型用法代码示例。如果您正苦于以下问题:C++ sl_NetCfgGet函数的具体用法?C++ sl_NetCfgGet怎么用?C++ sl_NetCfgGet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sl_NetCfgGet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
}
示例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;
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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
}
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}