diff --git a/cmd/cmd.c b/cmd/cmd.c index 6ebb8cb..705ee8a 100644 --- a/cmd/cmd.c +++ b/cmd/cmd.c @@ -43,7 +43,7 @@ static uint16_t resp_crc; // Start a response, returns the partial CRC void ICACHE_FLASH_ATTR cmdResponseStart(uint16_t cmd, uint32_t value, uint16_t argc) { - DBG("cmdResponse: cmd=%d val=%ld argc=%d\n", cmd, value, argc); + DBG("cmdResponse: cmd=%d val=%d argc=%d\n", cmd, value, argc); uart0_write_char(SLIP_END); cmdProtoWriteBuf((uint8_t*)&cmd, 2); @@ -107,7 +107,7 @@ cmdParsePacket(uint8_t *buf, short len) { uint8_t *data_ptr = (uint8_t*)&packet->args; uint8_t *data_limit = data_ptr+len; - DBG("cmdParsePacket: cmd=%d argc=%d value=%lu\n", + DBG("cmdParsePacket: cmd=%d argc=%d value=%u\n", packet->cmd, packet->argc, packet->value diff --git a/cmd/handlers.c b/cmd/handlers.c index 2b9c1ad..061526a 100644 --- a/cmd/handlers.c +++ b/cmd/handlers.c @@ -62,7 +62,7 @@ cmdAddCb(char* name, uint32_t cb) { os_strncpy(callbacks[i].name, name, sizeof(callbacks[i].name)); callbacks[i].name[CMD_CBNLEN-1] = 0; // strncpy doesn't null terminate callbacks[i].callback = cb; - DBG("cmdAddCb: '%s'->0x%lx added at %d\n", callbacks[i].name, cb, i); + DBG("cmdAddCb: '%s'->0x%x added at %d\n", callbacks[i].name, cb, i); return 1; } } diff --git a/esp-link/cgiflash.c b/esp-link/cgiflash.c index 8c39e36..4b9277d 100644 --- a/esp-link/cgiflash.c +++ b/esp-link/cgiflash.c @@ -30,7 +30,7 @@ static char* ICACHE_FLASH_ATTR check_header(void *buf) { uint8_t *cd = (uint8_t *)buf; #ifdef CGIFLASH_DBG uint32_t *buf32 = buf; - os_printf("%p: %08lX %08lX %08lX %08lX\n", buf, buf32[0], buf32[1], buf32[2], buf32[3]); + os_printf("%p: %08X %08X %08X %08X\n", buf, buf32[0], buf32[1], buf32[2], buf32[3]); #endif if (cd[0] != 0xEA) return "IROM magic missing"; if (cd[1] != 4 || cd[2] > 3 || (cd[3]>>4) > 6) return "bad flash header"; @@ -197,4 +197,4 @@ int ICACHE_FLASH_ATTR cgiReset(HttpdConnData *connData) { os_timer_setfn(&flash_reboot_timer, (os_timer_func_t *)system_restart, NULL); os_timer_arm(&flash_reboot_timer, 2000, 1); return HTTPD_CGI_DONE; -} \ No newline at end of file +} diff --git a/esp-link/cgioptiboot.c b/esp-link/cgioptiboot.c index 6594973..ed87d0e 100644 --- a/esp-link/cgioptiboot.c +++ b/esp-link/cgioptiboot.c @@ -153,7 +153,7 @@ int ICACHE_FLASH_ATTR cgiOptibootSync(HttpdConnData *connData) { if (!errMessage[0] && progState >= stateProg) { char buf[64]; DBG("OB got sync\n"); - os_sprintf(buf, "SYNC at %ld baud: bootloader v%d.%d", + os_sprintf(buf, "SYNC at %d baud: bootloader v%d.%d", baudRate, optibootVers>>8, optibootVers&0xff); httpdSend(connData, buf, -1); } else if (errMessage[0] && progState == stateSync) { @@ -314,7 +314,7 @@ int ICACHE_FLASH_ATTR cgiOptibootData(HttpdConnData *connData) { float dt = ((system_get_time() - optibootData->startTime)/1000)/1000.0; // in seconds uint16_t pgmDone = optibootData->pgmDone; optibootInit(); - os_sprintf(errMessage, "Success. %d bytes at %ld baud in %d.%ds, %dB/s %d%% efficient", + os_sprintf(errMessage, "Success. %d bytes at %d baud in %d.%ds, %dB/s %d%% efficient", pgmDone, baudRate, (int)dt, (int)(dt*10)%10, (int)(pgmDone/dt), (int)(100.0*(10.0*pgmDone/baudRate)/dt)); } else { @@ -387,7 +387,7 @@ static bool ICACHE_FLASH_ATTR processRecord(char *buf, short len) { optibootData->eof = true; break; case 0x04: // address - DBG("OB address 0x%lx\n", getHexValue(buf+8, 4) << 16); + DBG("OB address 0x%x\n", getHexValue(buf+8, 4) << 16); // program any remaining partial page if (optibootData->pageLen > 0) if (!programPage()) return false; @@ -435,7 +435,7 @@ static bool ICACHE_FLASH_ATTR programPage(void) { uint16_t pgmLen = optibootData->pageLen; if (pgmLen > optibootData->pgmSz) pgmLen = optibootData->pgmSz; - DBG("OB pgm %d@0x%lx\n", pgmLen, optibootData->address); + DBG("OB pgm %d@0x%x\n", pgmLen, optibootData->address); // send address to optiboot (little endian format) #ifdef DBG_GPIO5 @@ -525,7 +525,7 @@ static void ICACHE_FLASH_ATTR optibootTimerCB(void *arg) { return; } // time to switch baud rate and issue a reset - DBG("OB no sync response @%ld baud\n", baudRate); + DBG("OB no sync response @%d baud\n", baudRate); setBaud(); serbridgeReset(); progState = stateInit; @@ -539,7 +539,7 @@ static void ICACHE_FLASH_ATTR optibootTimerCB(void *arg) { return; default: // we're trying to get some info from optiboot and it should have responded! optibootInit(); // abort - os_sprintf(errMessage, "No response in state %s(%d) @%ld baud\n", + os_sprintf(errMessage, "No response in state %s(%d) @%d baud\n", progStates[progState], progState, baudRate); DBG("OB %s\n", errMessage); return; // do not re-arm timer diff --git a/esp-link/cgipins.c b/esp-link/cgipins.c index c219f77..b763d12 100644 --- a/esp-link/cgipins.c +++ b/esp-link/cgipins.c @@ -49,7 +49,7 @@ int ICACHE_FLASH_ATTR cgiPinsSet(HttpdConnData *connData) { int8_t ok = 0; int8_t reset, isp, conn, ser; - bool swap, rxpup; + uint8_t swap, rxpup; ok |= getInt8Arg(connData, "reset", &reset); ok |= getInt8Arg(connData, "isp", &isp); ok |= getInt8Arg(connData, "conn", &conn); diff --git a/esp-link/cgiservices.c b/esp-link/cgiservices.c index 81f7200..cf55dd1 100644 --- a/esp-link/cgiservices.c +++ b/esp-link/cgiservices.c @@ -66,11 +66,11 @@ int ICACHE_FLASH_ATTR cgiSystemInfo(HttpdConnData *connData) { "\"name\": \"%s\", " "\"reset cause\": \"%d=%s\", " "\"size\": \"%s\", " - "\"id\": \"0x%02lX 0x%04lX\", " + "\"id\": \"0x%02X 0x%04X\", " "\"partition\": \"%s\", " "\"slip\": \"%s\", " "\"mqtt\": \"%s/%s\", " - "\"baud\": \"%ld\", " + "\"baud\": \"%d\", " "\"description\": \"%s\"" " }", flashConfig.hostname, @@ -92,10 +92,10 @@ int ICACHE_FLASH_ATTR cgiSystemInfo(HttpdConnData *connData) { } void ICACHE_FLASH_ATTR cgiServicesSNTPInit() { - if (flashConfig.sntp_server[0] != '\0') { + if (flashConfig.sntp_server[0] != '\0') { sntp_stop(); if (true == sntp_set_timezone(flashConfig.timezone_offset)) { - sntp_setservername(0, flashConfig.sntp_server); + sntp_setservername(0, flashConfig.sntp_server); sntp_init(); } DBG("SNTP timesource set to %s with offset %d\n", flashConfig.sntp_server, flashConfig.timezone_offset); @@ -107,7 +107,7 @@ int ICACHE_FLASH_ATTR cgiServicesInfo(HttpdConnData *connData) { if (connData->conn == NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. - os_sprintf(buff, + os_sprintf(buff, "{ " "\"syslog_host\": \"%s\", " "\"syslog_minheap\": %d, " @@ -118,7 +118,7 @@ int ICACHE_FLASH_ATTR cgiServicesInfo(HttpdConnData *connData) { "\"sntp_server\": \"%s\", " "\"mdns_enable\": \"%s\", " "\"mdns_servername\": \"%s\"" - " }", + " }", flashConfig.syslog_host, flashConfig.syslog_minheap, flashConfig.syslog_filter, @@ -168,7 +168,7 @@ int ICACHE_FLASH_ATTR cgiServicesSet(HttpdConnData *connData) { int8_t mdns = 0; mdns |= getBoolArg(connData, "mdns_enable", &flashConfig.mdns_enable); if (mdns < 0) return HTTPD_CGI_DONE; - + if (mdns > 0) { if (flashConfig.mdns_enable){ DBG("Services: MDNS Enabled\n"); diff --git a/esp-link/config.h b/esp-link/config.h index 59d5f3d..c3da742 100644 --- a/esp-link/config.h +++ b/esp-link/config.h @@ -13,7 +13,7 @@ typedef struct { char hostname[32]; // if using DHCP uint32_t staticip, netmask, gateway; // using DHCP if staticip==0 uint8_t log_mode; // UART log debug mode - int8_t swap_uart; // swap uart0 to gpio 13&15 + uint8_t swap_uart; // swap uart0 to gpio 13&15 uint8_t tcp_enable, rssi_enable; // TCP client settings char api_key[48]; // RSSI submission API key (Grovestreams for now) uint8_t slip_enable, mqtt_enable, // SLIP protocol, MQTT client @@ -21,9 +21,9 @@ typedef struct { mqtt_timeout, // MQTT send timeout mqtt_clean_session; // MQTT clean session uint16_t mqtt_port, mqtt_keepalive; // MQTT Host port, MQTT Keepalive timer - char mqtt_host[32], - mqtt_clientid[48], - mqtt_username[32], + char mqtt_host[32], + mqtt_clientid[48], + mqtt_username[32], mqtt_password[32], mqtt_status_topic[32]; char sys_descr[129]; // system description @@ -35,7 +35,7 @@ typedef struct { syslog_showtick, // show system tick (µs) syslog_showdate; // populate SYSLOG date field uint8_t mdns_enable; - char mdns_servername[32]; + char mdns_servername[32]; int8_t timezone_offset; } FlashConfig; extern FlashConfig flashConfig; diff --git a/esp-link/main.c b/esp-link/main.c index 4f7de35..d38ad24 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -73,7 +73,7 @@ HttpdBuiltInUrl builtInUrls[] = { { "/wifi/setmode", cgiWiFiSetMode, NULL }, { "/wifi/special", cgiWiFiSpecial, NULL }, { "/wifi/apinfo", cgiApSettingsInfo, NULL }, - { "/wifi/apchange", cgiApSettingsChange, NULL }, + { "/wifi/apchange", cgiApSettingsChange, NULL }, { "/system/info", cgiSystemInfo, NULL }, { "/system/update", cgiSystemSet, NULL }, { "/services/info", cgiServicesInfo, NULL }, @@ -81,7 +81,7 @@ HttpdBuiltInUrl builtInUrls[] = { { "/pins", cgiPins, NULL }, #ifdef MQTT { "/mqtt", cgiMqtt, NULL }, -#endif +#endif { "*", cgiEspFsHook, NULL }, //Catch-all cgi function for the filesystem { NULL, NULL, NULL } }; @@ -149,10 +149,10 @@ void user_init(void) { rst_info->exccause, rst_info->epc1, rst_info->epc2, rst_info->epc3, rst_info->excvaddr, rst_info->depc); uint32_t fid = spi_flash_get_id(); - NOTICE("Flash map %s, manuf 0x%02lX chip 0x%04lX", flash_maps[system_get_flash_size_map()], + NOTICE("Flash map %s, manuf 0x%02X chip 0x%04X", flash_maps[system_get_flash_size_map()], fid & 0xff, (fid&0xff00)|((fid>>16)&0xff)); NOTICE("** esp-link ready"); - + // Init SNTP service cgiServicesSNTPInit(); #ifdef MQTT diff --git a/mqtt/mqtt_cmd.c b/mqtt/mqtt_cmd.c index 05f277f..71c5d20 100644 --- a/mqtt/mqtt_cmd.c +++ b/mqtt/mqtt_cmd.c @@ -42,7 +42,7 @@ cmdMqttDataCb(MQTT_Client* client, const char* topic, uint32_t topic_len, const char* data, uint32_t data_len) { MqttCmdCb* cb = (MqttCmdCb*)client->user_data; - DBG("MQTT: Data cb=%p topic=%s len=%ld\n", (void*)cb->dataCb, topic, data_len); + DBG("MQTT: Data cb=%p topic=%s len=%u\n", (void*)cb->dataCb, topic, data_len); cmdResponseStart(CMD_RESP_CB, cb->dataCb, 2); cmdResponseBody(topic, topic_len); @@ -168,7 +168,7 @@ MQTTCMD_Subscribe(CmdPacket *cmd) { uint32_t qos = 0; cmdPopArg(&req, (uint8_t*)&qos, 4); - DBG("MQTT: MQTTCMD_Subscribe topic=%s, qos=%ld\n", topic, qos); + DBG("MQTT: MQTTCMD_Subscribe topic=%s, qos=%u\n", topic, qos); MQTT_Subscribe(client, (char*)topic, (uint8_t)qos); os_free(topic); @@ -245,7 +245,7 @@ MQTTCMD_Setup(CmdPacket *cmd) { cmdPopArg(&req, &callback->dataCb, 4); client->user_data = callback; - DBG("MQTT connectedCb=%lx\n", callback->connectedCb); + DBG("MQTT connectedCb=%x\n", callback->connectedCb); client->cmdConnectedCb = cmdMqttConnectedCb; client->cmdDisconnectedCb = cmdMqttDisconnectedCb; diff --git a/rest/rest.c b/rest/rest.c index 81e296a..67c0f7d 100644 --- a/rest/rest.c +++ b/rest/rest.c @@ -252,7 +252,7 @@ REST_Setup(CmdPacket *cmd) { os_free(client->pCon); } os_memset(client, 0, sizeof(RestClient)); - DBG_REST("REST: setup #%d host=%s port=%ld security=%ld\n", clientNum, rest_host, port, security); + DBG_REST("REST: setup #%d host=%s port=%d security=%d\n", clientNum, rest_host, port, security); client->resp_cb = cmd->value; @@ -348,7 +348,7 @@ REST_Request(CmdPacket *cmd) { // Get client uint32_t clientNum = cmd->value; RestClient *client = restClient + (clientNum % MAX_REST); - DBG_REST(" #%ld", clientNum); + DBG_REST(" #%d", clientNum); // Get HTTP method uint16_t len = cmdArgLen(&req); @@ -374,7 +374,7 @@ REST_Request(CmdPacket *cmd) { realLen = cmdArgLen(&req); if (realLen > 2048) goto fail; } - DBG_REST(" bodyLen=%ld", realLen); + DBG_REST(" bodyLen=%d", realLen); // we need to allocate memory for the header plus the body. First we count the length of the // header (including some extra counted "%s" and then we add the body length. We allocate the @@ -393,7 +393,7 @@ REST_Request(CmdPacket *cmd) { if (client->data) os_free(client->data); client->data = (char*)os_zalloc(headerLen + realLen); if (client->data == NULL) goto fail; - DBG_REST(" totLen=%ld data=%p", headerLen + realLen, client->data); + DBG_REST(" totLen=%d data=%p", headerLen + realLen, client->data); client->data_len = os_sprintf((char*)client->data, headerFmt, method, path, client->host, client->header, realLen, client->content_type, client->user_agent); DBG_REST(" hdrLen=%d", client->data_len); @@ -412,7 +412,7 @@ REST_Request(CmdPacket *cmd) { espconn_regist_reconcb(client->pCon, tcpclient_recon_cb); if(UTILS_StrToIP((char *)client->host, &client->pCon->proto.tcp->remote_ip)) { - DBG_REST("REST: Connect to ip %s:%ld\n",client->host, client->port); + DBG_REST("REST: Connect to ip %s:%d\n",client->host, client->port); //if(client->security){ // espconn_secure_connect(client->pCon); //} @@ -420,7 +420,7 @@ REST_Request(CmdPacket *cmd) { espconn_connect(client->pCon); //} } else { - DBG_REST("REST: Connect to host %s:%ld\n", client->host, client->port); + DBG_REST("REST: Connect to host %s:%d\n", client->host, client->port); espconn_gethostbyname(client->pCon, (char *)client->host, &client->ip, rest_dns_found); } diff --git a/serial/console.c b/serial/console.c index 68b5b55..44e860a 100644 --- a/serial/console.c +++ b/serial/console.c @@ -76,7 +76,7 @@ ajaxConsoleBaud(HttpdConnData *connData) { } jsonHeader(connData, status); - os_sprintf(buff, "{\"rate\": %ld}", flashConfig.baud_rate); + os_sprintf(buff, "{\"rate\": %d}", flashConfig.baud_rate); httpdSend(connData, buff, -1); return HTTPD_CGI_DONE; } @@ -86,14 +86,14 @@ ajaxConsoleSend(HttpdConnData *connData) { if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. char buff[2048]; int len, status = 400; - + // figure out where to start in buffer based on URI param len = httpdFindArg(connData->getArgs, "text", buff, sizeof(buff)); if (len > 0) { uart0_tx_buffer(buff, len); status = 200; } - + jsonHeader(connData, status); return HTTPD_CGI_DONE; } diff --git a/syslog/syslog.c b/syslog/syslog.c index 207b678..f187114 100644 --- a/syslog/syslog.c +++ b/syslog/syslog.c @@ -406,16 +406,16 @@ syslog_compose(uint8_t facility, uint8_t severity, const char *tag, const char * tp->tm_year + 1900, tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec); if (realtime_stamp == 0) - p += os_sprintf(p, ".%06luZ ", se->tick % 1000000); + p += os_sprintf(p, ".%06uZ ", se->tick % 1000000); else p += os_sprintf(p, "%+03d:00 ", flashConfig.timezone_offset); } // add HOSTNAME APP-NAME PROCID MSGID if (flashConfig.syslog_showtick) - p += os_sprintf(p, "%s %s %lu.%06lu %lu ", flashConfig.hostname, tag, se->tick / 1000000, se->tick % 1000000, syslog_msgid++); + p += os_sprintf(p, "%s %s %u.%06u %u ", flashConfig.hostname, tag, se->tick / 1000000, se->tick % 1000000, syslog_msgid++); else - p += os_sprintf(p, "%s %s - %lu ", flashConfig.hostname, tag, syslog_msgid++); + p += os_sprintf(p, "%s %s - %u ", flashConfig.hostname, tag, syslog_msgid++); // append syslog message va_list arglist;