• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ NODE_DBG函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NODE_DBG函数的典型用法代码示例。如果您正苦于以下问题:C++ NODE_DBG函数的具体用法?C++ NODE_DBG怎么用?C++ NODE_DBG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NODE_DBG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: myspiffs_set_cfg

/*
 * Returns  TRUE if FS was found
 * align must be a power of two
 */
static bool myspiffs_set_cfg(spiffs_config *cfg, int align, int offset, bool force_create) {
  cfg->phys_erase_block = INTERNAL_FLASH_SECTOR_SIZE; // according to datasheet
  cfg->log_page_size = LOG_PAGE_SIZE; // as we said

  cfg->hal_read_f = my_spiffs_read;
  cfg->hal_write_f = my_spiffs_write;
  cfg->hal_erase_f = my_spiffs_erase;

  if (!myspiffs_set_location(cfg, align, offset, LOG_BLOCK_SIZE)) {
    if (!myspiffs_set_location(cfg, align, offset, LOG_BLOCK_SIZE_SMALL_FS)) {
      return FALSE;
    }
  }

  NODE_DBG("fs.start:%x,max:%x\n",cfg->phys_addr,cfg->phys_size);

#ifdef SPIFFS_USE_MAGIC_LENGTH
  if (force_create) {
    return TRUE;
  }

  int size = SPIFFS_probe_fs(cfg);

  if (size > 0 && size < cfg->phys_size) {
    NODE_DBG("Overriding size:%x\n",size);
    cfg->phys_size = size;
  }
  if (size > 0) {
    return TRUE;
  }
  return FALSE;
#else
  return TRUE;
#endif
}
开发者ID:SolarTheCenter,项目名称:nodemcu-firmware,代码行数:39,代码来源:spiffs.c


示例2: deliver_publish

static void deliver_publish(lmqtt_userdata * mud, uint8_t* message, int length)
{
  NODE_DBG("enter deliver_publish.\n");
  if(mud == NULL)
    return;
  mqtt_event_data_t event_data;

  event_data.topic_length = length;
  event_data.topic = mqtt_get_publish_topic(message, &event_data.topic_length);

  event_data.data_length = length;
  event_data.data = mqtt_get_publish_data(message, &event_data.data_length);

  if(mud->cb_message_ref == LUA_NOREF)
    return;
  if(mud->self_ref == LUA_NOREF)
    return;
  if(mud->L == NULL)
    return;
  if(event_data.topic && (event_data.topic_length > 0)){
    lua_rawgeti(mud->L, LUA_REGISTRYINDEX, mud->cb_message_ref);
    lua_rawgeti(mud->L, LUA_REGISTRYINDEX, mud->self_ref);  // pass the userdata to callback func in lua
    lua_pushlstring(mud->L, event_data.topic, event_data.topic_length);
  } else {
    NODE_DBG("get wrong packet.\n");
    return;
  }
  if(event_data.data && (event_data.data_length > 0)){
    lua_pushlstring(mud->L, event_data.data, event_data.data_length);
    lua_call(mud->L, 3, 0);
  } else {
    lua_call(mud->L, 2, 0);
  }
  NODE_DBG("leave deliver_publish.\n");
}
开发者ID:pvvx,项目名称:EspLua,代码行数:35,代码来源:mqtt.c


示例3: http_server_cgi_execute

