本文整理汇总了C++中os_timer_setfn函数的典型用法代码示例。如果您正苦于以下问题:C++ os_timer_setfn函数的具体用法?C++ os_timer_setfn怎么用?C++ os_timer_setfn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了os_timer_setfn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: object_init_pool
void ICACHE_FLASH_ATTR object_init_pool(const struct object_config** object_configs)
{
struct object* object;
const struct object_config** config;
uint32_t cnt = 0, daemon_timeout_ms = 0;
// Count the objects
for(config=object_configs; *config != NULL; ++config, ++cnt);
global_objects = (struct object*) os_zalloc(sizeof(struct object) * (cnt + 1));
for(object=global_objects,config=object_configs; *config != NULL; ++object,++config)
{
object->config = *config;
if(object->config->init != NULL)
object->config->init(object, &daemon_timeout_ms);
if((object->config->daemon != NULL) && (daemon_timeout_ms != 0))
{
os_timer_setfn(&object->daemon, object_daemon_task, object);
os_timer_arm(&object->daemon, daemon_timeout_ms, 1);
object_daemon_task(object);
}
}
}
示例2: cgiWiFiConnStatus
int ICACHE_FLASH_ATTR cgiWiFiConnStatus(HttpdConnData *connData) {
char buff[1024];
int len;
if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up.
jsonHeader(connData, 200);
len = os_sprintf(buff, "{");
len += printWifiInfo(buff+len);
len += os_sprintf(buff+len, ", ");
if (wifiReason != 0) {
len += os_sprintf(buff+len, "\"reason\": \"%s\", ", wifiGetReason());
}
#if 0
// commented out 'cause often the client that requested the change can't get a request in to
// find out that it succeeded. Better to just wait the std 15 seconds...
int st=wifi_station_get_connect_status();
if (st == STATION_GOT_IP) {
if (wifi_get_opmode() != 1) {
// Reset into AP-only mode sooner.
os_timer_disarm(&resetTimer);
os_timer_setfn(&resetTimer, resetTimerCb, NULL);
os_timer_arm(&resetTimer, 1000, 0);
}
}
#endif
len += os_sprintf(buff+len, "\"x\":0}\n");
//DBG(" -> %s\n", buff);
httpdSend(connData, buff, len);
return HTTPD_CGI_DONE;
}
示例3: syslog_timer_arm
static void ICACHE_FLASH_ATTR syslog_timer_arm(int delay) {
static os_timer_t wifi_chk_timer = {};
syslog_timer_armed = true;
os_timer_disarm(&wifi_chk_timer);
os_timer_setfn(&wifi_chk_timer, (os_timer_func_t *)syslog_chk_status, NULL);
os_timer_arm(&wifi_chk_timer, delay, 0);
}
示例4: ntp_get_time
void ICACHE_FLASH_ATTR ntp_get_time() {
ntp_t ntp;
// set up the udp "connection"
pCon = (struct espconn*)os_zalloc(sizeof(struct espconn));
pCon->type = ESPCONN_UDP;
pCon->state = ESPCONN_NONE;
pCon->proto.udp = (esp_udp*)os_zalloc(sizeof(esp_udp));
pCon->proto.udp->local_port = espconn_port();
pCon->proto.udp->remote_port = 123;
os_memcpy(pCon->proto.udp->remote_ip, ntp_server, 4);
// create a really simple ntp request packet
os_memset(&ntp, 0, sizeof(ntp_t));
ntp.options = 0b00100011; // leap = 0, version = 4, mode = 3 (client)
// set timeout timer
os_timer_disarm(&ntp_timeout);
os_timer_setfn(&ntp_timeout, (os_timer_func_t*)ntp_udp_timeout, pCon);
os_timer_arm(&ntp_timeout, NTP_TIMEOUT_MS, 0);
// send the ntp request
espconn_create(pCon);
espconn_regist_recvcb(pCon, ntp_udp_recv);
espconn_sent(pCon, (uint8*)&ntp, sizeof(ntp_t));
}
示例5: wifi_check_ip
static void ICACHE_FLASH_ATTR wifi_check_ip(void *arg)
{
os_timer_disarm(&WiFiLinker);
switch(wifi_station_get_connect_status())
{
case STATION_GOT_IP:
wifi_get_ip_info(STATION_IF, &ipConfig);
if(ipConfig.ip.addr != 0) {
connState = WIFI_CONNECTED;
os_printf("WiFi connected\r\n");
} else {
connState = WIFI_CONNECTING_ERROR;
os_printf("WiFi connected, ip.addr is null\r\n");
}
break;
case STATION_WRONG_PASSWORD:
connState = WIFI_CONNECTING_ERROR;
os_printf("WiFi connecting error, wrong password\r\n");
break;
case STATION_NO_AP_FOUND:
connState = WIFI_CONNECTING_ERROR;
os_printf("WiFi connecting error, ap not found\r\n");
break;
case STATION_CONNECT_FAIL:
connState = WIFI_CONNECTING_ERROR;
os_printf("WiFi connecting fail\r\n");
break;
default:
connState = WIFI_CONNECTING;
os_printf("WiFi connecting...\r\n");
}
os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);
os_timer_arm(&WiFiLinker, 2000, 0);
}
示例6: SysTickStart
/*******************************************************************************
* 名称: SysTick_Handler
* 功能: 系统时钟节拍1MS
* 形参:
* 返回: 无
* 说明:
*******************************************************************************/
void ICACHE_FLASH_ATTR
SysTickStart(void)
{
os_timer_disarm(&SystemSysTick);
os_timer_setfn(&SystemSysTick,(os_timer_func_t*)SysTick_Handler,NULL);
os_timer_arm(&SystemSysTick, 1, 1);
}
示例7: luaopen_tmr
int luaopen_tmr( lua_State *L ){
int i;
luaL_rometatable(L, "tmr.timer", (void *)tmr_dyn_map);
for(i=0; i<NUM_TMR; i++){
alarm_timers[i].lua_ref = LUA_NOREF;
alarm_timers[i].self_ref = LUA_REFNIL;
alarm_timers[i].mode = TIMER_MODE_OFF;
os_timer_disarm(&alarm_timers[i].os);
}
last_rtc_time=system_get_rtc_time(); // Right now is time 0
last_rtc_time_us=0;
os_timer_disarm(&rtc_timer);
os_timer_setfn(&rtc_timer, rtc_callback, NULL);
os_timer_arm(&rtc_timer, 1000, 1);
SWTIMER_REG_CB(rtc_callback, SWTIMER_RESUME);
//The function rtc_callback calls the a function that calibrates the SoftRTC for drift in the esp8266's clock.
//My guess: after the duration of light_sleep there's bound to be some drift in the clock, so a calibration is due.
SWTIMER_REG_CB(alarm_timer_common, SWTIMER_RESUME);
//The function alarm_timer_common handles timers created by the developer via tmr.create().
//No reason not to resume the timers, so resume em'.
return 0;
}
示例8: connected_cloud_cb
void ICACHE_FLASH_ATTR connected_cloud_cb(void* param)
{
uint8 rcvbuf[16];
struct espconn* conn = (struct espconn*)param;
os_printf("connected_cloud_cb, conn: [%p]\n", conn);
client_status = STATUS_CONNECTED;
//注册 断开与接收、发送的回调
espconn_regist_recvcb(conn, data_received_cb);
espconn_regist_sentcb(conn, sent_cloud_cb);
espconn_regist_disconcb(conn, disconnected_cloud_cb);
//注册心跳回调
heart_timer* pheart = (heart_timer*)os_zalloc(sizeof(heart_timer));
ETSTimer* timer = (ETSTimer*)os_zalloc(sizeof(ETSTimer));
pheart->timer = timer;
pheart->conn = conn;
conn->reverse = (void*)pheart;
os_timer_disarm(timer);
os_timer_setfn(timer, heart_beat_cbfn, pheart);
os_timer_arm(timer, 120000, 1);//两分钟一个心跳包, 重复
uint32* pchipid = (uint32*)(rcvbuf + 2);
rcvbuf[0] = 7;
rcvbuf[1] = 0;
*pchipid = system_get_chip_id();
rcvbuf[6] = 1;
espconn_sent(conn, rcvbuf, 7);
os_printf("DEV RP OVER\n");
}
示例9: cgiWiFiConnect
//This cgi uses the routines above to connect to a specific access point with the
//given ESSID using the given password.
CgiStatus ICACHE_FLASH_ATTR cgiWiFiConnect(HttpdConnData *connData) {
char essid[128];
char passwd[128];
static os_timer_t reassTimer;
if (connData->isConnectionClosed) {
//Connection aborted. Clean up.
return HTTPD_CGI_DONE;
}
httpdFindArg(connData->post.buff, "essid", essid, sizeof(essid));
httpdFindArg(connData->post.buff, "passwd", passwd, sizeof(passwd));
strncpy((char*)stconf.ssid, essid, 32);
strncpy((char*)stconf.password, passwd, 64);
//Schedule disconnect/connect
os_timer_disarm(&reassTimer);
os_timer_setfn(&reassTimer, reassTimerCb, NULL);
//Set to 0 if you want to disable the actual reconnecting bit
connTryStatus = CONNTRY_WORKING;
#ifdef DEMO_MODE
httpdRedirect(connData, "/wifi");
#else
os_timer_arm(&reassTimer, 500, 0);
httpdRedirect(connData, "connecting.html");
#endif
return HTTPD_CGI_DONE;
}
示例10: user_check_ip
void ICACHE_FLASH_ATTR user_check_ip(uint8 reset_flag)
{
struct ip_info ipconfig;
os_timer_disarm(&check_sta_timer);
wifi_get_ip_info(STATION_IF, &ipconfig);
if (wifi_station_get_connect_status() == STATION_GOT_IP && ipconfig.ip.addr != 0)
{
fetch_code_from_cloud();
}
else
{
/* if there are wrong while connecting to some AP, then reset mode */
if ((wifi_station_get_connect_status() == STATION_WRONG_PASSWORD ||
wifi_station_get_connect_status() == STATION_NO_AP_FOUND ||
wifi_station_get_connect_status() == STATION_CONNECT_FAIL))
{
//TODO: reconfig wifi!!!
//user_esp_platform_reset_mode();
} else {
os_timer_setfn(&check_sta_timer, (os_timer_func_t *)user_check_ip, NULL);
os_timer_arm(&check_sta_timer, 100, 0);
}
}
}
示例11: light_pwm_dh_adj_proc
void light_pwm_dh_adj_proc(void *Targ)
{
uint8 i;
for(i=0;i<PWM_CHANNEL;i++){
duty_now[i] = (duty_now[i]*7 + current_duty[i])>>3;
if( ABS_MINUS(duty_now[i],current_duty[i])<20 ){
duty_now[i] = current_duty[i];
}
user_light_set_duty(duty_now[i],i);
}
//printf("duty:%u,%u,%u\r\n", duty_now[0],duty_now[1],duty_now[2] );
// pwm_init(light_param.pwm_period, light_param.pwm_duty,PWM_CHANNEL,pwmio_info); //lujian
pwm_start();
if(check_pwm_current_duty_diff()){
change_finish = 0;
os_timer_disarm(&timer_pwm_adj);
os_timer_setfn(&timer_pwm_adj, (os_timer_func_t *)light_pwm_dh_adj_proc, NULL);
os_timer_arm(&timer_pwm_adj, min_ms, 0);
}
else{
//printf("finish\n");
change_finish = 1;
//light_save_target_duty();
os_timer_disarm(&timer_pwm_adj);
light_pwm_smooth_adj_proc();
}
}
示例12: mg_ev_mgr_init
void mg_ev_mgr_init(struct mg_mgr *mgr) {
LOG(LL_INFO, ("%p Mongoose init, tq %p", mgr, s_mg_task_queue));
system_os_task(mg_lwip_task, MG_TASK_PRIORITY, s_mg_task_queue,
MG_TASK_QUEUE_LEN);
os_timer_setfn(&s_poll_tmr, mg_poll_timer_cb, mgr);
os_timer_arm(&s_poll_tmr, MG_POLL_INTERVAL_MS, 0 /* no repeat */);
}
示例13: mg_lwip_check_rexmit
static void mg_lwip_check_rexmit(void *arg) {
struct mg_mgr *mgr = (struct mg_mgr *) arg;
struct mg_connection *nc;
uint32_t now = system_get_time();
uint32_t next_rexmit_in_micros = ~0;
for (nc = mgr->active_connections; nc != NULL; nc = nc->next) {
struct mg_lwip_conn_state *cs = (struct mg_lwip_conn_state *) nc->sock;
if (nc->sock == INVALID_SOCKET || nc->flags & MG_F_UDP ||
nc->flags & MG_F_LISTENING || cs->pcb.tcp == NULL) {
continue;
}
if (cs->next_rexmit_ts_micros > 0 &&
time_left_micros(now, cs->next_rexmit_ts_micros) == 0) {
mg_lwip_rexmit(nc);
}
if (cs->next_rexmit_ts_micros > 0) {
uint32_t time_left = time_left_micros(now, cs->next_rexmit_ts_micros);
next_rexmit_in_micros = MIN(next_rexmit_in_micros, time_left);
}
}
if (next_rexmit_in_micros != ~0U) {
uint32_t delay_millis = 1;
delay_millis = next_rexmit_in_micros / 1000;
if (delay_millis == 0) delay_millis = 1;
os_timer_disarm(&s_rexmit_tmr);
os_timer_setfn(&s_rexmit_tmr, mg_lwip_check_rexmit, mgr);
os_timer_arm(&s_rexmit_tmr, delay_millis, 0 /* no repeat */);
}
}
示例14: GPIO_DIS_OUTPUT
// initialization
void IRrecv::enableIRIn() {
// initialize state machine variables
irparams.rcvstate = STATE_IDLE;
irparams.rawlen = 0;
// set pin modes
//PIN_FUNC_SELECT(IR_IN_MUX, IR_IN_FUNC);
GPIO_DIS_OUTPUT(irparams.recvpin);
// Initialize timer
os_timer_disarm(&timer);
os_timer_setfn(&timer, (os_timer_func_t *)read_timeout, &timer);
// ESP Attach Interrupt
ETS_GPIO_INTR_DISABLE();
ETS_GPIO_INTR_ATTACH(gpio_intr, NULL);
gpio_pin_intr_state_set(GPIO_ID_PIN(irparams.recvpin), GPIO_PIN_INTR_ANYEDGE);
ETS_GPIO_INTR_ENABLE();
//ETS_INTR_UNLOCK();
//attachInterrupt(irparams.recvpin, readIR, CHANGE);
//irReadTimer.initializeUs(USECPERTICK, readIR).start();
//os_timer_arm_us(&irReadTimer, USECPERTICK, 1);
//ets_timer_arm_new(&irReadTimer, USECPERTICK, 1, 0);
}
示例15: statusWifiUpdate
// change the wifi state
void ICACHE_FLASH_ATTR statusWifiUpdate(uint8_t state) {
wifiState = state;
// schedule an update (don't want to run into concurrency issues)
os_timer_disarm(&ledTimer);
os_timer_setfn(&ledTimer, ledTimerCb, NULL);
os_timer_arm(&ledTimer, 500, 0);
}