本文整理汇总了C++中NODE_DBG函数的典型用法代码示例。如果您正苦于以下问题:C++ NODE_DBG函数的具体用法?C++ NODE_DBG怎么用?C++ NODE_DBG使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NODE_DBG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
示例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");
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}