// CGI dispatcher for the http server
//
int ICACHE_FLASH_ATTR http_server_cgi_execute(http_connection * conn){

	NODE_DBG("http_execute_cgi");

	//request is finished and we should start sending response
	//if not final, cgi should not expect data to be sent
	uint8_t final = conn->state==HTTPD_STATE_BODY_END;

	if(conn->cgi.done)
		return 0;

	//Any CGI function already attached?
	if(conn->cgi.function!=NULL){ 

		NODE_DBG("Executing previous cgi ");

		int r;
		r=conn->cgi.function(conn);
		NODE_DBG("Cgi return is %d", r);
		
		if(r==HTTPD_CGI_DONE){
			conn->cgi.function=NULL; //mark for destruction
			conn->cgi.done=1;						
		}
		
		if(final)
			http_send_response(conn);

		if(r==HTTPD_CGI_MORE ||r==HTTPD_CGI_DONE){
			return 0;
		}		

	}
开发者ID:HaknCo,项目名称:esp-ginx,代码行数:35,代码来源:http_server.c


示例4: wifi_ap_dhcp_config

// Lua: ip = wifi.ap.dhcp.config()
static int wifi_ap_dhcp_config( lua_State* L )
{
  if (!lua_istable(L, 1))
    return luaL_error( L, "wrong arg type" );

  struct dhcps_lease lease;
  uint32_t ip;

  ip = parse_key(L, "start");
  if (ip == 0)
    return luaL_error( L, "wrong arg type" );

  lease.start_ip = ip;
  NODE_DBG(IPSTR, IP2STR(&lease.start_ip));
  NODE_DBG("\n");

  // use configured max_connection to determine end
  struct softap_config config;
  wifi_softap_get_config(&config);
  lease.end_ip = lease.start_ip;
  ip4_addr4(&lease.end_ip) += config.max_connection - 1;

  char temp[64];
  c_sprintf(temp, IPSTR, IP2STR(&lease.start_ip));
  lua_pushstring(L, temp);
  c_sprintf(temp, IPSTR, IP2STR(&lease.end_ip));
  lua_pushstring(L, temp);

  // note: DHCP max range = 101 from start_ip to end_ip
  wifi_softap_dhcps_stop();
  wifi_softap_set_dhcps_lease(&lease);
  wifi_softap_dhcps_start();

  return 2;
}
开发者ID:tjclement,项目名称:nodemcu-firmware,代码行数:36,代码来源:wifi.c


示例5: wifi_station_config

// Lua: wifi.sta.config(ssid, password)
static int wifi_station_config( lua_State* L )
{
  size_t sl, pl;
  struct station_config sta_conf;
  int i;
  const char *ssid = luaL_checklstring( L, 1, &sl );
  if (sl>32 || ssid == NULL)
    return luaL_error( L, "ssid:<32" );
  const char *password = luaL_checklstring( L, 2, &pl );
  if (pl>64 || password == NULL)
    return luaL_error( L, "pwd:<64" );

  c_memset(sta_conf.ssid, 0, 32);
  c_memset(sta_conf.password, 0, 64);
  c_memset(sta_conf.bssid, 0, 6);
  c_memcpy(sta_conf.ssid, ssid, sl);
  c_memcpy(sta_conf.password, password, pl);
  sta_conf.bssid_set = 0;

  NODE_DBG(sta_conf.ssid);
  NODE_DBG(" %d\n", sl);
  NODE_DBG(sta_conf.password);
  NODE_DBG(" %d\n", pl);

  wifi_station_set_config(&sta_conf);
  wifi_station_set_auto_connect(true);
  wifi_station_disconnect();
  wifi_station_connect();
  // station_check_connect(0);
  return 0;  
}
开发者ID:aeickho,项目名称:nodemcu-firmware,代码行数:32,代码来源:wifi.c


示例6: on_url

static int ICACHE_FLASH_ATTR on_url(http_parser *parser, const char *url, size_t length)
{	
	NODE_DBG("\nhttp_parser url: ");
    #ifdef DEVELOP_VERSION
	nprintf(url,length);
    #endif

	NODE_DBG("http_parser method: %d",parser->method);
		

	//grab the connection
	http_connection * conn = (http_connection *)parser->data;

	conn->state=HTTPD_STATE_ON_URL; //set state

	os_memcpy(conn->url,url,length); //copy url to connection info
	conn->url[length]=0; //null terminate string

	http_parse_url(conn);

	//execute cgi
	http_execute_cgi(conn);

	return 0;
}
开发者ID:ivmi,项目名称:esp-ginx-rc,代码行数:25,代码来源:http_process.c


示例7: mqtt_socket_close

// Lua: mqtt:close()
// client disconnect and unref itself
static int mqtt_socket_close( lua_State* L )
{
  NODE_DBG("enter mqtt_socket_close.\n");
  int i = 0;
  lmqtt_userdata *mud = NULL;

  mud = (lmqtt_userdata *)luaL_checkudata(L, 1, "mqtt.socket");
  luaL_argcheck(L, mud, 1, "mqtt.socket expected");
  if(mud == NULL)
    return 0;

  if(mud->pesp_conn == NULL)
    return 0;

  // call mqtt_disconnect()
  mud->mqtt_state.auto_reconnect = 0;   // stop auto reconnect.

  if(mud->secure){
    if(mud->pesp_conn->proto.tcp->remote_port || mud->pesp_conn->proto.tcp->local_port)
      espconn_secure_disconnect(mud->pesp_conn);
  }
  else
  {
    if(mud->pesp_conn->proto.tcp->remote_port || mud->pesp_conn->proto.tcp->local_port)
      espconn_disconnect(mud->pesp_conn);
  }
  NODE_DBG("leave mqtt_socket_close.\n");
  return 0;  
}
开发者ID:pvvx,项目名称:EspLua,代码行数:31,代码来源:mqtt.c


示例8: http_SET_HEADER

int ICACHE_FLASH_ATTR http_SET_HEADER(http_connection *c,const char * header,const char * value){

	NODE_DBG("Setting header: %s : %s",header,value);

	int j=0;
	while(c->output.headers[j].key!=NULL && j< MAX_HEADERS){

		if(os_strcmp(c->output.headers[j].key,header)==0){
			//header already on the list, overwrite
			if(c->output.headers[j].value!=NULL){				
				os_free(c->output.headers[j].value);				
			}
			break;
		}

		j++;
	}
	if(j==MAX_HEADERS) return 0;

	c->output.headers[j].key=header;
	c->output.headers[j].value=(char *) os_malloc(strlen(value)+1);

	if(c->output.headers[j].value==NULL){
		NODE_DBG("Failed to alloc header memory");
		return 0;
	}
	os_strcpy(c->output.headers[j].value,value);

	return 1;
}
开发者ID:kstevica,项目名称:esp-ginx,代码行数:30,代码来源:http_helper.c


示例9: myspiffs_mount

void myspiffs_mount() {
  spiffs_config cfg;
#ifdef SPIFFS_FIXED_LOCATION
  cfg.phys_addr = SPIFFS_FIXED_LOCATION;
#else
  cfg.phys_addr = ( u32_t )platform_flash_get_first_free_block_address( NULL ); 
#endif
  cfg.phys_addr += 0x3000;
  cfg.phys_addr &= 0xFFFFC000;  // align to 4 sector.
  cfg.phys_size = INTERNAL_FLASH_SIZE - ( ( u32_t )cfg.phys_addr - INTERNAL_FLASH_START_ADDRESS );
  cfg.phys_erase_block = INTERNAL_FLASH_SECTOR_SIZE; // according to datasheet
  cfg.log_block_size = INTERNAL_FLASH_SECTOR_SIZE; // let us not complicate things
  cfg.log_page_size = LOG_PAGE_SIZE; // as we said
  NODE_DBG("fs.start:%x,max:%x\n",cfg.phys_addr,cfg.phys_size);

  cfg.hal_read_f = my_spiffs_read;
  cfg.hal_write_f = my_spiffs_write;
  cfg.hal_erase_f = my_spiffs_erase;
  
  int res = SPIFFS_mount(&fs,
    &cfg,
    spiffs_work_buf,
    spiffs_fds,
    sizeof(spiffs_fds),
#if SPIFFS_CACHE
    spiffs_cache,
    sizeof(spiffs_cache),
#else
    0, 0,
#endif
    // myspiffs_check_callback);
    0);
  NODE_DBG("mount res: %i\n", res);
}
开发者ID:jiangxilong,项目名称:nodemcu-firmware,代码行数:34,代码来源:spiffs.c


示例10: user_init

/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void user_init(void)
{   
    
    system_update_cpu_freq(160); //overclock :)

    uart_init(BIT_RATE_115200,BIT_RATE_115200);

    NODE_DBG("User Init");

    uint32_t size = flash_get_size_byte();
    NODE_DBG("Flash size %d",size);
   
    config_wifi();
    
	relay_init();   
    
    init_dns();
    init_http_server();

    //uncomment to send data to mqtt broker
    //mqtt_app_init();    

    //uncomment if you have sensors intalled
    //sensors_init();

    #ifdef DEVELOP_VERSION

    //arm timer
    os_memset(&heapTimer,0,sizeof(os_timer_t));
    os_timer_disarm(&heapTimer);
    os_timer_setfn(&heapTimer, (os_timer_func_t *)heapTimerCb, NULL);
    os_timer_arm(&heapTimer, 5000, 1);

    #endif
}
开发者ID:andresvidal,项目名称:esp-ginx,代码行数:41,代码来源:user_main.c


示例11: http_wifi_api_scan_callback

static void ICACHE_FLASH_ATTR http_wifi_api_scan_callback(void *arg, STATUS status){

	int n;
	struct bss_info *bss_link = (struct bss_info *)arg;
	NODE_DBG("Wifi Scan Done, status: %d", status);
	if (status!=OK) {
		wifi_status.scanning=0;
		return;
	}

	//Clear prev ap data if needed.
	if (wifi_status.scan_result.ap!=NULL) {
		for (n=0; n<wifi_status.scan_result.ap_count; n++) 
			os_free(wifi_status.scan_result.ap[n]);
		os_free(wifi_status.scan_result.ap);
	}

	//Count amount of access points found.
	n=0;
	while (bss_link != NULL) {
		bss_link = bss_link->next.stqe_next;
		n++;
	}

	//Allocate memory for access point data
	wifi_status.scan_result.ap=(ap **)os_malloc(sizeof(ap *)*n);
	wifi_status.scan_result.ap_count=n;
	NODE_DBG("Scan done: found %d APs", n);

	//Copy access point data to the static struct
	n=0;
	bss_link = (struct bss_info *)arg;
	while (bss_link != NULL) {
		if (n>=wifi_status.scan_result.ap_count) {
			//This means the bss_link changed under our nose. Shouldn't happen!
			//Break because otherwise we will write in unallocated memory.
			NODE_DBG("Huh? I have more than the allocated %d aps!", wifi_status.scan_result.ap_count);
			break;
		}
		//Save the ap data.
		if(strlen(bss_link->ssid)>0){
			wifi_status.scan_result.ap[n]=(ap *)os_malloc(sizeof(ap));
			wifi_status.scan_result.ap[n]->rssi=bss_link->rssi;
			wifi_status.scan_result.ap[n]->enc=bss_link->authmode;
			wifi_status.scan_result.ap[n]->channel=bss_link->channel;
			strncpy(wifi_status.scan_result.ap[n]->ssid, (char*)bss_link->ssid, 32);			
			n++;
		}
		else{
			wifi_status.scan_result.ap_count--;
		}

		bss_link = bss_link->next.stqe_next;
		
	}

	//We're done.
	wifi_status.scanning=0;

}
开发者ID:andresvidal,项目名称:esp-ginx,代码行数:60,代码来源:cgi_wifi.c


示例12: on_header_value

static int ICACHE_FLASH_ATTR on_header_value(http_parser *parser, const char *at, size_t length)
{
	NODE_DBG("http_parser header value: ");
	nprintf(at,length);
	
	//grab the connection
	http_connection * conn = (http_connection *)parser->data;

	int i=0;
	while(conn->headers[i].key!=NULL){		
		if(conn->headers[i].save==1){
			NODE_DBG("saving header");

			conn->headers[i].value=(char *) os_malloc(length+1);
			os_memcpy(conn->headers[i].value,at,length);
			conn->headers[i].value[length]=0; //terminate string;

			conn->headers[i].save=0;

			break;

			
		}

		i++;
	}
	
	return 0;
}
开发者ID:andresvidal,项目名称:esp-ginx,代码行数:29,代码来源:http_process.c


示例13: flash_rom_set_size_type

static bool flash_rom_set_size_type(uint8_t size_code)
{
    // Dangerous, here are dinosaur infested!!!!!
    // Reboot required!!!
    // If you don't know what you're doing, your nodemcu may turn into stone ...
    NODE_DBG("\nBEGIN SET FLASH HEADER\n");
    esp_image_header_t *hdr = (esp_image_header_t *)malloc (SPI_FLASH_SEC_SIZE);
    if (!hdr)
      return false;

    if (ESP_OK == spi_flash_read (FLASH_HDR_ADDR, (uint32_t *)hdr, SPI_FLASH_SEC_SIZE))
    {
      hdr->spi_size = size_code;
      if (ESP_OK == spi_flash_erase_sector (FLASH_HDR_ADDR / SPI_FLASH_SEC_SIZE))
      {
        NODE_DBG("\nERASE SUCCESS\n");
      }
      if (ESP_OK == spi_flash_write(FLASH_HDR_ADDR, (uint32_t *)hdr, SPI_FLASH_SEC_SIZE))
      {
        NODE_DBG("\nWRITE SUCCESS, %u\n", size_code);
      }
    }
    free (hdr);
    NODE_DBG("\nEND SET FLASH HEADER\n");
    return true;
}
开发者ID:Nicholas3388,项目名称:LuaNode,代码行数:26,代码来源:flash_api.c


示例14: f_open

RO_FILE* f_open(const char *fileName){

	const char *fName = fileName;

	if(*fName=='/') //skip leading /
		fName++;

	NODE_DBG("Trying to open file %s ",fName);
	NODE_DBG("FS Location %p ",ro_file_system);
	NODE_DBG("FS data Location %p ",rofs_data);

	int i=0;
	while(i<ro_file_system.count){

		const RO_FILE_ENTRY *entry = &ro_file_system.files[i];
		
		NODE_DBG("Checking %s",entry->name);

		if(os_strcmp(fName,entry->name)==0){

			RO_FILE *f = (RO_FILE*)os_malloc(sizeof(RO_FILE));
			f->file = entry;
			f->readPos=0;

			return f;
		}
		i++;

	}

	return NULL;
}
开发者ID:andresvidal,项目名称:esp-ginx,代码行数:32,代码来源:rofs.c


示例15: handle_post_command

static int handle_post_command(const coap_endpoint_t *ep, coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)
{
    if (inpkt->payload.len == 0)
        return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_BAD_REQUEST, COAP_CONTENTTYPE_TEXT_PLAIN);
    if (inpkt->payload.len > 0)
    {
        lua_Load *load = &gLoad;
        if(load->line_position == 0){
            coap_buffer_to_string(load->line, load->len,&inpkt->payload);
            load->line_position = c_strlen(load->line)+1;
            // load->line[load->line_position-1] = '\n';
            // load->line[load->line_position] = 0;
            // load->line_position++;
            load->done = 1;
            NODE_DBG("Get command:\n");
            NODE_DBG_(load->line); // buggy here
            NODE_DBG("\nResult(if any):\n");
/*            os_timer_disarm(&lua_timer);
            os_timer_setfn(&lua_timer, (os_timer_func_t *)dojob, load);
            os_timer_arm(&lua_timer, READLINE_INTERVAL, 0);   // no repeat */
			set_lua_dojob(load);
        }
        return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_TEXT_PLAIN);
    }
}
开发者ID:pvvx,项目名称:EspLua,代码行数:25,代码来源:endpoints.c


