void user_init(void)
{
	// Configure the UART
	uart_init(BIT_RATE_115200,0);
	// Enable system messages
	system_set_os_print(1);
	os_printf("\r\nSDK version: %s\n", system_get_sdk_version());
	os_printf("System init...\r\n");

	os_printf("ESP8266 is %s mode, restarting in %s mode...\r\n", WiFiMode[wifi_get_opmode()], WiFiMode[STATION_MODE]);
	setup_wifi_st_mode();
	if(wifi_get_phy_mode() != PHY_MODE_11N)
		wifi_set_phy_mode(PHY_MODE_11N);
	if(wifi_station_get_auto_connect() == 0)
		wifi_station_set_auto_connect(1);

	// Init DHT22 sensor
	DHTInit(DHT22);

	// Wait for Wi-Fi connection
	os_timer_disarm(&WiFiLinker);
	os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);
	os_timer_arm(&WiFiLinker, 1000, 0);

	// Set up a timer to send the message
	os_timer_disarm(&dht22_timer);
	os_timer_setfn(&dht22_timer, (os_timer_func_t *)dht22_cb, (void *)0);
	os_timer_arm(&dht22_timer, DATA_SEND_DELAY, 1);

	os_printf("System init done.\n");
}
void ICACHE_FLASH_ATTR dhconnector_init(dhconnector_command_json_cb cb) {
	dhrequest_load_settings();
	mCommandCallback = cb;
	mConnectionState = CS_DISCONNECT;

	dhrequest_create_info(&mInfoRequest);
	dhrequest_create_register(&mRegisterRequest);
	mPollRequest.len = mPollRequest.data[0] = 0;

	wifi_set_opmode(STATION_MODE);
	wifi_station_set_auto_connect(1);
	wifi_station_set_reconnect_policy(true);
	struct station_config stationConfig;
	wifi_station_get_config(&stationConfig);
	wifi_set_phy_mode(PHY_MODE_11N);
	os_memset(stationConfig.ssid, 0, sizeof(stationConfig.ssid));
	os_memset(stationConfig.password, 0, sizeof(stationConfig.password));
	snprintf(stationConfig.ssid, sizeof(stationConfig.ssid), "%s", dhsettings_get_wifi_ssid());
	snprintf(stationConfig.password, sizeof(stationConfig.password), "%s", dhsettings_get_wifi_password());
	wifi_station_set_config(&stationConfig);

	static esp_tcp tcp;
	os_memset(&tcp, 0, sizeof(tcp));
	os_memset(&mDHConnector, 0, sizeof(mDHConnector));
	mDHConnector.type = ESPCONN_TCP;
	mDHConnector.state = ESPCONN_NONE;
	mDHConnector.proto.tcp = &tcp;
	mDHConnector.proto.tcp->local_port = espconn_port();

	wifi_set_event_handler_cb(wifi_state_cb);
}
Beispiel #3
0
static int wifi_setphymode( lua_State* L )
{
  unsigned mode;

  mode = luaL_checkinteger( L, 1 );

  if ( mode != PHY_MODE_11B && mode != PHY_MODE_11G && mode != PHY_MODE_11N )
    return luaL_error( L, "wrong arg type" );
  wifi_set_phy_mode( (uint8_t)mode);
  mode = (unsigned)wifi_get_phy_mode();
  lua_pushinteger( L, mode );
  return 1;
}
Beispiel #4
0
/*JSON{
  "type"     : "staticmethod",
  "class"    : "ESP8266WiFi",
  "name"     : "init",
  "generate" : "jswrap_ESP8266WiFi_init"
}*/
void jswrap_ESP8266WiFi_init() {
  os_printf("> jswrap_ESP8266WiFi_init\n");
  // register the state change handler so we get debug printout for sure
  wifi_set_phy_mode(2);
  wifi_set_event_handler_cb(wifiEventHandler);
  os_printf("Wifi init, mode=%d\n", wifi_get_opmode());
  wifi_station_set_hostname("espruino");

  netInit_esp8266_board();
  setupJsNetwork();
  networkState = NETWORKSTATE_ONLINE;
  os_printf("< jswrap_ESP8266WiFi_init\n");
}
Beispiel #5
0
void ICACHE_FLASH_ATTR wifiInit(int wifiMode)
{
INFO("\r===== WiFi Init =====\r");

wifi_set_opmode(0); // Clear all modes
INFO("\r\nSetting WiFI\r\n");

if(wifiMode & SOFTAP_MODE)
	{
	INFO("\rSetting SOFTAP Mode\r\n");
	setup_wifi_ap_mode();
	INFO("Done\r\n");
	}

if(wifiMode & STATION_MODE)
	{
	INFO("\rSetting Station Mode \r\n");
	setup_wifi_st_mode();
	INFO("Done\r\n");
	}

if(wifi_get_phy_mode() != PHY_MODE_11N)
	wifi_set_phy_mode(PHY_MODE_11N);
if(wifi_station_get_auto_connect() == 0)
	wifi_station_set_auto_connect(1);

INFO("Wi-Fi mode: %s\r\n", WiFiMode[wifi_get_opmode()]);
if(wifiMode & SOFTAP_MODE)
	{
	struct softap_config apConfig;
	if(wifi_softap_get_config(&apConfig))
		{
		INFO("AP config: SSID: %s, PASSWORD: %s\r\n",
			apConfig.ssid,
			apConfig.password);
		}
	}
if(wifiMode & STATION_MODE)
	{
	struct station_config stationConfig;
	if(wifi_station_get_config(&stationConfig))
		{
		INFO("STA config: SSID: %s, PASSWORD: %s\r\n",
			stationConfig.ssid,
			stationConfig.password);
		}
	}
}
Beispiel #6
0
void ICACHE_FLASH_ATTR connectToAp() {
    char * ap = "LedAccess";
    char * pass = "******";
    wifi_set_phy_mode( PHY_MODE_11N );

    struct station_config apconf;
    wifi_station_set_auto_connect(true);
    wifi_set_opmode(STATION_MODE);
    wifi_station_get_config(&apconf);
    strncpy((char*)apconf.ssid, ap, 32);
    printf("connecting to: %s", apconf.ssid);
    strncpy((char*)apconf.password, pass, 64);
    wifi_station_set_config(&apconf);
    wifi_promiscuous_enable(1);
    //wifi_set_event_handler_cb(wifi_event_cb);
}
LOCAL void ICACHE_FLASH_ATTR setup_ap_mode() {
	wifi_station_disconnect();
	wifi_station_dhcpc_stop();

	wifi_set_opmode(SOFTAP_MODE);

	struct softap_config apconfig;

	if (wifi_softap_get_config(&apconfig)) {
		wifi_softap_dhcps_stop();
		char macaddr[6];
		wifi_get_macaddr(SOFTAP_IF, macaddr);

		os_memset(apconfig.ssid, 0, sizeof(apconfig.ssid));
		os_memset(apconfig.password, 0, sizeof(apconfig.password));
		apconfig.ssid_len = os_sprintf(apconfig.ssid, "MacGyver-IoT_%02x%02x%02x%02x%02x%02x", MAC2STR(macaddr));
		//os_sprintf(apconfig.password, "%02x%02x%02x%02x%02x%02x", MAC2STR(macaddr)); // 18fe349bc6b6
		//os_sprintf(apconfig.password, "test"); // 18fe349bc6b6
		//apconfig.authmode = AUTH_WPA_WPA2_PSK; // AUTH_OPEN
		apconfig.authmode = AUTH_OPEN;
		apconfig.ssid_hidden = 0;
		apconfig.channel = 7;
		apconfig.max_connection = 10;

		if (!wifi_softap_set_config(&apconfig)) {
			// CTRL not set AP config!
		}

		struct ip_info ipinfo;
		if (wifi_get_ip_info(SOFTAP_IF, &ipinfo)) {
			IP4_ADDR(&ipinfo.ip, 192, 168, 4, 1);
			IP4_ADDR(&ipinfo.gw, 192, 168, 4, 1);
			IP4_ADDR(&ipinfo.netmask, 255, 255, 255, 0);
			if (!wifi_set_ip_info(SOFTAP_IF, &ipinfo)) {
				// CTRL not set IP config!
			}
		}

		wifi_softap_dhcps_start();

	}

	if (wifi_get_phy_mode() != PHY_MODE_11N)
		wifi_set_phy_mode(PHY_MODE_11N);

}
Beispiel #8
0
/**
 * Configure AP mode
 * @user_init
 */
