Added blynk_syncAll to [19_m1284p_WIZNET_blynk]

master
maxxir 7 years ago
parent c0c9edca06
commit 89eb9fc3aa

@ -760,3 +760,14 @@ static void replacetonull(uint8_t * str, uint8_t c)
for (x = 0; str[x]; x++)
if (str[x] == c) str[x] = NULL;
}
uint8_t is_blynk_connection_available(void)
{
return blynk_connection_available;
}
//Requests Server to re-send current values for all widgets
void blynk_syncAll(void)
{
sendCmd(BLYNK_CMD_HARDWARE_SYNC, 0, NULL, 0, NULL, 0);
}

@ -79,6 +79,7 @@ enum BlynkCmd
BLYNK_CMD_EMAIL = 13,
BLYNK_CMD_PUSH_NOTIFICATION = 14,
BLYNK_CMD_BRIDGE = 15,
BLYNK_CMD_HARDWARE_SYNC = 16,
BLYNK_CMD_HARDWARE = 20
};
@ -136,6 +137,9 @@ BlynkParam;
void blynk_begin(uint8_t * auth, uint8_t * dest_ip, uint16_t dest_port, uint8_t * buf, uint8_t socket);
void blynk_run(void);
void blynk_time_handler(void);
//void blynk_time_handler(void);
uint8_t is_blynk_connection_available(void);
void sendCmd(uint8_t cmd, uint16_t id, uint8_t * data, size_t length, uint8_t * data2, size_t length2);
void blynk_syncAll(void);
#endif

@ -63,7 +63,7 @@ uint8_t Domain_IP[4] = {0, }; // Translated IP address by DNS S
* OK (v1.3)GPIO IN - fixed bug (remove redundant space symbol in <dw xx xx >)
* Virtual IN/OUT -Not fully supported yet, so decide not use here..
* OK (v1.4)Analog Read/Write
* Restore pins state on board reboot
* OK (v1.5)Restore pins state on board reboot
* OK ??3.Try fix frequent reconnection with blynk server - every ~22sec may be this OK.
* Need compare local blynk.c code with modern <blynk> library - (Too old version here - 0.2.1 (On git blynk March 2019 - 0.6.x) )
*
@ -100,7 +100,7 @@ volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days
//*********Program metrics
const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции
const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции
const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.4 Static IP BLYNK WIZNET_5500 ETHERNET 14/03/2019\r\n"; // Program name
const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.5 Static IP BLYNK WIZNET_5500 ETHERNET 14/03/2019\r\n"; // Program name
#if defined(__AVR_ATmega128__)
const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128
@ -497,7 +497,8 @@ int main()
/* Loopback Test: TCP Server and UDP */
// Test for Ethernet data transfer validation
uint32_t timer_link_1sec = millis();
uint32_t timer_tick_1sec = millis();
uint8_t blynk_restore_connection = 1;
while(1)
{
//Here at least every 1sec
@ -515,22 +516,23 @@ int main()
//loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport);
//if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code
//Shouldn't use it here
/*
if((millis()-timer_link_1sec)> 1000)
//Here every 1sec
if((millis()-timer_tick_1sec)> 1000)
{
//here every 1 sec
timer_link_1sec = millis();
if(wizphy_getphylink() == PHY_LINK_ON)
timer_tick_1sec = millis();
//To restore GPIO state on start-up application
if(blynk_restore_connection)
{
led1_high();
}
else
if(is_blynk_connection_available())
{
led1_low();
blynk_restore_connection = 0;
//Requests Server to re-send current values for all widgets
PRINTF("++blynk_syncAll event\r\n"); //Just for debug
blynk_syncAll();
}
}
}
*/
}
return 0;
}