示例16: on_header_field

static int ICACHE_FLASH_ATTR on_header_field(http_parser *parser, const char *at, size_t length)
{
	NODE_DBG("http_parser header: ");
    #ifdef DEVELOP_VERSION
	nprintf(at,length);
    #endif

	//grab the connection
	http_connection * conn = (http_connection *)parser->data;

	int i=0;
	while(conn->headers[i].key!=NULL){		
		if(os_strncmp(conn->headers[i].key,at,length)==0){
			NODE_DBG("marking header to save");
			//match header			
			//turn on save header			
			conn->headers[i].save=1;

			break;
		}

		i++;
	}
	
	return 0;
}
开发者ID:ivmi,项目名称:esp-ginx-rc,代码行数:26,代码来源:http_process.c


示例17: mqtt_socket_connected

static void mqtt_socket_connected(void *arg)
{
  NODE_DBG("enter mqtt_socket_connected.\n");
  struct espconn *pesp_conn = arg;
  if(pesp_conn == NULL)
    return;
  lmqtt_userdata *mud = (lmqtt_userdata *)pesp_conn->reverse;
  if(mud == NULL)
    return;
  mud->connected = true;
  espconn_regist_recvcb(pesp_conn, mqtt_socket_received);
  espconn_regist_sentcb(pesp_conn, mqtt_socket_sent);
  espconn_regist_disconcb(pesp_conn, mqtt_socket_disconnected);

  uint8_t temp_buffer[MQTT_BUF_SIZE];
  // call mqtt_connect() to start a mqtt connect stage.
  mqtt_msg_init(&mud->mqtt_state.mqtt_connection, temp_buffer, MQTT_BUF_SIZE);
  mqtt_message_t* temp_msg = mqtt_msg_connect(&mud->mqtt_state.mqtt_connection, mud->mqtt_state.connect_info);
  NODE_DBG("Send MQTT connection infomation, data len: %d, d[0]=%d \r\n", temp_msg->length,  temp_msg->data[0]);
  mud->event_timeout = MQTT_SEND_TIMEOUT;
  // not queue this message. should send right now. or should enqueue this before head.
  if(mud->secure)
    espconn_secure_sent(pesp_conn, temp_msg->data, temp_msg->length);
  else
    espconn_sent(pesp_conn, temp_msg->data, temp_msg->length);
  mud->keep_alive_tick = 0;

  mud->connState = MQTT_CONNECT_SENDING;
  NODE_DBG("leave mqtt_socket_connected.\n");
  return;
}
开发者ID:pvvx,项目名称:EspLua,代码行数:31,代码来源:mqtt.c


