Commit d77666c0 authored by sergio's avatar sergio Committed by Terry Ellison
Browse files

trailing spaces cleanup (#2659)

parent d7583040
......@@ -13,14 +13,14 @@ static const uint8 b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
static uint8 *toBase64 ( lua_State* L, const uint8 *msg, size_t *len){
size_t i, n = *len;
if (!n) // handle empty string case
if (!n) // handle empty string case
return NULL;
int buf_size = (n + 2) / 3 * 4; // estimated encoded size
uint8 * q, *out = (uint8 *)luaM_malloc(L, buf_size);
uint8 bytes64[sizeof(b64)];
c_memcpy(bytes64, b64, sizeof(b64)); //Avoid lots of flash unaligned fetches
for (i = 0, q = out; i < n; i += 3) {
int a = msg[i];
int b = (i + 1 < n) ? msg[i + 1] : 0;
......@@ -40,29 +40,29 @@ static uint8 *fromBase64 ( lua_State* L, const uint8 *enc_msg, size_t *len){
const uint8 *p;
uint8 unbytes64[UCHAR_MAX+1], *msg, *q;
if (!n) // handle empty string case
if (!n) // handle empty string case
return NULL;
if (n & 3)
luaL_error (L, "Invalid base64 string");
luaL_error (L, "Invalid base64 string");
c_memset(unbytes64, BASE64_INVALID, sizeof(unbytes64));
for (i = 0; i < sizeof(b64)-1; i++) unbytes64[b64[i]] = i; // sequential so no exceptions
for (i = 0; i < sizeof(b64)-1; i++) unbytes64[b64[i]] = i; // sequential so no exceptions
if (enc_msg[n-1] == BASE64_PADDING) {
pad = (enc_msg[n-2] != BASE64_PADDING) ? 1 : 2;
blocks--; //exclude padding block
}
}
for (i = 0; i < n - pad; i++) if (!ISBASE64(enc_msg[i])) luaL_error (L, "Invalid base64 string");
unbytes64[BASE64_PADDING] = 0;
int buf_size=1+ (3 * n / 4); // estimate decoded length
msg = q = (uint8 *) luaM_malloc(L, buf_size);
msg = q = (uint8 *) luaM_malloc(L, buf_size);
for (i = 0, p = enc_msg; i<blocks; i++) {
uint8 a = unbytes64[*p++];
uint8 b = unbytes64[*p++];
uint8 c = unbytes64[*p++];
uint8 a = unbytes64[*p++];
uint8 b = unbytes64[*p++];
uint8 c = unbytes64[*p++];
uint8 d = unbytes64[*p++];
*q++ = (a << 2) | (b >> 4);
*q++ = (b << 4) | (c >> 2);
......@@ -83,7 +83,7 @@ static uint8 *fromBase64 ( lua_State* L, const uint8 *enc_msg, size_t *len){
static inline uint8 to_hex_nibble(uint8 b) {
return b + ( b < 10 ? '0' : 'a' - 10 );
}
static uint8 *toHex ( lua_State* L, const uint8 *msg, size_t *len){
int i, n = *len;
*len <<= 1;
......@@ -98,14 +98,14 @@ static uint8 *toHex ( lua_State* L, const uint8 *msg, size_t *len){
static uint8 *fromHex ( lua_State* L, const uint8 *msg, size_t *len){
int i, n = *len;
const uint8 *p;
if (n &1)
luaL_error (L, "Invalid hex string");
*len >>= 1;
uint8 b, *q, *out = (uint8 *)luaM_malloc(L, *len);
uint8 c = 0;
for (i = 0, p = msg, q = out; i < n; i++) {
if (*p >= '0' && *p <= '9') {
b = *p++ - '0';
......@@ -121,20 +121,20 @@ static uint8 *fromHex ( lua_State* L, const uint8 *msg, size_t *len){
c = b<<4;
} else {
*q++ = c+ b;
}
}
}
return out;
}
// All encoder functions are of the form:
// Lua: output_string = encoder.function(input_string)
// Lua: output_string = encoder.function(input_string)
// Where input string maybe empty, but not nil
// Hence these all call the do_func wrapper
static int do_func (lua_State *L, uint8 * (*conv_func)(lua_State *, const uint8 *, size_t *)) {
size_t len;
const uint8 *input = luaL_checklstring(L, 1, &len);
uint8 *output = conv_func(L, input, &len);
if (output) {
lua_pushlstring(L, output, len);
luaM_freearray(L, output, len, uint8);
......
......@@ -49,7 +49,7 @@
#include "vfs.h"
#include "task/task.h"
/* Set this to 1 to generate debug messages. Uses debug callback provided by Lua. Example: enduser_setup.start(successFn, print, print) */
/* Set this to 1 to generate debug messages. Uses debug callback provided by Lua. Example: enduser_setup.start(successFn, print, print) */
#define ENDUSER_SETUP_DEBUG_ENABLE 0
/* Set this to 1 to output the contents of HTTP requests when debugging. Useful if you need it, but can get pretty noisy */
......@@ -259,10 +259,10 @@ static void enduser_setup_check_station(void *p)
}
uint8_t currChan = wifi_get_channel();
if (has_ip == 0)
{
/* No IP Address yet, so check the reported status */
/* No IP Address yet, so check the reported status */
uint8_t curr_status = wifi_station_get_connect_status();
char buf[20];
c_sprintf(buf, "status=%d,chan=%d", curr_status, currChan);
......@@ -271,16 +271,16 @@ static void enduser_setup_check_station(void *p)
if (curr_status == 2 || curr_status == 3 || curr_status == 4)
{
state->connecting = 0;
/* If the status is an error status and the channel changed, then cache the
/* If the status is an error status and the channel changed, then cache the
* status to state since the Station won't be able to report the same status
* after switching the channel back to the SoftAP's
*/
if (currChan != state->softAPchannel) {
state->lastStationStatus = curr_status;
ENDUSER_SETUP_DEBUG("Turning off Station due to different channel than AP");
wifi_station_disconnect();
wifi_set_opmode(SOFTAP_MODE);
enduser_setup_ap_start();
......@@ -294,11 +294,11 @@ static void enduser_setup_check_station(void *p)
state->success = 1;
state->lastStationStatus = 5; /* We have an IP Address, so the status is 5 (as of SDK 1.5.1) */
state->connecting = 0;
#if ENDUSER_SETUP_DEBUG_ENABLE
#if ENDUSER_SETUP_DEBUG_ENABLE
char debuginfo[100];
c_sprintf(debuginfo, "AP_CHAN: %d, STA_CHAN: %d", state->softAPchannel, currChan);
ENDUSER_SETUP_DEBUG(debuginfo);
ENDUSER_SETUP_DEBUG(debuginfo);
#endif
if (currChan == state->softAPchannel)
......@@ -313,7 +313,7 @@ static void enduser_setup_check_station(void *p)
wifi_set_opmode(SOFTAP_MODE);
enduser_setup_ap_start();
}
enduser_setup_check_station_stop();
/* Trigger shutdown, but allow time for HTTP client to fetch last status. */
......@@ -346,7 +346,7 @@ static void enduser_setup_check_station(void *p)
static err_t force_abort (void *arg, struct tcp_pcb *pcb)
{
ENDUSER_SETUP_DEBUG("force_abort");
(void)arg;
tcp_poll (pcb, 0, 0);
tcp_abort (pcb);
......@@ -357,7 +357,7 @@ static err_t force_abort (void *arg, struct tcp_pcb *pcb)
static err_t handle_remote_close (void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
ENDUSER_SETUP_DEBUG("handle_remote_close");
(void)arg; (void)err;
if (p) /* server sent us data, just ACK and move on */
{
......@@ -377,7 +377,7 @@ static err_t handle_remote_close (void *arg, struct tcp_pcb *pcb, struct pbuf *p
static inline void deferred_close (struct tcp_pcb *pcb)
{
ENDUSER_SETUP_DEBUG("deferred_close");
tcp_poll (pcb, force_abort, 15); /* ~3sec from now */
tcp_recv (pcb, handle_remote_close);
tcp_sent (pcb, 0);
......@@ -433,7 +433,7 @@ static int enduser_setup_http_load_payload(void)
/* Try to open enduser_setup.html.gz from SPIFFS first */
int f = vfs_open(http_html_gz_filename, "r");
if (f)
if (f)
{
err = vfs_lseek(f, 0, VFS_SEEK_END);
file_len = (int) vfs_tell(f);
......@@ -442,7 +442,7 @@ static int enduser_setup_http_load_payload(void)
if (!f || err == VFS_RES_ERR || err2 == VFS_RES_ERR)
{
if (f)
if (f)
{
vfs_close(f);
}
......@@ -450,7 +450,7 @@ static int enduser_setup_http_load_payload(void)
/* If that didn't work, try to open enduser_setup.html from SPIFFS */
f = vfs_open(http_html_filename, "r");
if (f)
if (f)
{
err = vfs_lseek(f, 0, VFS_SEEK_END);
file_len = (int) vfs_tell(f);
......@@ -460,7 +460,7 @@ static int enduser_setup_http_load_payload(void)
char cl_hdr[30];
size_t ce_len = 0;
c_sprintf(cl_hdr, http_header_content_len_fmt, file_len);
size_t cl_len = c_strlen(cl_hdr);
......@@ -477,9 +477,9 @@ static int enduser_setup_http_load_payload(void)
ce_len = c_strlen(http_html_gzip_contentencoding);
html_len = http_html_backup_len; /* Defined in eus/http_html_backup.def by xxd -i */
ENDUSER_SETUP_DEBUG("Content is gzipped");
}
int payload_len = LITLEN(http_header_200) + cl_len + ce_len + html_len;
}
int payload_len = LITLEN(http_header_200) + cl_len + ce_len + html_len;
state->http_payload_len = payload_len;
state->http_payload_data = (char *) c_malloc(payload_len);
......@@ -496,23 +496,23 @@ static int enduser_setup_http_load_payload(void)
{
offset += c_sprintf(state->http_payload_data + offset, http_html_gzip_contentencoding, ce_len);
}
c_memcpy(&(state->http_payload_data[offset]), &(cl_hdr), cl_len);
offset += cl_len;
c_memcpy(&(state->http_payload_data[offset]), &(http_html_backup), sizeof(http_html_backup));
return 1;
return 1;
}
char magic[2];
vfs_read(f, magic, 2);
if (magic[0] == 0x1f && magic[1] == 0x8b)
{
ce_len = c_strlen(http_html_gzip_contentencoding);
ENDUSER_SETUP_DEBUG("Content is gzipped");
}
int payload_len = LITLEN(http_header_200) + cl_len + ce_len + file_len;
state->http_payload_len = payload_len;
state->http_payload_data = (char *) c_malloc(payload_len);
......@@ -523,7 +523,7 @@ static int enduser_setup_http_load_payload(void)
}
vfs_lseek(f, 0, VFS_SEEK_SET);
int offset = 0;
c_memcpy(&(state->http_payload_data[offset]), &(http_header_200), LITLEN(http_header_200));
......@@ -531,14 +531,14 @@ static int enduser_setup_http_load_payload(void)
if (ce_len > 0)
{
offset += c_sprintf(state->http_payload_data + offset, http_html_gzip_contentencoding, ce_len);
offset += c_sprintf(state->http_payload_data + offset, http_html_gzip_contentencoding, ce_len);
}
c_memcpy(&(state->http_payload_data[offset]), &(cl_hdr), cl_len);
offset += cl_len;
vfs_read(f, &(state->http_payload_data[offset]), file_len);
vfs_close(f);
vfs_close(f);
return 0;
}
......@@ -611,7 +611,7 @@ static int enduser_setup_http_urldecode(char *dst, const char *src, int src_len,
static void do_station_cfg (task_param_t param, uint8_t prio)
{
ENDUSER_SETUP_DEBUG("do_station_cfg");
state->connecting = 1;
struct station_config *cnf = (struct station_config *)param;
(void)prio;
......@@ -645,7 +645,7 @@ static int enduser_setup_http_handle_credentials(char *data, unsigned short data
state->success = 0;
state->lastStationStatus = 0;
char *name_str = (char *) ((uint32_t)strstr(&(data[6]), "wifi_ssid="));
char *pwd_str = (char *) ((uint32_t)strstr(&(data[6]), "wifi_password="));
if (name_str == NULL || pwd_str == NULL)
......@@ -707,7 +707,7 @@ static int enduser_setup_http_handle_credentials(char *data, unsigned short data
static int enduser_setup_http_serve_header(struct tcp_pcb *http_client, const char *header, uint32_t header_len)
{
ENDUSER_SETUP_DEBUG("enduser_setup_http_serve_header");
err_t err = tcp_write (http_client, header, header_len, TCP_WRITE_FLAG_COPY);
if (err != ERR_OK)
{
......@@ -797,7 +797,7 @@ static void enduser_setup_serve_status(struct tcp_pcb *conn)
"HTTP/1.1 200 OK\r\n"
"Cache-control:no-cache\r\n"
"Connection:close\r\n"
"Access-Control-Allow-Origin: *\r\n"
"Access-Control-Allow-Origin: *\r\n"
"Content-type:text/plain\r\n"
"Content-length: %d\r\n"
"\r\n"
......@@ -813,7 +813,7 @@ static void enduser_setup_serve_status(struct tcp_pcb *conn)
};
const size_t num_states = sizeof(states)/sizeof(states[0]);
uint8_t curr_state = state->lastStationStatus > 0 ? state->lastStationStatus : wifi_station_get_connect_status ();
uint8_t curr_state = state->lastStationStatus > 0 ? state->lastStationStatus : wifi_station_get_connect_status ();
if (curr_state < num_states)
{
switch (curr_state)
......@@ -880,9 +880,9 @@ static void enduser_setup_serve_status(struct tcp_pcb *conn)
static void enduser_setup_serve_status_as_json (struct tcp_pcb *http_client)
{
ENDUSER_SETUP_DEBUG("enduser_setup_serve_status_as_json");
/* If the station is currently shut down because of wi-fi channel issue, use the cached status */
uint8_t curr_status = state->lastStationStatus > 0 ? state->lastStationStatus : wifi_station_get_connect_status ();
uint8_t curr_status = state->lastStationStatus > 0 ? state->lastStationStatus : wifi_station_get_connect_status ();
char json_payload[64];
......@@ -902,7 +902,7 @@ static void enduser_setup_serve_status_as_json (struct tcp_pcb *http_client)
{
c_sprintf(json_payload, "{\"deviceid\":\"%06X\", \"status\":%d}", system_get_chip_id(), curr_status);
}
const char fmt[] =
"HTTP/1.1 200 OK\r\n"
"Cache-Control: no-cache\r\n"
......@@ -923,7 +923,7 @@ static void enduser_setup_serve_status_as_json (struct tcp_pcb *http_client)
static void enduser_setup_handle_OPTIONS (struct tcp_pcb *http_client, char *data, unsigned short data_len)
{
ENDUSER_SETUP_DEBUG("enduser_setup_handle_OPTIONS");
const char json[] =
"HTTP/1.1 200 OK\r\n"
"Cache-Control: no-cache\r\n"
......@@ -939,11 +939,11 @@ static void enduser_setup_handle_OPTIONS (struct tcp_pcb *http_client, char *dat
"HTTP/1.1 200 OK\r\n"
"Cache-Control: no-cache\r\n"
"Connection: close\r\n"
"Content-Length: 0\r\n"
"Content-Length: 0\r\n"
"\r\n";
int type = 0;
if (c_strncmp(data, "GET ", 4) == 0)
{
if (c_strncmp(data + 4, "/aplist", 7) == 0 || c_strncmp(data + 4, "/setwifi?", 9) == 0 || c_strncmp(data + 4, "/status.json", 12) == 0)
......@@ -961,7 +961,7 @@ static void enduser_setup_handle_OPTIONS (struct tcp_pcb *http_client, char *dat
static void free_scan_listeners (void)
{
ENDUSER_SETUP_DEBUG("free_scan_listeners");
ENDUSER_SETUP_DEBUG("free_scan_listeners");
if (!state || !state->scan_listeners)
{
......@@ -981,7 +981,7 @@ static void free_scan_listeners (void)
static void remove_scan_listener (scan_listener_t *l)
{
ENDUSER_SETUP_DEBUG("remove_scan_listener");
ENDUSER_SETUP_DEBUG("remove_scan_listener");
if (state)
{
......@@ -1018,7 +1018,7 @@ static char *escape_ssid (char *dst, const char *src)
static void notify_scan_listeners (const char *payload, size_t sz)
{
ENDUSER_SETUP_DEBUG("notify_scan_listeners");
ENDUSER_SETUP_DEBUG("notify_scan_listeners");
if (!state)
{
......@@ -1043,7 +1043,7 @@ static void notify_scan_listeners (const char *payload, size_t sz)
static void on_scan_done (void *arg, STATUS status)
{
ENDUSER_SETUP_DEBUG("on_scan_done");
ENDUSER_SETUP_DEBUG("on_scan_done");
if (!state || !state->scan_listeners)
{
......@@ -1062,7 +1062,7 @@ static void on_scan_done (void *arg, STATUS status)
"HTTP/1.1 200 OK\r\n"
"Connection:close\r\n"
"Cache-control:no-cache\r\n"
"Access-Control-Allow-Origin: *\r\n"
"Access-Control-Allow-Origin: *\r\n"
"Content-type:application/json\r\n"
"Content-length:%4d\r\n"
"\r\n";
......@@ -1098,12 +1098,12 @@ static void on_scan_done (void *arg, STATUS status)
p += sizeof (entry_mid) -1;
p += c_sprintf (p, "%d", wn->rssi);
const char entry_chan[] = ",\"chan\":";
const char entry_chan[] = ",\"chan\":";
strcpy (p, entry_chan);
p += sizeof (entry_chan) -1;
p += c_sprintf (p, "%d", wn->channel);
p += c_sprintf (p, "%d", wn->channel);
*p++ = '}';
}
......@@ -1114,8 +1114,8 @@ static void on_scan_done (void *arg, STATUS status)
http[hdr_sz] = '['; /* Rewrite the \0 with the correct start of body */
notify_scan_listeners (http, hdr_sz + body_sz);
ENDUSER_SETUP_DEBUG(http + hdr_sz);
ENDUSER_SETUP_DEBUG(http + hdr_sz);
c_free (http);
return;
}
......@@ -1179,7 +1179,7 @@ static err_t enduser_setup_http_recvcb(void *arg, struct tcp_pcb *http_client, s
else if (c_strncmp(data + 4, "/aplist", 7) == 0)
{
/* Don't do an AP Scan while station is trying to connect to Wi-Fi */
if (state->connecting == 0)
if (state->connecting == 0)
{
scan_listener_t *l = os_malloc (sizeof (scan_listener_t));
if (!l)
......@@ -1210,13 +1210,13 @@ static err_t enduser_setup_http_recvcb(void *arg, struct tcp_pcb *http_client, s
else
{
/* Return No Content status to the caller */
enduser_setup_http_serve_header(http_client, http_header_204, LITLEN(http_header_204));
enduser_setup_http_serve_header(http_client, http_header_204, LITLEN(http_header_204));
}
}
else if (c_strncmp(data + 4, "/status.json", 12) == 0)
{
enduser_setup_serve_status_as_json(http_client);
}
}
else if (c_strncmp(data + 4, "/status", 7) == 0)
{
enduser_setup_serve_status(http_client);
......@@ -1251,7 +1251,7 @@ static err_t enduser_setup_http_recvcb(void *arg, struct tcp_pcb *http_client, s
ENDUSER_SETUP_ERROR("http_recvcb failed. Failed to handle wifi credentials.", ENDUSER_SETUP_ERR_UNKOWN_ERROR, ENDUSER_SETUP_ERR_NONFATAL);
break;
}
}
}
else if (c_strncmp(data + 4, "/generate_204", 13) == 0)
{
/* Convince Android devices that they have internet access to avoid pesky dialogues. */
......@@ -1266,7 +1266,7 @@ static err_t enduser_setup_http_recvcb(void *arg, struct tcp_pcb *http_client, s
else if (c_strncmp(data, "OPTIONS ", 8) == 0)
{
enduser_setup_handle_OPTIONS(http_client, data, data_len);
}
}
else /* not GET or OPTIONS */
{
enduser_setup_http_serve_header(http_client, http_header_405, LITLEN(http_header_405));
......@@ -1390,11 +1390,11 @@ static void enduser_setup_ap_start(void)
wifi_set_opmode(STATIONAP_MODE);
wifi_softap_set_config(&cnf);
#if ENDUSER_SETUP_DEBUG_ENABLE
#if ENDUSER_SETUP_DEBUG_ENABLE
char debuginfo[100];
c_sprintf(debuginfo, "SSID: %s, CHAN: %d", cnf.ssid, cnf.channel);
ENDUSER_SETUP_DEBUG(debuginfo);
#endif
ENDUSER_SETUP_DEBUG(debuginfo);
#endif
}
static void on_initial_scan_done (void *arg, STATUS status)
......@@ -1407,16 +1407,16 @@ static void on_initial_scan_done (void *arg, STATUS status)
}
int8_t rssi = -100;
if (status == OK)
{
/* Find the strongest signal and use the same wi-fi channel for the SoftAP. This is based on an assumption that end-user
* will likely be choosing that AP to connect to. Since ESP only has one radio, STA and AP must share same channel. This
* algorithm tries to minimize the SoftAP unavailability when the STA is connecting to verify. If the STA must switch to
* another wi-fi channel, then the SoftAP will follow it, but the end-user's device will not know that the SoftAP is no
/* Find the strongest signal and use the same wi-fi channel for the SoftAP. This is based on an assumption that end-user
* will likely be choosing that AP to connect to. Since ESP only has one radio, STA and AP must share same channel. This
* algorithm tries to minimize the SoftAP unavailability when the STA is connecting to verify. If the STA must switch to
* another wi-fi channel, then the SoftAP will follow it, but the end-user's device will not know that the SoftAP is no
* longer there until it times out. To mitigate, we try to prevent the need to switch channels, and if a switch does occur,
* be quick about returning to this channel so that status info can be delivered to the end-user's device before shutting
* down EUS.
* be quick about returning to this channel so that status info can be delivered to the end-user's device before shutting
* down EUS.
*/
for (struct bss_info *wn = arg; wn; wn = wn->next.stqe_next)
{
......@@ -1427,7 +1427,7 @@ static void on_initial_scan_done (void *arg, STATUS status)
}
}
}
enduser_setup_ap_start();
enduser_setup_check_station_start();
}
......@@ -1444,18 +1444,18 @@ static void enduser_setup_dns_recv_callback(void *arg, char *recv_data, unsigned
uint32_t dns_reply_len = dns_reply_static_len + qname_len;
#if ENDUSER_SETUP_DEBUG_ENABLE
char *qname = c_malloc(qname_len + 12);
char *qname = c_malloc(qname_len + 12);
if (qname != NULL)
{
c_sprintf(qname, "DNS QUERY = %s", &(recv_data[12]));
uint32_t p;
int i, j;
for(i=12;i<(int)strlen(qname);i++)
for(i=12;i<(int)strlen(qname);i++)
{
p=qname[i];
for(j=0;j<(int)p;j++)
for(j=0;j<(int)p;j++)
{
qname[i]=qname[i+1];
i=i+1;
......@@ -1463,7 +1463,7 @@ static void enduser_setup_dns_recv_callback(void *arg, char *recv_data, unsigned
qname[i]='.';
}
qname[i-1]='\0';
ENDUSER_SETUP_DEBUG(qname);
ENDUSER_SETUP_DEBUG(qname);
c_free(qname);
}
#endif
......@@ -1521,11 +1521,11 @@ static void enduser_setup_dns_recv_callback(void *arg, char *recv_data, unsigned
else if (err == ESPCONN_MAXNUM)
{
ENDUSER_SETUP_ERROR_VOID("dns_recv_callback failed. Buffer full. Discarding...", ENDUSER_SETUP_ERR_MAX_NUMBER, ENDUSER_SETUP_ERR_NONFATAL);
}
}
else if (err == ESPCONN_IF)
{
ENDUSER_SETUP_ERROR_VOID("dns_recv_callback failed. Send UDP data failed", ENDUSER_SETUP_ERR_UNKOWN_ERROR, ENDUSER_SETUP_ERR_NONFATAL);
}
}
else if (err != 0)
{
ENDUSER_SETUP_ERROR_VOID("dns_recv_callback failed. espconn_send failed", ENDUSER_SETUP_ERR_UNKOWN_ERROR, ENDUSER_SETUP_ERR_FATAL);
......@@ -1649,17 +1649,17 @@ static int enduser_setup_init(lua_State *L)
}
else
{
c_memset(state, 0, sizeof(enduser_setup_state_t));
c_memset(state, 0, sizeof(enduser_setup_state_t));
state->lua_connected_cb_ref = LUA_NOREF;
state->lua_err_cb_ref = LUA_NOREF;
state->lua_dbg_cb_ref = LUA_NOREF;
state->lua_dbg_cb_ref = LUA_NOREF;
state->softAPchannel = 1;
state->success = 0;
state->callbackDone = 0;
state->lastStationStatus = 0;
state->connecting = 0;
state->connecting = 0;
}
}
......@@ -1679,14 +1679,14 @@ static int enduser_setup_init(lua_State *L)
{
lua_pushvalue (L, 3);
state->lua_dbg_cb_ref = luaL_ref(L, LUA_REGISTRYINDEX);
ENDUSER_SETUP_DEBUG("enduser_setup_init: Debug callback has been set");
ENDUSER_SETUP_DEBUG("enduser_setup_init: Debug callback has been set");
}
if (ret == ENDUSER_SETUP_ERR_ALREADY_INITIALIZED)
if (ret == ENDUSER_SETUP_ERR_ALREADY_INITIALIZED)
{
ENDUSER_SETUP_ERROR("init failed. Appears to already be started. EUS will shut down now.", ENDUSER_SETUP_ERR_ALREADY_INITIALIZED, ENDUSER_SETUP_ERR_FATAL);
}
else if (ret == ENDUSER_SETUP_ERR_OUT_OF_MEMORY)
else if (ret == ENDUSER_SETUP_ERR_OUT_OF_MEMORY)
{
ENDUSER_SETUP_ERROR("init failed. Unable to allocate memory.", ENDUSER_SETUP_ERR_OUT_OF_MEMORY, ENDUSER_SETUP_ERR_FATAL);
}
......@@ -1725,7 +1725,7 @@ static int enduser_setup_start(lua_State *L)
if (!manual)
{
ENDUSER_SETUP_DEBUG("Performing AP Scan to identify likely AP's channel. Enabling Station if it wasn't already.");
ENDUSER_SETUP_DEBUG("Performing AP Scan to identify likely AP's channel. Enabling Station if it wasn't already.");
wifi_set_opmode(STATION_MODE | wifi_get_opmode());
wifi_station_scan(NULL, on_initial_scan_done);
}
......@@ -1775,7 +1775,7 @@ static int enduser_setup_stop(lua_State* L)
wifi_set_opmode(STATION_MODE | wifi_get_opmode());
wifi_station_connect();
enduser_setup_connected_callback();
}
}
enduser_setup_dns_stop();
enduser_setup_http_stop();
enduser_setup_free();
......
......@@ -135,7 +135,7 @@ static int file_close( lua_State* L )
// mark as closed
ud->fd = 0;
}
return 0;
return 0;
}
static int file_obj_free( lua_State *L )
......@@ -207,7 +207,7 @@ static int file_open( lua_State* L )
lua_pushvalue( L, -1 );
file_fd_ref = luaL_ref( L, LUA_REGISTRYINDEX );
}
return 1;
return 1;
}
// Lua: list()
......@@ -229,7 +229,7 @@ static int file_list( lua_State* L )
lua_newtable( L ); /* Table at 2 */
if (pattern) {
/*
/*
* We know that pattern is a string, and so the "match" method will always
* exist. No need to check return value here
*/
......@@ -300,7 +300,7 @@ static int file_seek (lua_State *L)
static int file_exists( lua_State* L )
{
size_t len;
const char *fname = luaL_checklstring( L, 1, &len );
const char *fname = luaL_checklstring( L, 1, &len );
const char *basename = vfs_basename( fname );
luaL_argcheck(L, c_strlen(basename) <= FS_OBJ_NAME_LEN && c_strlen(fname) == len, 1, "filename invalid");
......@@ -314,7 +314,7 @@ static int file_exists( lua_State* L )
static int file_remove( lua_State* L )
{
size_t len;
const char *fname = luaL_checklstring( L, 1, &len );
const char *fname = luaL_checklstring( L, 1, &len );
const char *basename = vfs_basename( fname );
luaL_argcheck(L, c_strlen(basename) <= FS_OBJ_NAME_LEN && c_strlen(fname) == len, 1, "filename invalid");
vfs_remove((char *)fname);
......@@ -343,8 +343,8 @@ static int file_rename( lua_State* L )
const char *oldname = luaL_checklstring( L, 1, &len );
const char *basename = vfs_basename( oldname );
luaL_argcheck(L, c_strlen(basename) <= FS_OBJ_NAME_LEN && c_strlen(oldname) == len, 1, "filename invalid");
const char *newname = luaL_checklstring( L, 2, &len );
const char *newname = luaL_checklstring( L, 2, &len );
basename = vfs_basename( newname );
luaL_argcheck(L, c_strlen(basename) <= FS_OBJ_NAME_LEN && c_strlen(newname) == len, 2, "filename invalid");
......@@ -360,7 +360,7 @@ static int file_rename( lua_State* L )
static int file_stat( lua_State* L )
{
size_t len;
const char *fname = luaL_checklstring( L, 1, &len );
const char *fname = luaL_checklstring( L, 1, &len );
luaL_argcheck( L, c_strlen(fname) <= FS_OBJ_NAME_LEN && c_strlen(fname) == len, 1, "filename invalid" );
struct vfs_stat stat;
......@@ -483,7 +483,7 @@ static int file_g_read( lua_State* L, int n, int16_t end_char, int fd )
// Lua: read()
// file.read() will read all byte in file
// file.read(10) will read 10 byte from file, or EOF is reached.
// file.read('q') will read until 'q' or EOF is reached.
// file.read('q') will read until 'q' or EOF is reached.
static int file_read( lua_State* L )
{
unsigned need_len = FILE_READ_CHUNK;
......@@ -660,7 +660,7 @@ static const LUA_REG_TYPE file_map[] = {
{ LSTRKEY( "seek" ), LFUNCVAL( file_seek ) },
{ LSTRKEY( "flush" ), LFUNCVAL( file_flush ) },
{ LSTRKEY( "rename" ), LFUNCVAL( file_rename ) },
{ LSTRKEY( "exists" ), LFUNCVAL( file_exists ) },
{ LSTRKEY( "exists" ), LFUNCVAL( file_exists ) },
{ LSTRKEY( "fsinfo" ), LFUNCVAL( file_fsinfo ) },
{ LSTRKEY( "on" ), LFUNCVAL( file_on ) },
{ LSTRKEY( "stat" ), LFUNCVAL( file_stat ) },
......
......@@ -2,8 +2,8 @@
* This module, when enabled with the LUA_USE_MODULES_GDBSTUB define causes
* the gdbstub code to be included and enabled to handle all fatal exceptions.
* This allows you to use the lx106 gdb to catch the exception and then poke
* around. You can continue from a break, but attempting to continue from an
* exception usually fails.
* around. You can continue from a break, but attempting to continue from an
* exception usually fails.
*
* This should not be included in production builds as any exception will
* put the nodemcu into a state where it is waiting for serial input and it has
......
......@@ -58,7 +58,7 @@ static void gpio_intr_callback_task (task_param_t param, uint8 priority)
while (needs_callback) {
// Note that the interrupt level only modifies 'seen' and
// the base level only modifies 'reported'.
// the base level only modifies 'reported'.
// Do the actual callback
lua_rawgeti(L, LUA_REGISTRYINDEX, gpio_cb_ref[pin]);
......@@ -77,7 +77,7 @@ static void gpio_intr_callback_task (task_param_t param, uint8 priority)
}
lua_call(L, 3, 0);
}
}
if (INTERRUPT_TYPE_IS_LEVEL(pin_int_type[pin])) {
// Level triggered -- re-enable the callback
......@@ -105,7 +105,7 @@ static int lgpio_trig( lua_State* L )
gpio_cb_ref[pin] = LUA_NOREF;
} else if (lua_gettop(L)==2 && old_pin_ref != LUA_NOREF) {
// keep the old one if no callback
// keep the old one if no callback
old_pin_ref = LUA_NOREF;
} else if (lua_type(L, 3) == LUA_TFUNCTION || lua_type(L, 3) == LUA_TLIGHTFUNCTION) {
......@@ -154,7 +154,7 @@ static int lgpio_mode( lua_State* L )
NODE_DBG("pin,mode,pullup= %d %d %d\n",pin,mode,pullup);
NODE_DBG("Pin data at mode: %d %08x, %d %d %d, %08x\n",
pin, pin_mux[pin], pin_num[pin], pin_func[pin],
pin, pin_mux[pin], pin_num[pin], pin_func[pin],
#ifdef GPIO_INTERRUPT_ENABLE
pin_int_type[pin], gpio_cb_ref[pin]
#else
......@@ -303,7 +303,7 @@ static int lgpio_serout( lua_State* L )
serout.index = 0;
seroutasync_cb(0);
} else { // sync version for sub-50 µs resolution & total duration < 15 mSec
do {
do {
for( serout.index = 0;serout.index < serout.tablelen; serout.index++ ){
NODE_DBG("%d\t%d\t%d\t%d\t%d\t%d\t%d\n", serout.repeats, serout.index, serout.level, serout.pin, serout.tablelen, serout.delay_table[serout.index], system_get_time()); // timings is delayed for short timings when debug output is enabled
GPIO_OUTPUT_SET(GPIO_ID_PIN(pin_num[serout.pin]), serout.level);
......
......@@ -92,7 +92,7 @@ static int gpio_pulse_stop(lua_State *L) {
int32_t stop_pos = -2;
if (lua_type(L, argno) == LUA_TNUMBER) {
stop_pos = luaL_checkinteger(L, 2);
stop_pos = luaL_checkinteger(L, 2);
if (stop_pos != -2) {
if (stop_pos < 1 || stop_pos > pulser->entry_count) {
return luaL_error( L, "bad stop position: %d (valid range 1 - %d)", stop_pos, pulser->entry_count );
......@@ -235,7 +235,7 @@ static int gpio_pulse_build(lua_State *L) {
static int gpio_pulse_update(lua_State *L) {
pulse_t *pulser = luaL_checkudata(L, 1, "gpio.pulse");
int entry_pos = luaL_checkinteger(L, 2);
int entry_pos = luaL_checkinteger(L, 2);
if (entry_pos < 1 || entry_pos > pulser->entry_count) {
return luaL_error(L, "entry number must be in range 1 .. %d", pulser->entry_count);
......@@ -368,8 +368,8 @@ static void ICACHE_RAM_ATTR gpio_pulse_timeout(os_param_t p) {
delay_offset = ((0x7fffffff & (now - active_pulser->desired_end_time)) << 1) >> 1;
delay -= delay_offset;
delay += offset;
//dbg_printf("%d(et %d diff %d): Delay was %d us, offset = %d, delay_offset = %d, new delay = %d, range=%d..%d\n",
// now, active_pulser->desired_end_time, now - active_pulser->desired_end_time,
//dbg_printf("%d(et %d diff %d): Delay was %d us, offset = %d, delay_offset = %d, new delay = %d, range=%d..%d\n",
// now, active_pulser->desired_end_time, now - active_pulser->desired_end_time,
// entry->delay, offset, delay_offset, delay, entry->delay_min, entry->delay_max);
if (delay < entry->delay_min) {
// we can't delay as little as 'delay', so we need to adjust
......@@ -387,7 +387,7 @@ static void ICACHE_RAM_ATTR gpio_pulse_timeout(os_param_t p) {
active_pulser->desired_end_time += delay + delay_offset;
active_pulser->expected_end_time = system_get_time() + delay;
} while (delay < 3);
if (delay > 1200000) {
active_pulser->pending_delay = delay - 1000000;
delay = 1000000;
......@@ -446,7 +446,7 @@ static int gpio_pulse_start(lua_State *L) {
return 0;
}
static void gpio_pulse_task(os_param_t param, uint8_t prio)
static void gpio_pulse_task(os_param_t param, uint8_t prio)
{
(void) param;
(void) prio;
......
/*
* Driver for TI Texas Instruments HDC1080 Temperature/Humidity Sensor.
* Code By Metin KOC
* Code By Metin KOC
* Sixfab Inc. metin@sixfab.com
* Code based on ADXL345 driver.
*/
......@@ -25,18 +25,18 @@ static int hdc1080_setup(lua_State* L) {
// Configure Sensor
platform_i2c_send_start(hdc1080_i2c_id);
platform_i2c_send_address(hdc1080_i2c_id, hdc1080_i2c_addr, PLATFORM_I2C_DIRECTION_TRANSMITTER);
platform_i2c_send_byte(hdc1080_i2c_id, HDC1080_CONFIG_REGISTER);
platform_i2c_send_byte(hdc1080_i2c_id, HDC1080_CONFIG_REGISTER);
platform_i2c_send_byte(hdc1080_i2c_id, 0x05); //Bit[10] to 1 for 11 bit resolution , Set Bit[9:8] to 01 for 11 bit resolution.
platform_i2c_send_byte(hdc1080_i2c_id, 0x00);
platform_i2c_send_stop(hdc1080_i2c_id);
return 0;
}
static int hdc1080_read(lua_State* L) {
uint8_t data[2];
#ifdef LUA_NUMBER_INTEGRAL
int temp;
int humidity;
......@@ -44,7 +44,7 @@ static int hdc1080_read(lua_State* L) {
float temp;
float humidity;
#endif
int i;
platform_i2c_send_start(hdc1080_i2c_id);
......@@ -70,8 +70,8 @@ static int hdc1080_read(lua_State* L) {
temp = ((float)((data[0]<<8)|data[1])/(float)pow(2,16))*165.0f-40.0f;
lua_pushnumber(L, temp);
#endif
platform_i2c_send_start(hdc1080_i2c_id);
platform_i2c_send_address(hdc1080_i2c_id, hdc1080_i2c_addr, PLATFORM_I2C_DIRECTION_TRANSMITTER);
platform_i2c_send_byte(hdc1080_i2c_id, HDC1080_HUMIDITY_REGISTER);
......@@ -95,7 +95,7 @@ static int hdc1080_read(lua_State* L) {
humidity = ((float)((data[0]<<8)|data[1])/(float)pow(2,16))*100.0f;
lua_pushnumber(L, humidity);
#endif
return 2;
}
......
......@@ -73,7 +73,7 @@ static int hmc5883_read(lua_State* L) {
for (i=0; i<5; i++) {
data[i] = platform_i2c_recv_byte(hmc5883_i2c_id, 1);
}
data[5] = platform_i2c_recv_byte(hmc5883_i2c_id, 0);
platform_i2c_send_stop(hmc5883_i2c_id);
......
......@@ -278,7 +278,7 @@ static const LUA_REG_TYPE http_map[] = {
{ LSTRKEY( "OK" ), LNUMVAL( 0 ) },
{ LSTRKEY( "ERROR" ), LNUMVAL( HTTP_STATUS_GENERIC_ERROR ) },
{ LNILKEY, LNILVAL }
};
......
......@@ -63,7 +63,7 @@ static int l3g4200d_read(lua_State* L) {
for (i=0; i<5; i++) {
data[i] = platform_i2c_recv_byte(i2c_id, 1);
}
data[5] = platform_i2c_recv_byte(i2c_id, 0);
platform_i2c_send_stop(i2c_id);
......
......@@ -14,7 +14,7 @@
//
// mdns.close()
//
//
static int mdns_close(lua_State *L)
{
nodemcu_mdns_close();
......@@ -29,7 +29,7 @@ static int mdns_register(lua_State *L)
struct nodemcu_mdns_info info;
memset(&info, 0, sizeof(info));
info.host_name = luaL_checkstring(L, 1);
info.service_name = "http";
info.service_port = 80;
......@@ -73,7 +73,7 @@ static int mdns_register(lua_State *L)
// Close up the old session (if any). This cannot fail
// so no chance of losing the memory in 'result'
mdns_close(L);
// Save the result as it appears that nodemcu_mdns_init needs
......
......@@ -13,7 +13,7 @@
#include "osapi.h"
#include "lwip/err.h"
#include "lwip/ip_addr.h"
#include "lwip/dns.h"
#include "lwip/dns.h"
#include "lwip/igmp.h"
#include "lwip/tcp.h"
#include "lwip/udp.h"
......
......@@ -503,7 +503,7 @@ static int node_osprint( lua_State* L )
system_set_os_print(0);
}
return 0;
return 0;
}
int node_random_range(int l, int u) {
......@@ -570,7 +570,7 @@ static int node_random (lua_State *L) {
u = luaL_checkint(L, 2);
break;
}
default:
default:
return luaL_error(L, "wrong number of arguments");
}
luaL_argcheck(L, l<=u, 2, "interval is empty");
......
......@@ -9,7 +9,7 @@
static int ow_setup( lua_State *L )
{
unsigned id = luaL_checkinteger( L, 1 );
if(id==0)
return luaL_error( L, "no 1-wire for D0" );
......@@ -210,7 +210,7 @@ static int ow_search( lua_State *L )
lua_pop(L,1);
lua_pushnil(L);
}
return 1;
return 1;
}
#endif
......
//
// This module allows performance monitoring by looking at
// the PC at regular intervals and building a histogram
//
//
// perf.start(start, end, nbins[, pc offset on stack])
// perf.stop() -> total sample, samples outside range, table { addr -> count , .. }
......
......@@ -11,7 +11,7 @@ static int lpwm_setup( lua_State* L )
s32 freq; // signed, to error check for negative values
unsigned duty;
unsigned id;
id = luaL_checkinteger( L, 1 );
if(id==0)
return luaL_error( L, "no pwm for D0" );
......@@ -27,18 +27,18 @@ static int lpwm_setup( lua_State* L )
if(freq==0)
return luaL_error( L, "too many pwms." );
lua_pushinteger( L, freq );
return 1;
return 1;
}
// Lua: close( id )
static int lpwm_close( lua_State* L )
{
unsigned id;
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( pwm, id );
platform_pwm_close( id );
return 0;
return 0;
}
// Lua: start( id )
......@@ -50,18 +50,18 @@ static int lpwm_start( lua_State* L )
if (!platform_pwm_start( id )) {
return luaL_error(L, "Unable to start PWM output");
}
return 0;
return 0;
}
// Lua: stop( id )
static int lpwm_stop( lua_State* L )
{
unsigned id;
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( pwm, id );
platform_pwm_stop( id );
return 0;
return 0;
}
// Lua: realclock = setclock( id, clock )
......@@ -69,7 +69,7 @@ static int lpwm_setclock( lua_State* L )
{
unsigned id;
s32 clk; // signed to error-check for negative values
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( pwm, id );
clk = luaL_checkinteger( L, 2 );
......@@ -85,7 +85,7 @@ static int lpwm_getclock( lua_State* L )
{
unsigned id;
u32 clk;
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( pwm, id );
clk = platform_pwm_get_clock( id );
......@@ -98,7 +98,7 @@ static int lpwm_setduty( lua_State* L )
{
unsigned id;
s32 duty; // signed to error-check for negative values
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( pwm, id );
duty = luaL_checkinteger( L, 2 );
......@@ -114,7 +114,7 @@ static int lpwm_getduty( lua_State* L )
{
unsigned id;
u32 duty;
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( pwm, id );
duty = platform_pwm_get_duty( id );
......
/*
* Module for interfacing with cheap rotary switches that
* are much used in the automtive industry as the cntrols for
* are much used in the automtive industry as the cntrols for
* CD players and the like.
*
* Philip Gladstone, N1DQ
......@@ -55,7 +55,7 @@ static task_handle_t tasknumber;
static void lrotary_timer_done(void *param);
static void lrotary_check_timer(DATA *d, uint32_t time_us, bool dotimer);
static void callback_free_one(lua_State *L, int *cb_ptr)
static void callback_free_one(lua_State *L, int *cb_ptr)
{
if (*cb_ptr != LUA_NOREF) {
luaL_unref(L, LUA_REGISTRYINDEX, *cb_ptr);
......@@ -63,7 +63,7 @@ static void callback_free_one(lua_State *L, int *cb_ptr)
}
}
static void callback_free(lua_State* L, unsigned int id, int mask)
static void callback_free(lua_State* L, unsigned int id, int mask)
{
DATA *d = data[id];
......@@ -77,7 +77,7 @@ static void callback_free(lua_State* L, unsigned int id, int mask)
}
}
static int callback_setOne(lua_State* L, int *cb_ptr, int arg_number)
static int callback_setOne(lua_State* L, int *cb_ptr, int arg_number)
{
if (lua_type(L, arg_number) == LUA_TFUNCTION || lua_type(L, arg_number) == LUA_TLIGHTFUNCTION) {
lua_pushvalue(L, arg_number); // copy argument (func) to the top of stack
......@@ -89,7 +89,7 @@ static int callback_setOne(lua_State* L, int *cb_ptr, int arg_number)
return -1;
}
static int callback_set(lua_State* L, int id, int mask, int arg_number)
static int callback_set(lua_State* L, int id, int mask, int arg_number)
{
DATA *d = data[id];
int result = 0;
......@@ -104,7 +104,7 @@ static int callback_set(lua_State* L, int id, int mask, int arg_number)
return result;
}
static void callback_callOne(lua_State* L, int cb, int mask, int arg, uint32_t time)
static void callback_callOne(lua_State* L, int cb, int mask, int arg, uint32_t time)
{
if (cb != LUA_NOREF) {
lua_rawgeti(L, LUA_REGISTRYINDEX, cb);
......@@ -117,7 +117,7 @@ static void callback_callOne(lua_State* L, int cb, int mask, int arg, uint32_t t
}
}
static void callback_call(lua_State* L, DATA *d, int cbnum, int arg, uint32_t time)
static void callback_call(lua_State* L, DATA *d, int cbnum, int arg, uint32_t time)
{
if (d) {
callback_callOne(L, d->callback[cbnum], 1 << cbnum, arg, time);
......@@ -135,7 +135,7 @@ int platform_rotary_exists( unsigned int id )
static int lrotary_setup( lua_State* L )
{
unsigned int id;
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( rotary, id );
......@@ -148,7 +148,7 @@ static int lrotary_setup( lua_State* L )
data[id] = (DATA *) c_zalloc(sizeof(DATA));
if (!data[id]) {
return -1;
}
}
}
DATA *d = data[id];
......@@ -162,7 +162,7 @@ static int lrotary_setup( lua_State* L )
//My guess: Since proper functionality relies on some variables to be reset via timer callback and state would be invalid anyway.
//It is probably best to resume this timer so it can reset it's state variables
int i;
for (i = 0; i < CALLBACK_COUNT; i++) {
d->callback[i] = LUA_NOREF;
......@@ -196,14 +196,14 @@ static int lrotary_setup( lua_State* L )
if (rotary_setup(id, phase_a, phase_b, press, tasknumber)) {
return luaL_error(L, "Unable to setup rotary switch.");
}
return 0;
return 0;
}
// Lua: close( id )
static int lrotary_close( lua_State* L )
{
unsigned int id;
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( rotary, id );
callback_free(L, id, ROTARY_ALL);
......@@ -217,7 +217,7 @@ static int lrotary_close( lua_State* L )
if (rotary_close( id )) {
return luaL_error( L, "Unable to close switch." );
}
return 0;
return 0;
}
// Lua: on( id, mask[, cb] )
......@@ -237,7 +237,7 @@ static int lrotary_on( lua_State* L )
callback_free(L, id, mask);
}
return 0;
return 0;
}
// Lua: getpos( id ) -> pos, PRESS/RELEASE
......@@ -256,7 +256,7 @@ static int lrotary_getpos( lua_State* L )
lua_pushnumber(L, (pos << 1) >> 1);
lua_pushnumber(L, (pos & 0x80000000) ? MASK(PRESS) : MASK(RELEASE));
return 2;
return 2;
}
// Returns TRUE if there maybe/is more stuff to do
......@@ -358,7 +358,7 @@ static void lrotary_check_timer(DATA *d, uint32_t time_us, bool dotimer)
}
}
static void lrotary_task(os_param_t param, uint8_t prio)
static void lrotary_task(os_param_t param, uint8_t prio)
{
(void) param;
(void) prio;
......@@ -381,14 +381,14 @@ static void lrotary_task(os_param_t param, uint8_t prio)
}
}
}
if (need_to_post) {
// If there is pending stuff, queue another task
task_post_medium(tasknumber, 0);
}
}
static int rotary_open(lua_State *L)
static int rotary_open(lua_State *L)
{
tasknumber = task_get_id(lrotary_task);
return 0;
......
......@@ -18,7 +18,7 @@
#define DEFAULT_DEPTH 20
#define DBG_PRINTF(...)
#define DBG_PRINTF(...)
typedef struct {
jsonsl_t jsn;
......@@ -86,12 +86,12 @@ create_new_element(jsonsl_t jsn,
switch(state->type) {
case JSONSL_T_SPECIAL:
case JSONSL_T_STRING:
case JSONSL_T_HKEY:
case JSONSL_T_STRING:
case JSONSL_T_HKEY:
break;
case JSONSL_T_LIST:
case JSONSL_T_OBJECT:
case JSONSL_T_LIST:
case JSONSL_T_OBJECT:
create_table(data);
state->lua_object_ref = lua_ref(data->L, 1);
state->used_count = 0;
......@@ -102,7 +102,7 @@ create_new_element(jsonsl_t jsn,
lua_pushnumber(data->L, get_parent_object_used_count_pre_inc());
DBG_PRINTF("Adding array element\n");
} else {
// object, so
// object, so
lua_rawgeti(data->L, LUA_REGISTRYINDEX, data->hkey_ref);
lua_unref(data->L, data->hkey_ref);
data->hkey_ref = LUA_NOREF;
......@@ -118,7 +118,7 @@ create_new_element(jsonsl_t jsn,
// At this point, the stack:
// top: index/hash key
// : table
int want_value = 1;
// Invoke the checkpath method if possible
if (data->pos_ref != LUA_NOREF) {
......@@ -245,7 +245,7 @@ cleanup_closing_element(jsonsl_t jsn,
// list, so append
lua_pushnumber(data->L, get_parent_object_used_count_pre_inc());
} else {
// object, so
// object, so
lua_rawgeti(data->L, LUA_REGISTRYINDEX, data->hkey_ref);
lua_unref(data->L, data->hkey_ref);
data->hkey_ref = LUA_NOREF;
......@@ -276,7 +276,7 @@ cleanup_closing_element(jsonsl_t jsn,
// list, so append
lua_pushnumber(data->L, get_parent_object_used_count_pre_inc());
} else {
// object, so
// object, so
lua_rawgeti(data->L, LUA_REGISTRYINDEX, data->hkey_ref);
lua_unref(data->L, data->hkey_ref);
data->hkey_ref = LUA_NOREF;
......@@ -347,7 +347,7 @@ static int sjson_decoder_int(lua_State *L, int argno) {
data->error = NULL;
data->L = L;
data->buffer_len = 0;
data->min_needed = data->min_available = jsn->pos;
lua_pushlightuserdata(L, 0);
......@@ -373,13 +373,13 @@ static int sjson_decoder_int(lua_State *L, int argno) {
lua_newtable(L);
data->pos_ref = lua_ref(L, 1);
}
lua_pop(L, 1); // Throw away the checkpath value
lua_pop(L, 1); // Throw away the checkpath value
}
lua_pop(L, 1); // Throw away the metatable
}
jsonsl_enable_all_callbacks(data->jsn);
jsn->action_callback = NULL;
jsn->action_callback_PUSH = create_new_element;
jsn->action_callback_POP = cleanup_closing_element;
......@@ -694,7 +694,7 @@ static void encode_lua_object(lua_State *L, ENC_DATA *data, int argno, const cha
lua_rawgeti(L, LUA_REGISTRYINDEX, data->null_ref);
if (lua_equal(L, -1, -2)) {
type = LUA_TNIL;
}
}
lua_pop(L, 1);
}
}
......@@ -785,7 +785,7 @@ static void encode_lua_object(lua_State *L, ENC_DATA *data, int argno, const cha
static int sjson_encoder_next_value_is_table(lua_State *L) {
int count = 10;
while ((lua_type(L, -1) == LUA_TFUNCTION
while ((lua_type(L, -1) == LUA_TFUNCTION
#ifdef LUA_TLIGHTFUNCTION
|| lua_type(L, -1) == LUA_TLIGHTFUNCTION
#endif
......@@ -815,7 +815,7 @@ static void sjson_encoder_make_next_chunk(lua_State *L, ENC_DATA *data) {
if (state->offset == 0) {
// start of object or whatever
luaL_addchar(&b, '[');
}
}
if (state->offset == state->size << 1) {
luaL_addchar(&b, ']');
finished = 1;
......@@ -1054,8 +1054,8 @@ LUALIB_API int luaopen_sjson (lua_State *L) {
luaL_register(L, NULL, sjson_decoder_map);
lua_setfield(L, -1, "__index");
#else
luaL_rometatable(L, "sjson.decoder", (void *)sjson_decoder_map);
luaL_rometatable(L, "sjson.encoder", (void *)sjson_encoder_map);
luaL_rometatable(L, "sjson.decoder", (void *)sjson_decoder_map);
luaL_rometatable(L, "sjson.encoder", (void *)sjson_encoder_map);
#endif
return 1;
}
......
......@@ -110,7 +110,7 @@ typedef struct
uint8_t server_index; // index into server table
uint8_t lookup_pos;
bool is_on_timeout;
uint32_t kodbits; // Only for up to 32 servers (more than enough)
uint32_t kodbits; // Only for up to 32 servers (more than enough)
int16_t server_pos;
int16_t last_server_pos;
int list_ref;
......@@ -226,7 +226,7 @@ static void sntp_handle_result(lua_State *L) {
const uint32_t MICROSECONDS = 1000000;
if (state->best.stratum == 0) {
// This could be because none of the servers are reachable, or maybe we haven't been able to look
// This could be because none of the servers are reachable, or maybe we haven't been able to look
// them up.
server_count = 0; // Reset for next time.
handle_error(L, NTP_TIMEOUT_ERR, NULL);
......@@ -841,7 +841,7 @@ error:
return luaL_error (L, errmsg);
}
static void sntp_task(os_param_t param, uint8_t prio)
static void sntp_task(os_param_t param, uint8_t prio)
{
(void) param;
(void) prio;
......
// ***************************************************************************
// Somfy module for ESP8266 with NodeMCU
//
//
// Written by Lukas Voborsky, @voborsky
// based on https://github.com/Nickduino/Somfy_Remote
// Somfy protocol description: https://pushstack.wordpress.com/somfy-rts-protocol/
// and discussion: https://forum.arduino.cc/index.php?topic=208346.0
//
//
// MIT license, http://opensource.org/licenses/MIT
// ***************************************************************************
......@@ -115,7 +115,7 @@ static void ICACHE_RAM_ATTR sendCommand(os_param_t p) {
// delayMicroseconds(89565);
break;
case 2:
signalindex++;
signalindex++;
// no break means go directly to step 3
// a "useless" step to allow repeating the hardware sync w/o the silence after wake-up pulse
case 3:
......@@ -162,7 +162,7 @@ static void ICACHE_RAM_ATTR sendCommand(os_param_t p) {
else {
DIRECT_WRITE_LOW(pin);
}
if (subindex<56) {
subindex++;
signalindex--;
......@@ -219,7 +219,7 @@ static int somfy_lua_sendcommand(lua_State* L) { // pin, remote, command, rollin
platform_gpio_mode(pin, PLATFORM_GPIO_OUTPUT, PLATFORM_GPIO_PULLUP);
buildFrame(frame, remote, cmd, code);
if (!platform_hw_timer_init(TIMER_OWNER, FRC1_SOURCE, TRUE)) {
// Failed to init the timer
luaL_error(L, "Unable to initialize timer");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment