-->
Page 3 of 9

Re: Native Smartmeter/datalogger

PostPosted: Wed Nov 19, 2014 10:22 am
by alonewolfx2
i am trying this but it cant work.chip is going to wdt reset. this is my code. have you any idea?

Code: Select allat_setupCmdCipStartLog(19,"=3,\"TCP\",\"192.168.2.69/new_value.php?d=5&o=4\",80");



Borstenhorst wrote:you might try to pass "="TCP","192.168.2.69/new_value.php?d=5&o=4",80"
to
at_setupCmdCipStartLog(uint8_t id, char *pPara)

you need to test where is a good place to do so or you might want to add a timer to fire an or find/implement a callback once the system is up.

Re: Native Smartmeter/datalogger

PostPosted: Wed Nov 19, 2014 11:50 am
by Borstenhorst
from where you doing this?

Re: Native Smartmeter/datalogger

PostPosted: Wed Nov 19, 2014 11:58 am
by alonewolfx2
Borstenhorst wrote:from where you doing this?

user_main.c

Re: Native Smartmeter/datalogger

PostPosted: Wed Nov 19, 2014 12:25 pm
by Borstenhorst
I present: the worst hack ever :P

This is just a 5 minute hack, not a proper implementation but.... it works.
The code is based on assumptions about the structure, so its really just a hack. Please dont make me responsible for this :p

The idea is that after 2 seconds the system should be up. If you have slow wifi, make it a bit longer to make sure the connection is up at that point.
The proper implementation would be to have an event fired once the device is connected and then checks if there is autorun config available in the flash.
But as I was not able to find information about how to write own configurations to the flash during runtime this is a future feature.


at_port.c
add call to hardcoded_connect();
Code: Select allvoid ICACHE_FLASH_ATTR
at_init(void)
{
  system_os_task(at_busyTask, at_busyTaskPrio, at_busyTaskQueue, at_busyTaskQueueLen);
  system_os_task(at_procTask, at_procTaskPrio, at_procTaskQueue, at_procTaskQueueLen);
  hardcoded_connect();
}


at_base_cmd.h

the new functions:
Code: Select allvoid hardcoded_connect();
void auto_setup_elapsed();


at_base_cmd.c
global timer
Code: Select allstatic volatile os_timer_t auto_setup;


and implementation, this is for a MUX=0
Code: Select allvoid hardcoded_connect()
{
   os_timer_disarm(&auto_setup);

   //Setup timer
   os_timer_setfn(&auto_setup, (os_timer_func_t *)auto_setup_elapsed, NULL);

   //Set up the timer, (timer, milliseconds, 1=cycle 0=once)
   os_timer_arm(&auto_setup, 2000, 0);
   

}

void auto_setup_elapsed()
{
   char temp[128];
   os_sprintf(temp,"=\"TCP\",\"yourURL\",80");
   
   at_setupCmdCipStartLog(19,temp);
}