示例18: wifi_scan_done

/**
  * @brief  Wifi ap scan over callback to display.
  * @param  arg: contain the aps information
  * @param  status: scan over status
  * @retval None
  */
static void wifi_scan_done(void *arg, STATUS status)
{
  uint8 ssid[33];
  char temp[128];
  if(wifi_scan_succeed == LUA_NOREF)
    return;
  if(arg == NULL)
    return;
  
  lua_rawgeti(gL, LUA_REGISTRYINDEX, wifi_scan_succeed);

  if (status == OK)
  {
    struct bss_info *bss_link = (struct bss_info *)arg;
    bss_link = bss_link->next.stqe_next;//ignore first
    lua_newtable( gL );

    while (bss_link != NULL)
    {
      c_memset(ssid, 0, 33);
      if (c_strlen(bss_link->ssid) <= 32)
      {
        c_memcpy(ssid, bss_link->ssid, c_strlen(bss_link->ssid));
      }
      else
      {
        c_memcpy(ssid, bss_link->ssid, 32);
      }
      if(getap_output_format==1) //use new format(BSSID : SSID, RSSI, Authmode, Channel)
      {
    	c_sprintf(temp,"%s,%d,%d,%d", ssid, bss_link->rssi, bss_link->authmode, bss_link->channel);
    	lua_pushstring(gL, temp);
        NODE_DBG(MACSTR" : %s\n",MAC2STR(bss_link->bssid) , temp);
    	c_sprintf(temp,MACSTR, MAC2STR(bss_link->bssid));
    	lua_setfield( gL, -2,  temp);
      }
      else//use old format(SSID : Authmode, RSSI, BSSID, Channel)
      {
  	    c_sprintf(temp,"%d,%d,"MACSTR",%d", bss_link->authmode, bss_link->rssi, MAC2STR(bss_link->bssid),bss_link->channel);
        lua_pushstring(gL, temp);
        lua_setfield( gL, -2, ssid );
        NODE_DBG("%s : %s\n", ssid, temp);
      }

      bss_link = bss_link->next.stqe_next;
    }
  }
  else
  {
    lua_newtable( gL );
  }
  lua_call(gL, 1, 0);
  if(wifi_scan_succeed != LUA_NOREF)
  {
    luaL_unref(gL, LUA_REGISTRYINDEX, wifi_scan_succeed);
    wifi_scan_succeed = LUA_NOREF;
  }
}
开发者ID:tjclement,项目名称:nodemcu-firmware,代码行数:64,代码来源:wifi.c


示例19: mqtt_socket_disconnected

static void mqtt_socket_disconnected(void *arg)    // tcp only
{
  NODE_DBG("enter mqtt_socket_disconnected.\n");
  struct espconn *pesp_conn = arg;
  bool call_back = false;
  if(pesp_conn == NULL)
    return;
  lmqtt_userdata *mud = (lmqtt_userdata *)pesp_conn->reverse;
  if(mud == NULL)
    return;

  os_timer_disarm(&mud->mqttTimer);

  if(mud->connected){     // call back only called when socket is from connection to disconnection.
    mud->connected = false;
    if((mud->L != NULL) && (mud->cb_disconnect_ref != LUA_NOREF) && (mud->self_ref != LUA_NOREF)) {
      lua_rawgeti(mud->L, LUA_REGISTRYINDEX, mud->cb_disconnect_ref);
      lua_rawgeti(mud->L, LUA_REGISTRYINDEX, mud->self_ref);  // pass the userdata(client) to callback func in lua
      call_back = true;
    }
  }

  if(mud->mqtt_state.auto_reconnect){
    mud->pesp_conn->reverse = mud;
    mud->pesp_conn->type = ESPCONN_TCP;
    mud->pesp_conn->state = ESPCONN_NONE;
    mud->connected = false;
    mud->pesp_conn->proto.tcp->remote_port = mud->mqtt_state.port;
    mud->pesp_conn->proto.tcp->local_port = espconn_port();
    espconn_regist_connectcb(mud->pesp_conn, mqtt_socket_connected);
    espconn_regist_reconcb(mud->pesp_conn, mqtt_socket_reconnected);
    socket_connect(pesp_conn);
  } else {
    if(mud->pesp_conn){
      mud->pesp_conn->reverse = NULL;
      if(mud->pesp_conn->proto.tcp)
        c_free(mud->pesp_conn->proto.tcp);
      mud->pesp_conn->proto.tcp = NULL;
      c_free(mud->pesp_conn);
      mud->pesp_conn = NULL;
    }

    if(mud->L == NULL)
      return;
    lua_gc(mud->L, LUA_GCSTOP, 0);
    if(mud->self_ref != LUA_NOREF){   // TODO: should we unref the client and delete it?
      luaL_unref(mud->L, LUA_REGISTRYINDEX, mud->self_ref);
      mud->self_ref = LUA_NOREF; // unref this, and the mqtt.socket userdata will delete it self
    }
    lua_gc(mud->L, LUA_GCRESTART, 0);
  }

  if((mud->L != NULL) && call_back){
    lua_call(mud->L, 1, 0);
  }

  NODE_DBG("leave mqtt_socket_disconnected.\n");
}
开发者ID:pvvx,项目名称:EspLua,代码行数:58,代码来源:mqtt.c