LOCAL void ICACHE_FLASH_ATTR esp_wifi_setup_apmode( void )
{
    struct softap_config admin_config;

    // set to 802.11g so AP mode can work
	wifi_set_phy_mode( PHY_MODE_11G );

    // setup IP settings for access point
    esp_wifi_setup_apmode_ip();
 esp_wifi_setup_dhcp_server();
    // setup apmode login
    esp_wifi_setup_apmode_connection( &admin_config );
   
    // set wifi max connections
	admin_config.channel = 4;
	admin_config.max_connection = 4;
    // save admin configuration
	wifi_softap_set_config( &admin_config );
}
Beispiel #9
0
void ICACHE_FLASH_ATTR wifiInit()
{
	//if(wifi_get_opmode() != USE_WIFI_MODE)
	{
		#ifdef PLATFORM_DEBUG
		os_printf("ESP8266 not in %s mode, restarting in %s mode...\r\n", WiFiMode[USE_WIFI_MODE], WiFiMode[USE_WIFI_MODE]);
		#endif
		if(USE_WIFI_MODE & SOFTAP_MODE)
			setup_wifi_ap_mode();
		if(USE_WIFI_MODE & STATION_MODE)
			setup_wifi_st_mode();
	}
	if(wifi_get_phy_mode() != PHY_MODE_11N)
		wifi_set_phy_mode(PHY_MODE_11N);
	if(wifi_station_get_auto_connect() == 0)
		wifi_station_set_auto_connect(1);

	#ifdef PLATFORM_DEBUG
	os_printf("Wi-Fi mode: %s\r\n", WiFiMode[wifi_get_opmode()]);
	if(USE_WIFI_MODE & SOFTAP_MODE)
	{
		struct softap_config apConfig;
		if(wifi_softap_get_config(&apConfig)) {
			os_printf("AP config: SSID: %s, PASSWORD: %s\r\n",
				apConfig.ssid,
				apConfig.password);
		}
	}
	if(USE_WIFI_MODE & STATION_MODE)
	{
		struct station_config stationConfig;
		if(wifi_station_get_config(&stationConfig)) {
			os_printf("STA config: SSID: %s, PASSWORD: %s\r\n",
				stationConfig.ssid,
				stationConfig.password);
		}
	}
	#endif
}
Beispiel #10
0
void user_init(void)
{
	// Configure the UART
	uart_init(BIT_RATE_115200, BIT_RATE_115200);
	// Enable system messages
	system_set_os_print(1);
	DHT22_DEBUG("\n==== System info: ====\n");
	DHT22_DEBUG("SDK version:%s rom %d\n", system_get_sdk_version(), system_upgrade_userbin_check());
	DHT22_DEBUG("Time = %ld\n", system_get_time());
	DHT22_DEBUG("Chip id = 0x%x\n", system_get_chip_id());
	DHT22_DEBUG("CPU freq = %d MHz\n", system_get_cpu_freq());
	DHT22_DEBUG("Flash size map = %s\n", FlashSizeMap[system_get_flash_size_map()]);
	DHT22_DEBUG("Free heap size = %d\n", system_get_free_heap_size());
	DHT22_DEBUG("==== End System info ====\n");
	os_delay_us(10000);
	DHT22_DEBUG("System init...\r\n");

	if(wifi_get_opmode() != STATION_MODE)
	{
		DHT22_DEBUG("ESP8266 is %s mode, restarting in %s mode...\r\n", WiFiMode[wifi_get_opmode()], WiFiMode[STATION_MODE]);
		setup_wifi_st_mode();
	}
	if(wifi_get_phy_mode() != PHY_MODE_11N)
		wifi_set_phy_mode(PHY_MODE_11N);
	if(wifi_station_get_auto_connect() == 0)
		wifi_station_set_auto_connect(1);


	// Wait for Wi-Fi connection
	os_timer_disarm(&WiFiLinker);
	os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);
	os_timer_arm(&WiFiLinker, WIFI_CHECK_DELAY, 0);

	UDP_Init();

	DHT22_DEBUG("System init done.\n");
}
/**
 * set phy Mode
 * @param mode phy_mode_t
 * @return bool
 */
bool ESP8266WiFiGenericClass::setPhyMode(WiFiPhyMode_t mode) {
    return wifi_set_phy_mode((phy_mode_t) mode);
}
Beispiel #12
0
//Read configuration settings and apply them
bool WIFI_CONFIG::Setup()
{
    char pwd[MAX_PASSWORD_LENGTH+1];
    char sbuf[MAX_SSID_LENGTH+1];
    char hostname [MAX_HOSTNAME_LENGTH+1];
    int wstatus;
    IPAddress currentIP;
    byte bflag=0;

    //set the sleep mode
    if (!CONFIG::read_byte(EP_SLEEP_MODE, &bflag )) {
        return false;
    }
    wifi_set_sleep_type ((sleep_type)bflag);
    sleep_mode=bflag;
    //AP or client ?
    if (!CONFIG::read_byte(EP_WIFI_MODE, &bflag ) ||  !CONFIG::read_string(EP_SSID, sbuf , MAX_SSID_LENGTH) ||!CONFIG::read_string(EP_PASSWORD, pwd , MAX_PASSWORD_LENGTH)) {
        return false;
    }
    if (!CONFIG::read_string(EP_HOSTNAME, hostname , MAX_HOSTNAME_LENGTH)) {
        strcpy(hostname,get_default_hostname());
    }
    //disconnect if connected
    WiFi.disconnect();
    //this is AP mode
    if (bflag==AP_MODE) {
        //setup Soft AP
        WiFi.mode(WIFI_AP);
        WiFi.softAP(sbuf, pwd);
        //setup PHY_MODE
        if (!CONFIG::read_byte(EP_PHY_MODE, &bflag )) {
            return false;
        }
        wifi_set_phy_mode((phy_mode)bflag);
        //get current config
        struct softap_config apconfig;
        wifi_softap_get_config(&apconfig);
        //set the chanel
        if (!CONFIG::read_byte(EP_CHANNEL, &bflag )) {
            return false;
        }
        apconfig.channel=bflag;
        //set Authentification type
        if (!CONFIG::read_byte(EP_AUTH_TYPE, &bflag )) {
            return false;
        }
        apconfig.authmode=(AUTH_MODE)bflag;
        //set the visibility of SSID
        if (!CONFIG::read_byte(EP_SSID_VISIBLE, &bflag )) {
            return false;
        }
        apconfig.ssid_hidden=!bflag;
        //no need to add these settings to configuration just use default ones
        apconfig.max_connection=DEFAULT_MAX_CONNECTIONS;
        apconfig.beacon_interval=DEFAULT_BEACON_INTERVAL;
        //apply settings to current and to default
        if (!wifi_softap_set_config(&apconfig) || !wifi_softap_set_config_current(&apconfig)) {
            Serial.println(F("M117 Error Wifi AP!"));
            delay(1000);
        }
    } else {
        //setup station mode
        WiFi.mode(WIFI_STA);
        WiFi.begin(sbuf, pwd);
        delay(500);
        //setup PHY_MODE
        if (!CONFIG::read_byte(EP_PHY_MODE, &bflag )) {
            return false;
        }
        wifi_set_phy_mode((phy_mode)bflag);
        delay(500);
        byte i=0;
        //try to connect
        while (WiFi.status() != WL_CONNECTED && i<40) {
            switch(WiFi.status()) {
            case 1:
                Serial.print(FPSTR(M117_));
                Serial.println(F("No SSID found!"));
                break;

            case 4:
                Serial.print(FPSTR(M117_));
                Serial.println(F("No Connection!"));
                break;

            default:
                Serial.print(FPSTR(M117_));
                Serial.println(F("Connecting..."));
                break;
            }
            delay(500);
            i++;
        }
        if (WiFi.status() != WL_CONNECTED) {
            return false;
        }
        WiFi.hostname(hostname);
    }

    //DHCP or Static IP ?
    if (!CONFIG::read_byte(EP_IP_MODE, &bflag )) {
        return false;
    }
    if (bflag==STATIC_IP_MODE) {
        byte ip_buf[4];
        //get the IP
        if (!CONFIG::read_buffer(EP_IP_VALUE,ip_buf , IP_LENGTH)) {
            return false;
        }
        IPAddress local_ip (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
        //get the gateway
        if (!CONFIG::read_buffer(EP_GATEWAY_VALUE,ip_buf , IP_LENGTH)) {
            return false;
        }
        IPAddress gateway (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
        //get the mask
        if (!CONFIG::read_buffer(EP_MASK_VALUE,ip_buf , IP_LENGTH)) {
            return false;
        }
        IPAddress subnet (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
        //apply according active wifi mode
        if (wifi_get_opmode()==WIFI_AP || wifi_get_opmode()==WIFI_AP_STA) {
            WiFi.softAPConfig( local_ip,  gateway,  subnet);
        } else {
            WiFi.config( local_ip,  gateway,  subnet);
        }
    }
#ifdef MDNS_FEATURE
    // Set up mDNS responder:
    if (!mdns.begin(hostname)) {
        Serial.print(FPSTR(M117_));
        Serial.println(F("Error with mDNS!"));
        delay(1000);
    }
#endif
    //Get IP
    if (wifi_get_opmode()==WIFI_STA) {
        currentIP=WiFi.localIP();
    } else {
        currentIP=WiFi.softAPIP();
    }
    Serial.print(FPSTR(M117_));
    Serial.println(currentIP);
    return true;
}
Beispiel #13
0
bool  Wifi::dispatch(Msg& msg) {
//	INFO("line : %d ",_ptLine);
// INFO("msg : %d:%d",msg.src(),msg.signal());
PT_BEGIN();
INIT : {
	PT_WAIT_UNTIL(msg.is(0,SIG_INIT));
	struct station_config stationConf;

	INFO("WIFI_INIT");
	if ( wifi_set_opmode(STATION_MODE) ){
		; // STATIONAP_MODE was STATION_MODE
		INFO("line : %d",__LINE__);
		if ( wifi_set_phy_mode(PHY_MODE_11B)) {
			os_memset(&stationConf, 0, sizeof(struct station_config));
			ets_strncpy((char*)stationConf.ssid,_ssid,sizeof(stationConf.ssid));
			ets_strncpy((char*)stationConf.password,_pswd,sizeof(stationConf.password));
			stationConf.bssid_set=0;
			INFO("line : %d",__LINE__);
			if ( wifi_station_set_config(&stationConf) ){
				if ( wifi_station_connect() ){
					INFO("line : %d",__LINE__);
					goto DISCONNECTED;//	wifi_station_set_auto_connect(TRUE);
				}
			}
		}
	}
	//	wifi_station_set_auto_connect(FALSE);
	INFO(" WIFI INIT failed , retrying... ");
	goto INIT;
};
DISCONNECTED: {
	while(true) {
		timeout(1000);
		PT_YIELD_UNTIL(timeout());
		struct ip_info ipConfig;
		wifi_get_ip_info(STATION_IF, &ipConfig);
		wifiStatus = wifi_station_get_connect_status();
		if ( wifi_station_get_connect_status()== STATION_NO_AP_FOUND || wifi_station_get_connect_status()==STATION_WRONG_PASSWORD || wifi_station_get_connect_status()==STATION_CONNECT_FAIL)
		{
			INFO(" NOT CONNECTED ");
			wifi_station_connect();
		} else if (wifiStatus == STATION_GOT_IP && ipConfig.ip.addr != 0) {
			_connections++;
			union {
				uint32_t addr;
				uint8_t ip[4];
			} v;
			v.addr = ipConfig.ip.addr;
			INFO("  IP Address : %d.%d.%d.%d ",v.ip[0],v.ip[1],v.ip[2],v.ip[3]);
			INFO(" CONNECTED ");
			Msg::publish(this,SIG_CONNECTED);
			_connected=true;
			timeout(2000);
			goto CONNECTED;
		} else {
			INFO(" STATION_IDLE ");
		}
		timeout(500);
	}
};
CONNECTED : {
	while(true) {
		PT_YIELD_UNTIL(timeout());
		struct ip_info ipConfig;
		wifi_get_ip_info(STATION_IF, &ipConfig);
		wifiStatus = wifi_station_get_connect_status();
		if (wifiStatus != STATION_GOT_IP ) {
			Msg::publish(this,SIG_DISCONNECTED);
			timeout(500);
			_connected=false;
			goto DISCONNECTED;
		}
		timeout(2000);
	}

};
PT_END();

}
Beispiel #14
0
void user_init(void)
{
	uint8_t i;



	UartDev.data_bits = EIGHT_BITS;
	UartDev.parity = NONE_BITS;
	UartDev.stop_bits = ONE_STOP_BIT;
	uart_init(BIT_RATE_9600, BIT_RATE_9600);


	i2c_init();
	SSD1306Init();
	clearScreen();
	stringDraw(1, 1, "SDK ver:");
	stringDraw(1, 48, (char*)system_get_sdk_version());


	ets_uart_printf("reset reason: %d\n", reset_info->reason);
	ets_uart_printf("Booting...\n");
	ets_uart_printf("SDK version:%s\n", system_get_sdk_version());

	setup_wifi_st_mode();
	if(wifi_get_phy_mode() != PHY_MODE_11N)
		wifi_set_phy_mode(PHY_MODE_11N);
	if(wifi_station_get_auto_connect() == 0)
		wifi_station_set_auto_connect(1);



#ifdef CONFIG_DYNAMIC
	flash_param_t *flash_param;
	flash_param_init();
	flash_param = flash_param_get();
	UartDev.data_bits = GETUART_DATABITS(flash_param->uartconf0);
	UartDev.parity = GETUART_PARITYMODE(flash_param->uartconf0);
	UartDev.stop_bits = GETUART_STOPBITS(flash_param->uartconf0);
	uart_init(flash_param->baud, BIT_RATE_115200);
#else

#endif
	ets_uart_printf("size flash_param_t %d\n", sizeof(flash_param_t));




#ifdef CONFIG_GPIO
	config_gpio();
#endif



	//		os_timer_disarm(&timer_1);
	//		os_timer_setfn(&timer_1, (os_timer_func_t *)timer_1_int, NULL);
	//		os_timer_arm(&timer_1, 1000, 1);

	// Wait for Wi-Fi connection
	os_timer_disarm(&WiFiLinker);
	os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);
	os_timer_arm(&WiFiLinker, 1000, 0);




	system_os_task(recvTask, recvTaskPrio, recvTaskQueue, recvTaskQueueLen);
}
Beispiel #15
0
static void ICACHE_FLASH_ATTR myTimer(void *arg)
{
	static int thistik;
	static int waittik;
	thistik++;

	CSTick( 0 );

//	wifi_set_user_fixed_rate( 3, 0x0b );  //0xb = 6Mbit G
//	wifi_set_user_fixed_rate( 3, 0x0c );  //0xc = 54Mbit G
//	wifi_set_user_fixed_rate( 3, 0x07 );  //0x7 = 11Mbit ... B?

	//0x02 = 5.5Mbit/s (B)
	//0x01 = 2Mbit/s (B)
	//0x00 = 1Mbit/s (B)
	//0x10 = 6.5MBit
	//0x11 = 13MBit
	//0x1f = 72.2Mbit/s
//	wifi_set_phy_mode(PHY_MODE_11N);
	wifi_set_phy_mode(PHY_MODE_11G); //??? Maybe - I haven't been doing this...

	wifi_set_user_fixed_rate( 3, 0x0c );

//	wifi_set_user_limit_rate_mask( 3 );
//	wifi_set_user_rate_limit( FIXED_RATE_MASK_ALL, 0, 1, 1 );

	if( thistik == waittik-3 )
	{
		int i;
		static int did_init = 0;

		if( !did_init && printed_ip )
		{
			//For sending raw packets.
			//SetupRawsend();
			wifi_set_raw_recv_cb( rx_func );

			wifi_register_send_pkt_freedom_cb( sent_freedom_cb );

			did_init = 1;

			//Setup our send packet with our MAC address.
			wifi_get_macaddr(STATION_IF, mypacket + 10);
			debugccount = 0;

			//printf( "!!!\n" );
		}


		//printf( "%d\n", debugccount );
		//uart0_sendStr("k");
		ets_strcpy( mypacket+30, "ESPEED" );
		txpakid++;
		mypacket[36] = txpakid>>24;
		mypacket[37] = txpakid>>16;
		mypacket[38] = txpakid>>8;
		mypacket[39] = txpakid>>0;
		mypacket[40] = 0;
		mypacket[41] = 0;
		mypacket[42] = 0;
		mypacket[43] = 0;
	
		packet_tx_time = 0;
		wifi_send_pkt_freedom( mypacket, 30 + 16, true) ;  
		//Looks like we can actually set the speed --> wifi_set_user_fixed_rate( 3, 12 );
	}