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

trailing spaces cleanup (#2659)

parent d7583040
......@@ -1432,7 +1432,7 @@ static int db_update_hook(lua_State *L) {
** callback function:
** Params: userdata
** Returned value: Return false or nil to continue the COMMIT operation normally.
** return true (non false, non nil), then the COMMIT is converted into a ROLLBACK.
** return true (non false, non nil), then the COMMIT is converted into a ROLLBACK.
*/
static int db_commit_hook_callback(void *user) {
sdb *db = (sdb*)user;
......@@ -2167,7 +2167,7 @@ static int lsqlite_open_memory(lua_State *L) {
}
/* From: Wolfgang Oertl
When using lsqlite3 in a multithreaded environment, each thread has a separate Lua
When using lsqlite3 in a multithreaded environment, each thread has a separate Lua
environment, but full userdata structures can't be passed from one thread to another.
This is possible with lightuserdata, however. See: db_get_ptr().
*/
......
/*
* Module for interfacing with Switec instrument steppers (and
* similar devices). These are the steppers that are used in automotive
* similar devices). These are the steppers that are used in automotive
* instrument panels and the like. Run off 5 volts at low current.
*
* Code inspired by:
......@@ -25,13 +25,13 @@
static int stopped_callback[SWITEC_CHANNEL_COUNT] = { LUA_NOREF, LUA_NOREF, LUA_NOREF };
static task_handle_t tasknumber;
static void callback_free(lua_State* L, unsigned int id)
static void callback_free(lua_State* L, unsigned int id)
{
luaL_unref(L, LUA_REGISTRYINDEX, stopped_callback[id]);
stopped_callback[id] = LUA_NOREF;
}
static void callback_set(lua_State* L, unsigned int id, int argNumber)
static void callback_set(lua_State* L, unsigned int id, int argNumber)
{
if (lua_type(L, argNumber) == LUA_TFUNCTION || lua_type(L, argNumber) == LUA_TLIGHTFUNCTION) {
lua_pushvalue(L, argNumber); // copy argument (func) to the top of stack
......@@ -40,7 +40,7 @@ static void callback_set(lua_State* L, unsigned int id, int argNumber)
}
}
static void callback_execute(lua_State* L, unsigned int id)
static void callback_execute(lua_State* L, unsigned int id)
{
if (stopped_callback[id] != LUA_NOREF) {
int callback = stopped_callback[id];
......@@ -60,7 +60,7 @@ int platform_switec_exists( unsigned int id )
static int lswitec_setup( lua_State* L )
{
unsigned int id;
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( switec, id );
int pin[4];
......@@ -88,21 +88,21 @@ static int lswitec_setup( lua_State* L )
if (switec_setup(id, pin, deg_per_sec, tasknumber)) {
return luaL_error(L, "Unable to setup stepper.");
}
return 0;
return 0;
}
// Lua: close( id )
static int lswitec_close( lua_State* L )
{
unsigned int id;
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( switec, id );
callback_free(L, id);
if (switec_close( id )) {
return luaL_error( L, "Unable to close stepper." );
}
return 0;
return 0;
}
// Lua: reset( id )
......@@ -114,14 +114,14 @@ static int lswitec_reset( lua_State* L )
if (switec_reset( id )) {
return luaL_error( L, "Unable to reset stepper." );
}
return 0;
return 0;
}
// Lua: moveto( id, pos [, cb] )
static int lswitec_moveto( lua_State* L )
{
unsigned int id;
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( switec, id );
int pos;
......@@ -143,7 +143,7 @@ static int lswitec_moveto( lua_State* L )
static int lswitec_getpos( lua_State* L )
{
unsigned int id;
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( switec, id );
int32_t pos;
......@@ -177,7 +177,7 @@ static int lswitec_dequeue(lua_State* L)
return 0;
}
static void lswitec_task(os_param_t param, uint8_t prio)
static void lswitec_task(os_param_t param, uint8_t prio)
{
(void) param;
(void) prio;
......
// ***************************************************************************
// TCS34725 module for ESP8266 with nodeMCU
//
//
// Written by K. Townsend (microBuilder.eu), Adapted for nodeMCU by Travis Howse (tjhowse gmail.com)
//
//
// BSD (see license.txt)
// ***************************************************************************
......@@ -139,17 +139,17 @@ uint8_t tcs34725Write8 (uint8_t reg, uint8_t value)
uint8_t tcs34725Read8(uint8_t reg)
{
uint8_t value;
platform_i2c_send_start(TCS34725_BUS_ID);
platform_i2c_send_address(TCS34725_BUS_ID, TCS34725_ADDRESS, PLATFORM_I2C_DIRECTION_TRANSMITTER);
platform_i2c_send_byte(TCS34725_BUS_ID, TCS34725_COMMAND_BIT | reg);
platform_i2c_send_stop(TCS34725_BUS_ID);
platform_i2c_send_start(TCS34725_BUS_ID);
platform_i2c_send_address(TCS34725_BUS_ID, TCS34725_ADDRESS, PLATFORM_I2C_DIRECTION_RECEIVER);
value = platform_i2c_recv_byte(TCS34725_BUS_ID, 0);
platform_i2c_send_stop(TCS34725_BUS_ID);
return value;
}
......@@ -159,10 +159,10 @@ uint8_t tcs34725Read8(uint8_t reg)
*/
/**************************************************************************/
uint16_t tcs34725Read16(uint8_t reg)
{
{
uint8_t low = tcs34725Read8(reg);
uint8_t high = tcs34725Read8(++reg);
return (high << 8) | low;
}
/**************************************************************************/
......@@ -179,16 +179,16 @@ uint8_t tcs34725EnableDone()
/* Ready to go ... set the initialised flag */
_tcs34725Initialised = true;
/* This needs to take place after the initialisation flag! */
tcs34725SetIntegrationTime(TCS34725_INTEGRATIONTIME_2_4MS, L);
tcs34725SetGain(TCS34725_GAIN_60X, L);
tcs34725SetGain(TCS34725_GAIN_60X, L);
lua_rawgeti(L, LUA_REGISTRYINDEX, cb_tcs_en); // Get the callback to call
luaL_unref(L, LUA_REGISTRYINDEX, cb_tcs_en); // Unregister the callback to avoid leak
cb_tcs_en = LUA_NOREF;
lua_call(L, 0, 0);
return 0;
}
......@@ -210,7 +210,7 @@ uint8_t tcs34725Enable(lua_State* L)
} else {
return luaL_error(L, "Enable argument must be a function.");
}
tcs34725Write8(TCS34725_ENABLE, TCS34725_ENABLE_PON);
// Start a timer to wait TCS34725_EN_DELAY before calling tcs34725EnableDone
os_timer_disarm (&tcs34725_timer);
......@@ -250,7 +250,7 @@ uint8_t tcs34725Setup(lua_State* L)
if (id != 0x44) {
return luaL_error(L, "No TCS34725 found.");
}
lua_pushinteger(L, 1);
return 1;
}
......@@ -324,7 +324,7 @@ uint8_t tcs34725GetRawData(lua_State* L)
uint16_t g;
uint16_t b;
uint16_t c;
if (!_tcs34725Initialised)
{
return luaL_error(L, "TCS34725 not initialised.");
......
......@@ -486,7 +486,7 @@ static const char *append_pem_blob(const char *pem, const char *type, uint8_t **
return NULL;
}
static const char *fill_page_with_pem(lua_State *L, const unsigned char *flash_memory, int flash_offset, const char **types, const char **names)
static const char *fill_page_with_pem(lua_State *L, const unsigned char *flash_memory, int flash_offset, const char **types, const char **names)
{
uint8_t *buffer = luaM_malloc(L, INTERNAL_FLASH_SECTOR_SIZE);
uint8_t *buffer_base = buffer;
......
......@@ -132,14 +132,14 @@ static int tmr_delay( lua_State* L ){
os_delay_us(us);
system_soft_wdt_feed ();
}
return 0;
return 0;
}
// Lua: tmr.now() , return system timer in us
static int tmr_now(lua_State* L){
uint32_t now = 0x7FFFFFFF & system_get_time();
lua_pushinteger(L, now);
return 1;
return 1;
}
static timer_t tmr_get( lua_State *L, int stack ) {
......@@ -171,7 +171,7 @@ static int tmr_register(lua_State* L){
tmr->mode = mode|TIMER_IDLE_FLAG;
tmr->interval = interval;
os_timer_setfn(&tmr->os, alarm_timer_common, tmr);
return 0;
return 0;
}
// Lua: tmr.start( id / ref )
......@@ -217,7 +217,7 @@ static int tmr_stop(lua_State* L){
}else{
lua_pushboolean(L, 0);
}
return 1;
return 1;
}
#ifdef TIMER_SUSPEND_ENABLE
......@@ -256,7 +256,7 @@ static int tmr_unregister(lua_State* L){
if(tmr->lua_ref != LUA_NOREF)
luaL_unref(L, LUA_REGISTRYINDEX, tmr->lua_ref);
tmr->lua_ref = LUA_NOREF;
tmr->mode = TIMER_MODE_OFF;
tmr->mode = TIMER_MODE_OFF;
return 0;
}
......@@ -266,7 +266,7 @@ static int tmr_interval(lua_State* L){
uint32_t interval = luaL_checkinteger(L, 2);
luaL_argcheck(L, (interval > 0 && interval <= MAX_TIMEOUT), 2, MAX_TIMEOUT_ERR_STR);
if(tmr->mode != TIMER_MODE_OFF){
if(tmr->mode != TIMER_MODE_OFF){
tmr->interval = interval;
if(!(tmr->mode&TIMER_IDLE_FLAG)){
os_timer_disarm(&tmr->os);
......@@ -298,7 +298,7 @@ why they are here*/
static int tmr_wdclr( lua_State* L ){
system_soft_wdt_feed ();
// update_key_led();
return 0;
return 0;
}
//system_rtc_clock_cali_proc() returns
......@@ -344,13 +344,13 @@ void rtc_callback(void *arg){
static int tmr_time( lua_State* L ){
uint64_t us=rtc_timer_update(false);
lua_pushinteger(L, us/1000000);
return 1;
return 1;
}
// Lua: tmr.softwd( value )
static int tmr_softwd( lua_State* L ){
soft_watchdog = luaL_checkinteger(L, 1);
return 0;
return 0;
}
// Lua: tmr.create()
......
......@@ -84,7 +84,7 @@ static int l_uart_on( lua_State* L )
lua_pop(L, 1);
return luaL_error( L, "method not supported" );
}
return 0;
return 0;
}
bool uart0_echo = true;
......@@ -93,7 +93,7 @@ static int l_uart_setup( lua_State* L )
{
uint32_t id, databits, parity, stopbits, echo = 1;
uint32_t baud, res;
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( uart, id );
......@@ -119,7 +119,7 @@ static int l_uart_getconfig( lua_State* L )
{
uint32_t id, databits, parity, stopbits;
uint32_t baud;
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( uart, id );
......@@ -136,7 +136,7 @@ static int l_uart_getconfig( lua_State* L )
static int l_uart_alt( lua_State* L )
{
unsigned set;
set = luaL_checkinteger( L, 1 );
platform_uart_alt( set );
......@@ -150,7 +150,7 @@ static int l_uart_write( lua_State* L )
const char* buf;
size_t len, i;
int total = lua_gettop( L ), s;
id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( uart, id );
for( s = 2; s <= total; s ++ )
......
......@@ -37,7 +37,7 @@ typedef struct
ucg_nodemcu_t ucg;
ucg_dev_fnptr dev_cb;
ucg_dev_fnptr ext_cb;
ucg_dev_fnptr ext_cb;
// For Print() function
ucg_int_t tx, ty;
......@@ -741,7 +741,7 @@ static const LUA_REG_TYPE lucg_display_map[] =
{ LNILKEY, LNILVAL }
};
static const LUA_REG_TYPE lucg_map[] =
static const LUA_REG_TYPE lucg_map[] =
{
#undef UCG_DISPLAY_TABLE_ENTRY
#define UCG_DISPLAY_TABLE_ENTRY(binding, device, extension) { LSTRKEY( #binding ), LFUNCVAL ( l ## binding ) },
......
......@@ -75,7 +75,7 @@ static void websocketclient_onCloseCallback(ws_info *ws, int errorCode) {
luaL_error(L, "Client websocket is nil.\n");
return;
}
ws_data *data = (ws_data *) ws->reservedData;
ws_data *data = (ws_data *) ws->reservedData;
if (data->onClose != LUA_NOREF) {
lua_rawgeti(L, LUA_REGISTRYINDEX, data->onClose); // load the callback function
......@@ -119,7 +119,7 @@ static int websocket_createClient(lua_State *L) {
static int websocketclient_on(lua_State *L) {
NODE_DBG("websocketclient_on\n");
ws_info *ws = (ws_info *) luaL_checkudata(L, 1, METATABLE_WSCLIENT);
ws_info *ws = (ws_info *) luaL_checkudata(L, 1, METATABLE_WSCLIENT);
ws_data *data = (ws_data *) ws->reservedData;
......@@ -170,7 +170,7 @@ static int websocketclient_on(lua_State *L) {
static int websocketclient_connect(lua_State *L) {
NODE_DBG("websocketclient_connect is called.\n");
ws_info *ws = (ws_info *) luaL_checkudata(L, 1, METATABLE_WSCLIENT);
ws_info *ws = (ws_info *) luaL_checkudata(L, 1, METATABLE_WSCLIENT);
ws_data *data = (ws_data *) ws->reservedData;
......@@ -242,7 +242,7 @@ static int websocketclient_config(lua_State *L) {
static int websocketclient_send(lua_State *L) {
NODE_DBG("websocketclient_send is called.\n");
ws_info *ws = (ws_info *) luaL_checkudata(L, 1, METATABLE_WSCLIENT);
ws_info *ws = (ws_info *) luaL_checkudata(L, 1, METATABLE_WSCLIENT);
ws_data *data = (ws_data *) ws->reservedData;
......@@ -265,7 +265,7 @@ static int websocketclient_send(lua_State *L) {
static int websocketclient_close(lua_State *L) {
NODE_DBG("websocketclient_close.\n");
ws_info *ws = (ws_info *) luaL_checkudata(L, 1, METATABLE_WSCLIENT);
ws_info *ws = (ws_info *) luaL_checkudata(L, 1, METATABLE_WSCLIENT);
ws_close(ws);
return 0;
......@@ -274,7 +274,7 @@ static int websocketclient_close(lua_State *L) {
static int websocketclient_gc(lua_State *L) {
NODE_DBG("websocketclient_gc\n");
ws_info *ws = (ws_info *) luaL_checkudata(L, 1, METATABLE_WSCLIENT);
ws_info *ws = (ws_info *) luaL_checkudata(L, 1, METATABLE_WSCLIENT);
ws->extraHeaders = realloc_headers(ws->extraHeaders, 0);
......
......@@ -85,7 +85,7 @@ static void wifi_scan_done(void *arg, STATUS status)
return;
if(arg == NULL)
return;
lua_rawgeti(L, LUA_REGISTRYINDEX, wifi_scan_succeed);
if (status == OK)
......@@ -139,13 +139,13 @@ static int wifi_start_smart( lua_State* L )
unsigned channel;
int stack = 1;
if ( lua_isnumber(L, stack) )
{
channel = lua_tointeger(L, stack);
stack++;
}
else
}
else
{
channel = 6;
}
......@@ -198,7 +198,7 @@ static int wifi_start_smart( lua_State* L )
#endif // defined( NODE_SMART_OLDSTYLE )
return 0;
return 0;
}
// Lua: exit_smart()
......@@ -211,7 +211,7 @@ static int wifi_exit_smart( lua_State* L )
#endif // defined( NODE_SMART_OLDSTYLE )
unregister_lua_cb(L, &wifi_smart_succeed);
return 0;
return 0;
}
#endif // WIFI_SMART_ENABLE
......@@ -340,28 +340,28 @@ static int wifi_setmode( lua_State* L )
bool save_to_flash=true;
mode = luaL_checkinteger( L, 1 );
luaL_argcheck(L, mode == STATION_MODE || mode == SOFTAP_MODE || mode == STATIONAP_MODE || mode == NULL_MODE, 1, "Invalid mode");
if(!lua_isnoneornil(L, 2))
{
if(!lua_isboolean(L, 2))
if(!lua_isboolean(L, 2))
{
luaL_typerror(L, 2, lua_typename(L, LUA_TBOOLEAN));
}
save_to_flash=lua_toboolean(L, 2);
}
if(save_to_flash)
if(save_to_flash)
{
wifi_set_opmode( (uint8_t)mode);
}
else
else
{
wifi_set_opmode_current( (uint8_t)mode);
}
mode = (unsigned)wifi_get_opmode();
lua_pushinteger( L, mode );
return 1;
return 1;
}
// Lua: wifi.getmode()
......@@ -370,7 +370,7 @@ static int wifi_getmode( lua_State* L )
unsigned mode;
mode = (unsigned)wifi_get_opmode();
lua_pushinteger( L, mode );
return 1;
return 1;
}
// Lua: wifi.getdefaultmode()
......@@ -400,7 +400,7 @@ static int wifi_setphymode( lua_State* L )
if ( mode != PHY_MODE_11B && mode != PHY_MODE_11G && mode != PHY_MODE_11N )
return luaL_error( L, "wrong arg type" );
wifi_set_phy_mode( (uint8_t)mode);
mode = (unsigned)wifi_get_phy_mode();
lua_pushinteger( L, mode );
......@@ -554,7 +554,7 @@ static int wifi_getmac( lua_State* L, uint8_t mode )
wifi_get_macaddr(mode, mac);
c_sprintf(temp, MACSTR, MAC2STR(mac));
lua_pushstring( L, temp );
return 1;
return 1;
}
// Lua: mac = wifi.xx.setmac()
......@@ -577,9 +577,9 @@ static int wifi_getip( lua_State* L, uint8_t mode )
wifi_get_ip_info(mode, &pTempIp);
if(pTempIp.ip.addr==0){
lua_pushnil(L);
return 1;
}
else
return 1;
}
else
{
c_sprintf(temp, "%d.%d.%d.%d", IP2STR(&pTempIp.ip) );
lua_pushstring( L, temp );
......@@ -599,9 +599,9 @@ static int wifi_getbroadcast( lua_State* L, uint8_t mode )
wifi_get_ip_info(mode, &pTempIp);
if(pTempIp.ip.addr==0){
lua_pushnil(L);
return 1;
}
else
return 1;
}
else
{
struct ip_addr broadcast_address;
......@@ -637,17 +637,17 @@ static int wifi_setip( lua_State* L, uint8_t mode )
if (!lua_istable(L, 1))
return luaL_error( L, "wrong arg type" );
uint32_t ip = parse_key(L, "ip");
if(ip!=0)
if(ip!=0)
pTempIp.ip.addr = ip;
ip = parse_key(L, "netmask");
if(ip!=0)
if(ip!=0)
pTempIp.netmask.addr = ip;
ip = parse_key(L, "gateway");
if(mode==SOFTAP_IF || ip!=0)
pTempIp.gw.addr = ip;
if(STATION_IF == mode)
{
wifi_station_dhcpc_stop();
......@@ -660,7 +660,7 @@ static int wifi_setip( lua_State* L, uint8_t mode )
wifi_softap_dhcps_start();
}
return 1;
return 1;
}
// Lua: wifi.sta.getapinfo
......@@ -775,12 +775,12 @@ static int wifi_station_getconfig( lua_State* L, bool get_flash_cfg)
{
struct station_config sta_conf;
char temp[sizeof(sta_conf.password)+1]; //max password length + '\0'
if(get_flash_cfg)
if(get_flash_cfg)
{
wifi_station_get_config_default(&sta_conf);
}
else
else
{
wifi_station_get_config(&sta_conf);
}
......@@ -858,11 +858,11 @@ static int wifi_station_clear_config ( lua_State* L )
wifi_station_disconnect();
bool config_success;
if(save_to_flash)
if(save_to_flash)
{
config_success = wifi_station_set_config(&sta_conf);
}
else
else
{
config_success = wifi_station_set_config_current(&sta_conf);
}
......@@ -870,7 +870,7 @@ static int wifi_station_clear_config ( lua_State* L )
wifi_station_set_auto_connect((uint8)0);
lua_pushboolean(L, config_success);
return 1;
return 1;
}
// Lua: wifi.sta.config()
......@@ -896,12 +896,12 @@ static int wifi_station_config( lua_State* L )
luaL_argcheck(L, ((sl>=0 && sl<=sizeof(sta_conf.ssid)) ), 1, "ssid: length:0-32"); /* Zero-length SSID is valid as a way to clear config */
memcpy(sta_conf.ssid, ssid, sl);
}
else
else
{
return luaL_argerror( L, 1, "ssid:not string" );
}
}
else
else
{
return luaL_argerror( L, 1, "ssid required" );
}
......@@ -916,7 +916,7 @@ static int wifi_station_config( lua_State* L )
luaL_argcheck(L, ((pl>=0 && pl<=sizeof(sta_conf.password)) ), 1, "pwd: length:0-64"); /* WPA = min 8, WEP = min 5 ASCII characters for a 40-bit key */
memcpy(sta_conf.password, pwd, pl);
}
else
else
{
return luaL_argerror( L, 1, "pwd:not string" );
}
......@@ -933,7 +933,7 @@ static int wifi_station_config( lua_State* L )
ets_str2macaddr(sta_conf.bssid, macaddr);
sta_conf.bssid_set = 1;
}
else
else
{
return luaL_argerror(L, 1, "bssid:not string");
}
......@@ -947,7 +947,7 @@ static int wifi_station_config( lua_State* L )
{
auto_connect=lua_toboolean(L, -1);
}
else
else
{
return luaL_argerror(L, 1, "auto:not boolean");
}
......@@ -957,16 +957,16 @@ static int wifi_station_config( lua_State* L )
lua_getfield(L, 1, "save");
if (!lua_isnil(L, -1))
{
if (lua_isboolean(L, -1))
if (lua_isboolean(L, -1))
{
save_to_flash=lua_toboolean(L, -1);
}
else
else
{
return luaL_argerror(L, 1, "save:not boolean");
}
}
else
else
{
save_to_flash=true;
}
......@@ -1091,17 +1091,17 @@ static int wifi_station_config( lua_State* L )
wifi_station_disconnect();
bool config_success;
if(save_to_flash)
if(save_to_flash)
{
config_success = wifi_station_set_config(&sta_conf);
}
else
else
{
config_success = wifi_station_set_config_current(&sta_conf);
}
wifi_station_set_auto_connect((uint8)auto_connect);
if(auto_connect)
if(auto_connect)
{
wifi_station_connect();
}
......@@ -1122,7 +1122,7 @@ static int wifi_station_connect4lua( lua_State* L )
}
#endif
wifi_station_connect();
return 0;
return 0;
}
// Lua: wifi.sta.disconnect()
......@@ -1137,14 +1137,14 @@ static int wifi_station_disconnect4lua( lua_State* L )
}
#endif
wifi_station_disconnect();
return 0;
return 0;
}
// Lua: wifi.sta.auto(true/false)
static int wifi_station_setauto( lua_State* L )
{
unsigned a;
a = luaL_checkinteger( L, 1 );
luaL_argcheck(L, ( a == 0 || a == 1 ), 1, "0 or 1");
wifi_station_set_auto_connect(a);
......@@ -1174,7 +1174,7 @@ static int wifi_station_listap( lua_State* L )
lua_getfield(L, 1, "ssid");
if (!lua_isnil(L, -1)) /* found? */
{
{
if( lua_isstring(L, -1) ) // deal with the ssid string
{
const char *ssidstr = luaL_checklstring( L, -1, &len );
......@@ -1194,7 +1194,7 @@ static int wifi_station_listap( lua_State* L )
lua_getfield(L, 1, "bssid");
if (!lua_isnil(L, -1)) /* found? */
{
{
if( lua_isstring(L, -1) ) // deal with the ssid string
{
const char *macaddr = luaL_checklstring( L, -1, &len );
......@@ -1215,7 +1215,7 @@ static int wifi_station_listap( lua_State* L )
lua_getfield(L, 1, "channel");
if (!lua_isnil(L, -1)) /* found? */
{
{
if( lua_isnumber(L, -1) ) // deal with the ssid string
{
channel = luaL_checknumber( L, -1);
......@@ -1232,7 +1232,7 @@ static int wifi_station_listap( lua_State* L )
lua_getfield(L, 1, "show_hidden");
if (!lua_isnil(L, -1)) /* found? */
{
{
if( lua_isnumber(L, -1) ) // deal with the ssid string
{
show_hidden = luaL_checknumber( L, -1);
......@@ -1370,7 +1370,7 @@ static int wifi_station_status( lua_State* L )
{
uint8_t status = wifi_station_get_connect_status();
lua_pushinteger( L, status );
return 1;
return 1;
}
// Lua: wifi.sta.getrssi()
......@@ -1437,11 +1437,11 @@ static int wifi_ap_getconfig( lua_State* L, bool get_flash_cfg)
{
struct softap_config config;
char temp[sizeof(config.password)+1]; //max password length + '\0'
if (get_flash_cfg)
if (get_flash_cfg)
{
wifi_softap_get_config_default(&config);
}
else
else
{
wifi_softap_get_config(&config);
}
......@@ -1479,7 +1479,7 @@ static int wifi_ap_getconfig( lua_State* L, bool get_flash_cfg)
memcpy(temp, config.ssid, sizeof(config.ssid));
lua_pushstring(L, temp);
if(config.authmode == AUTH_OPEN)
if(config.authmode == AUTH_OPEN)
{
lua_pushnil(L);
}
......@@ -1524,7 +1524,7 @@ static int wifi_ap_config( lua_State* L )
lua_getfield(L, 1, "ssid");
if (!lua_isnil(L, -1)) /* found? */
{
{
if( lua_isstring(L, -1) ) // deal with the ssid string
{
const char *ssid = luaL_checklstring( L, -1, &sl );
......@@ -1532,13 +1532,13 @@ static int wifi_ap_config( lua_State* L )
memcpy(config.ssid, ssid, sl);
config.ssid_len = sl;
config.ssid_hidden = 0;
}
else
}
else
{
return luaL_argerror( L, 1, "ssid: not string" );
}
}
else
else
{
return luaL_argerror( L, 1, "ssid: required" );
}
......@@ -1547,7 +1547,7 @@ static int wifi_ap_config( lua_State* L )
lua_getfield(L, 1, "pwd");
if (!lua_isnil(L, -1)) /* found? */
{
{
if( lua_isstring(L, -1) ) // deal with the password string
{
const char *pwd = luaL_checklstring( L, -1, &pl );
......@@ -1575,7 +1575,7 @@ static int wifi_ap_config( lua_State* L )
luaL_argcheck(L, (lint >= 0 && lint < AUTH_MAX), 1, "auth: Range:0-4");
config.authmode = (uint8_t)luaL_checkinteger(L, -1);
}
else
else
{
return luaL_argerror(L, 1, "auth: not number");
}
......@@ -1593,7 +1593,7 @@ static int wifi_ap_config( lua_State* L )
luaL_argcheck(L, (lint >= 1 && lint <= 13), 1, "channel: Range:1-13");
config.channel = (uint8_t)lint;
}
else
else
{
luaL_argerror(L, 1, "channel: not number");
}
......@@ -1624,7 +1624,7 @@ static int wifi_ap_config( lua_State* L )
luaL_argcheck(L, (lint == 0 || lint==1), 1, "hidden: 0 or 1");
config.ssid_hidden = (uint8_t)lint;
}
else
else
{
return luaL_argerror(L, 1, "hidden: not boolean");
}
......@@ -1646,7 +1646,7 @@ static int wifi_ap_config( lua_State* L )
config.max_connection = (uint8_t)lint;
}
else
else
{
return luaL_argerror(L, 1, "max: not number");
}
......@@ -1667,7 +1667,7 @@ static int wifi_ap_config( lua_State* L )
luaL_argcheck(L, (lint >= 100 && lint <= 60000), 1, "beacon: 100-60000");
config.beacon_interval = (uint16_t)lint;
}
else
else
{
return luaL_argerror(L, 1, "beacon: not number");
}
......@@ -1686,7 +1686,7 @@ static int wifi_ap_config( lua_State* L )
{
save_to_flash=lua_toboolean(L, -1);
}
else
else
{
return luaL_argerror(L, 1, "save: not boolean");
}
......@@ -1770,11 +1770,11 @@ static int wifi_ap_config( lua_State* L )
#endif
bool config_success;
if(save_to_flash)
if(save_to_flash)
{
config_success = wifi_softap_set_config(&config);
}
else
else
{
config_success = wifi_softap_set_config_current(&config);
}
......@@ -1926,7 +1926,7 @@ static const LUA_REG_TYPE wifi_map[] = {
{ LSTRKEY( "suspend" ), LFUNCVAL( wifi_suspend ) },
{ LSTRKEY( "resume" ), LFUNCVAL( wifi_resume ) },
{ LSTRKEY( "nullmodesleep" ), LFUNCVAL( wifi_null_mode_auto_sleep ) },
#ifdef WIFI_SMART_ENABLE
#ifdef WIFI_SMART_ENABLE
{ LSTRKEY( "startsmart" ), LFUNCVAL( wifi_start_smart ) },
{ LSTRKEY( "stopsmart" ), LFUNCVAL( wifi_exit_smart ) },
#endif
......
......@@ -304,7 +304,7 @@ static void wifi_rx_cb(uint8 *buf, uint16 len) {
}
}
static void monitor_task(os_param_t param, uint8_t prio)
static void monitor_task(os_param_t param, uint8_t prio)
{
packet_t *input = (packet_t *) param;
(void) prio;
......@@ -377,7 +377,7 @@ static void push_hex_string(lua_State *L, const uint8 *buf, int len, char *sep)
hex[2] = 0;
luaL_addstring(&b, hex);
}
luaL_pushresult(&b);
}
......@@ -418,7 +418,7 @@ static int comparator(const void *typekey, const void *obj) {
static bool push_field_value_string(lua_State *L, const uint8 *pkt,
const uint8 *packet_end, const char *field) {
const struct RxControl *rxc = (struct RxControl *) pkt;
const struct RxControl *rxc = (struct RxControl *) pkt;
const management_request_t *mgt = (management_request_t *) (rxc + 1);
typekey_t tk;
......@@ -526,7 +526,7 @@ static bool push_field_value_string(lua_State *L, const uint8 *pkt,
return false;
}
static bool push_field_value_int(lua_State *L, management_request_t *mgt,
static bool push_field_value_int(lua_State *L, management_request_t *mgt,
const uint8 *packet_end, int field) {
int varstart = variable_start[mgt->framectrl.Subtype];
......@@ -547,7 +547,7 @@ static bool push_field_value_int(lua_State *L, management_request_t *mgt,
static int packet_map_lookup(lua_State *L) {
packet_t *packet = luaL_checkudata(L, 1, "wifi.packet");
struct RxControl *rxc = (struct RxControl *) packet->buf;
struct RxControl *rxc = (struct RxControl *) packet->buf;
management_request_t *mgt = (management_request_t *) (rxc + 1);
const uint8 *packet_end = packet->buf + packet->len;
......@@ -630,7 +630,7 @@ static int packet_subhex(lua_State *L, int buf_offset, int buf_length) {
hex[2] = 0;
luaL_addstring(&b, hex);
}
luaL_pushresult(&b);
} else {
lua_pushliteral(L, "");
......
......@@ -65,7 +65,7 @@ static void enable_pin_mux(int pin) {
/* Lua: ws2801.init(pin_clk, pin_data)
* Sets up the GPIO pins
*
*
* ws2801.init(0, 2) uses GPIO0 as clock and GPIO2 as data.
* This is the default behavior.
*/
......
......@@ -33,14 +33,14 @@ static int16_t besttwoavg( int16_t x , int16_t y , int16_t z ) {
if ( da <= db && da <= dc ) reta = (x + y) >> 1;
else if ( db <= da && db <= dc ) reta = (x + z) >> 1;
else reta = (y + z) >> 1;
else reta = (y + z) >> 1;
return reta;
}
// Checks if the irq_pin is down
static int isTouching() {
return (platform_gpio_read(_irq_pin) == 0);
static int isTouching() {
return (platform_gpio_read(_irq_pin) == 0);
}
// transfer 16 bits from the touch display - returns the recived uint16_t
......@@ -81,7 +81,7 @@ static void getRaw(uint16_t *vi, uint16_t *vj) {
platform_spi_send_recv(1, 8 , 0); // Maintain 16-clocks/conversion; _readLoop always ends after issuing a control int
platform_spi_send_recv(1, 8 , CTRL_HI_Y | CTRL_LO_SER);
transfer16(0); // Flush last read, just to be sure
platform_gpio_write(_cs_pin, PLATFORM_GPIO_HIGH);
// Clear interrupt status
......@@ -127,14 +127,14 @@ static int xpt2046_init( lua_State* L ) {
_width = luaL_checkinteger( L, 4 );
// set pins correct
platform_gpio_mode(_cs_pin, PLATFORM_GPIO_OUTPUT, PLATFORM_GPIO_FLOAT );
setCalibration(
/*vi1=*/((int32_t)CAL_MARGIN) * ADC_MAX / _width,
/*vj1=*/((int32_t)CAL_MARGIN) * ADC_MAX / _height,
/*vi2=*/((int32_t)_width - CAL_MARGIN) * ADC_MAX / _width,
/*vj2=*/((int32_t)_height - CAL_MARGIN) * ADC_MAX / _height
);
// assume spi was inited before with a clockDiv of >=16
// as higher spi clock speed produced inaccurate results
......@@ -146,7 +146,7 @@ static int xpt2046_init( lua_State* L ) {
platform_spi_send_recv(1, 8, CTRL_HI_Y | CTRL_LO_SER);
transfer16(0); // Flush, just to be sure
platform_gpio_write(_cs_pin, PLATFORM_GPIO_HIGH);
platform_gpio_write(_cs_pin, PLATFORM_GPIO_HIGH);
return 0;
}
......
......@@ -24,7 +24,7 @@ STD_CFLAGS=-std=gnu11 -Wimplicit
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#DEFINES +=
#DEFINES +=
#############################################################
# Recursion Magic - Don't touch this!!
......
......@@ -440,7 +440,7 @@ mqtt_message_t* mqtt_msg_subscribe_fini(mqtt_connection_t* connection)
mqtt_message_t* mqtt_msg_subscribe(mqtt_connection_t* connection, const char* topic, int qos, uint16_t* message_id)
{
mqtt_message_t* result;
result = mqtt_msg_subscribe_init(connection, message_id);
if (result->length != 0) {
result = mqtt_msg_subscribe_topic(connection, topic, qos);
......@@ -476,7 +476,7 @@ mqtt_message_t* mqtt_msg_unsubscribe_fini(mqtt_connection_t* connection)
mqtt_message_t* mqtt_msg_unsubscribe(mqtt_connection_t* connection, const char* topic, uint16_t* message_id)
{
mqtt_message_t* result;
result = mqtt_msg_unsubscribe_init(connection, message_id);
if (result->length != 0) {
result = mqtt_msg_unsubscribe_topic(connection, topic);
......
/*
/*
* File: mqtt_msg.h
* Author: Minh Tuan
*
......
......@@ -16,7 +16,7 @@ msg_queue_t *msg_enqueue(msg_queue_t **head, mqtt_message_t *msg, uint16_t msg_i
NODE_DBG("not enough memory\n");
return NULL;
}
node->msg.data = (uint8_t *)c_zalloc(msg->length);
if(!node->msg.data){
NODE_DBG("not enough memory\n");
......
......@@ -22,7 +22,7 @@ endif
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#DEFINES +=
#DEFINES +=
#############################################################
# Recursion Magic - Don't touch this!!
......
......@@ -264,7 +264,7 @@ mdns_compare_name(unsigned char *query, unsigned char *response, unsigned char *
return 0;
}
static int
static int
mdns_namelen(u8_t *p, unsigned int maxlen) {
u8_t *orig = p;
......@@ -654,7 +654,7 @@ mdns_send_service(struct nodemcu_mdns_info *info, u16_t id, struct ip_addr *dst_
*query++ = '\0';
// increment by strlen(service_name) + 1 + 7 + sizeof_dns_answer + sizeof_mdns_service
*query++ = 0xc0 + (hostname_offset >> 8);
*query++ = hostname_offset & 0xff;
......@@ -667,9 +667,9 @@ mdns_send_service(struct nodemcu_mdns_info *info, u16_t id, struct ip_addr *dst_
/* resize the query */
query = query + SIZEOF_DNS_ANSWER;
// increment by strlen(service_name) + 1 + 7 + sizeof_dns_answer
// increment by strlen(service_name) + 1 + 7 + sizeof_dns_answer
/* fill the payload of the mDNS message */
/* set the local IP address */
......@@ -770,7 +770,7 @@ static char *append_nsec_record(char *query, u32_t actual_rr, int max_ttl) {
* but the name exists
*/
static void
static void
mdns_send_no_rr(struct mdns_hdr *req, const char *name, u32_t actual_rr, struct ip_addr *dst_addr, u16_t dst_port) {
int max_ttl = dst_addr ? 10 : 7200;
struct pbuf *p;
......@@ -786,7 +786,7 @@ mdns_send_no_rr(struct mdns_hdr *req, const char *name, u32_t actual_rr, struct
hdr->numextrarr = htons(1);
char *query = (char*) hdr + SIZEOF_DNS_HDR;
char *query_end = (char *) p->payload + p->tot_len;
// Now copy over the dns name
// Now copy over the dns name
int len = strlen(name);
if (query_end - query >= len + SIZEOF_DNS_QUERY + 15) {
......@@ -806,7 +806,7 @@ mdns_send_no_rr(struct mdns_hdr *req, const char *name, u32_t actual_rr, struct
* This sends a single A record and the NSEC record as additional
*/
static void
static void
mdns_send_a_rr(struct mdns_hdr *req, const char *name, struct ip_addr *dst_addr, u16_t dst_port) {
int max_ttl = dst_addr ? 10 : 7200;
struct pbuf *p;
......@@ -823,7 +823,7 @@ mdns_send_a_rr(struct mdns_hdr *req, const char *name, struct ip_addr *dst_addr,
hdr->numextrarr = htons(1);
char *query = (char*) hdr + SIZEOF_DNS_HDR;
char *query_end = (char *) p->payload + p->tot_len;
// Now copy over the dns name
// Now copy over the dns name
int len = strlen(name) + 1;
if (query_end - query >= len + SIZEOF_DNS_QUERY + 4 + 2 + 4 + 15) {
......@@ -1060,7 +1060,7 @@ mdns_dup_info(const struct nodemcu_mdns_info *info) {
/**
* Initialize the resolver: set up the UDP pcb and configure the default server
* (NEW IP).
*
*
* returns TRUE if it worked, FALSE if it failed.
*/
bool ICACHE_FLASH_ATTR
......
......@@ -24,7 +24,7 @@ STD_CFLAGS=-std=gnu11 -Wimplicit
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#DEFINES +=
#DEFINES +=
#############################################################
# Recursion Magic - Don't touch this!!
......
......@@ -24,7 +24,7 @@ STD_CFLAGS=-std=gnu11 -Wimplicit
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#DEFINES +=
#DEFINES +=
#############################################################
# Recursion Magic - Don't touch this!!
......
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