示例20: node_compile

// Lua: compile(filename) -- compile lua file into lua bytecode, and save to .lc
static int node_compile( lua_State* L )
{
  Proto* f;
  int file_fd = FS_OPEN_OK - 1;
  size_t len;
  const char *fname = luaL_checklstring( L, 1, &len );
  if ( len > FS_NAME_MAX_LENGTH )
    return luaL_error(L, "filename too long");

  char output[FS_NAME_MAX_LENGTH];
  c_strcpy(output, fname);
  // check here that filename end with ".lua".
  if (len < 4 || (c_strcmp( output + len - 4, ".lua") != 0) )
    return luaL_error(L, "not a .lua file");

  output[c_strlen(output) - 2] = 'c';
  output[c_strlen(output) - 1] = '\0';
  NODE_DBG(output);
  NODE_DBG("\n");
  if (luaL_loadfsfile(L, fname) != 0) {
    return luaL_error(L, lua_tostring(L, -1));
  }

  f = toproto(L, -1);

  int stripping = 1;      /* strip debug information? */

  file_fd = fs_open(output, fs_mode2flag("w+"));
  if (file_fd < FS_OPEN_OK)
  {
    return luaL_error(L, "cannot open/write to file");
  }

  lua_lock(L);
  int result = luaU_dump(L, f, writer, &file_fd, stripping);
  lua_unlock(L);

  if (fs_flush(file_fd) < 0) {   // result codes aren't propagated by flash_fs.h
    // overwrite Lua error, like writer() does in case of a file io error
    result = 1;
  }
  fs_close(file_fd);
  file_fd = FS_OPEN_OK - 1;

  if (result == LUA_ERR_CC_INTOVERFLOW) {
    return luaL_error(L, "value too big or small for target integer type");
  }
  if (result == LUA_ERR_CC_NOTINTEGER) {
    return luaL_error(L, "target lua_Number is integral but fractional value found");
  }
  if (result == 1) {    // result status generated by writer() or fs_flush() fail
    return luaL_error(L, "writing to file failed");
  }

  return 0;
}
开发者ID:Alvaro99CL,项目名称:nodemcu-firmware,代码行数:57,代码来源:node.c



注:本文中的NODE_DBG函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NODE_SET_PROTOTYPE_METHOD函数代码示例发布时间:2022-05-30
下一篇:
C++ NODE_DATA函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap