예제 #1
0
uint32 ICACHE_FLASH_ATTR str_array_b(uint8 *s, uint8 *buf, uint32 max_buf)
{
	uint32 ret = 0;
	uint8 *sval = NULL;
	while(max_buf > ret) {
		if(sval == NULL) {
			if (*s == '-' && s[1] >= '0' && s[1] <= '9') {
				sval = s;
				s++;
			}
			else if (*s >= '0' && *s <= '9') sval = s;
		}
		if(*s == ',' || *s == '.' || *s <= ')') {
			if(sval != NULL) {
				*buf = ahextoul(sval);
				sval = NULL;
			}
			buf++;
			ret++;
			if(*s < ')') return ret;
		}
		s++;
	}
	return ret;
}
예제 #2
0
void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 *pvar)
{
    WEB_SRV_CONN *web_conn = (WEB_SRV_CONN *)ts_conn->linkd;
	uint32 val = ahextoul(pvar);
	char *cstr = pcmd;
#if DEBUGSOO > 1
    os_printf("[%s=%s]\n", pcmd, pvar);
#endif
	ifcmp("start") 		web_conn->udata_start = val;
	else ifcmp("stop") 	web_conn->udata_stop = val;
예제 #3
0
//-------------------------------------------------------------------------------
// TCP receive response from server
//-------------------------------------------------------------------------------
err_t ICACHE_FLASH_ATTR tc_recv(TCP_SERV_CONN *ts_conn) {
#if DEBUGSOO > 1
	tcpsrv_received_data_default(ts_conn);
#endif
	tcpsrv_unrecved_win(ts_conn);
    uint8 *pstr = ts_conn->pbufi;
    sint32 len = ts_conn->sizei;
#if DEBUGSOO > 4
    os_printf("IOT_Rec(%u): %s\n", len, pstr);
#endif
    os_memset(iot_last_status, 0, sizeof(iot_last_status));
    os_strncpy(iot_last_status, (char *)pstr, mMIN(sizeof(iot_last_status)-1, len)); // status/error
    iot_last_status_time = get_sntp_time();
	if(len >= sizeof(key_http_ok1) + 3 + sizeof(key_http_ok2)) {
		if(os_memcmp(pstr, key_http_ok1, sizeof(key_http_ok1)-1) == 0
				&& os_memcmp(pstr + sizeof(key_http_ok1)-1 + 3, key_http_ok2, sizeof(key_http_ok2)-1) == 0) { // Check - 200 OK?
			#if DEBUGSOO > 4
				os_printf(" - 200\n");
			#endif
	        uint8 *nstr = web_strnstr(pstr, "\r\n\r\n", len); // find body
	        if(nstr != NULL) {
	        	pstr = nstr + 4; // body start
	        	len -= nstr - pstr; // body size
		        uint8 *nstr = web_strnstr(pstr, "\r\n", len); // find next delimiter
		        if(nstr != NULL) *nstr = '\0';
	        	if(ahextoul(pstr)) { // not 0 = OK
	    			tc_init_flg &= ~TC_RUNNING; // clear run flag
	    			iot_data_processing->last_run = system_get_time();
					#if DEBUGSOO > 4
						os_printf("Ok!!!\n");
					#endif
	        	}
	        }
		}
	}
	//ts_conn->flag.rx_null = 1; // stop receiving data
   	tc_close();
	return ERR_OK;
}