예제 #1
0
파일: upnptest.c 프로젝트: kid0607/ssl
static int get_mac_addr(void)
{
	char *words[6]={NULL};
	char rsp[64]={0};
	char is_ap_mode=0;

	if(hfat_send_cmd("AT+WMODE\r\n",sizeof("AT+WMODE\r\n"),rsp,64)!=0)
		return 0;

	if(hfat_get_words(rsp,words, 6)>0)
	{
		if(strcmp("STA",words[1])==0)
		{
			is_ap_mode=0;
		}
	}

	/* get mac as device id */
	//u_printf("kim:words start\r\n");
	if(is_ap_mode)
	{
		hfat_send_cmd("AT+WAMAC\r\n",sizeof("AT+WAMAC\r\n"),rsp,64);
	}
	else
		hfat_send_cmd("AT+WSMAC\r\n",sizeof("AT+WSMAC\r\n"),rsp,64);	
	
		if(hfat_get_words(rsp,words, 6)>0)
	{
			strcpy(MAC,words[1]);
	}		
}
예제 #2
0
파일: upnptest.c 프로젝트: kid0607/ssl
static int get_if_ip_addr(void)
{
	char *words[6]={NULL};
	char rsp[64]={0};
	char is_ap_mode=0;

	if(hfat_send_cmd("AT+WMODE\r\n",sizeof("AT+WMODE\r\n"),rsp,64)!=0)
		return 0;

	if(hfat_get_words(rsp,words, 6)>0)
	{
		if(strcmp("STA",words[1])==0)
		{
			is_ap_mode=0;
		}
	}

	if(is_ap_mode)
	{
		hfat_send_cmd("AT+LANN\r\n",sizeof("AT+LANN\r\n"),rsp,64);
	}
	else
		hfat_send_cmd("AT+WANN\r\n",sizeof("AT+WANN\r\n"),rsp,64);
	
	if(hfat_get_words(rsp,words, 6)>0)
	{
		////u_printf("\nresult:%s\nmode:%s\nIP:%s\nMASK:%s\nGW:%s\n",words[0],words[1],words[2],words[3],words[4]);
				
		if(is_ap_mode)
		{
			 memcpy(local_ip,words[1],strlen(words[1]));
			 local_ip[strlen(words[1])] = '\0';
		}
		else
		{
			 memcpy(local_ip,words[2],strlen(words[2]));			
			 local_ip[strlen(words[2])] = '\0';
		}
		if(is_ap_mode)
			return inet_addr(words[1]);
		else
			return inet_addr(words[2]);
	}
	
	return 0;
}
예제 #3
0
파일: callbacktest.c 프로젝트: mys812/hf
static int USER_FUNC assis_ex_recv_callback(uint32_t event,char *data,uint32_t len,uint32_t buf_len)
{
	if(event == HFNET_ASSIS_DATA_READY)
	{
		char tmp[64]={0};
		char rsp[64]={0};
		char *ip[6]={0};
		char *mac[3]={0};
		char response[40]={0};

		uint32_t ip_addr;
		uint16_t port;
 	
		MEMCPY(&ip_addr, data+len, sizeof(struct ip_addr));
		Memcpy(&port, data+len+sizeof(struct ip_addr), sizeof(port));
		u_printf("ip:%s, port:%d\n", inet_ntoa(ip_addr),port);
		
		MEMCPY(tmp, data, len);
		if(strcasecmp("HF-A11ASSISTHREAD", tmp)==0)
		{	
			hfat_send_cmd("AT+WANN\r\n", sizeof("AT+WANN\r\n"), rsp, 64);
			if(hfat_get_words(rsp, ip, 6)>0)
			{
				u_printf("local ip:%s\n", ip[2]);
				sprintf(response,"%s,",ip[2]);
			}

			memset(rsp, 0, sizeof(rsp));
			hfat_send_cmd("AT+WSMAC\r\n", sizeof("AT+WSMC\r\n"), rsp, 64);
			u_printf("AT+WSMAC's response:%s\n",rsp);
			if(hfat_get_words(rsp, mac, 3)>0)
			{
				u_printf("local mac:%s\n", mac[1]);
				strcat(response,mac[1]);
			}

			hfnet_assis_write(response, sizeof(response), ip_addr, port);
			
			return 0;
		}
	}
	return len;
}