whitecatboard / Lua-RTOS-ESP32

Lua RTOS for ESP32
Other
1.2k stars 221 forks source link

Printing pairs(lora) causes infinite loop #35

Closed jcwren closed 7 years ago

jcwren commented 7 years ago

for n in pairs(lora) do print(n) end causes an infinite loop of printing 'setAppKey', 'setNwksKey', 'setAppsKey'

There is a duplicate 'setAppKey' entry in the lora_map table in Lua-RTOS-ESP32/components/lua_rtos/Lua/modules/lora.c. Removing this appears to fix the issue.

static const LUA_REG_TYPE lora_map[] = {
#if CONFIG_LUA_RTOS_LORA_DEVICE_TYPE_NODE
    { LSTRKEY( "setup" ),        LFUNCVAL( llora_setup ) }, 
    { LSTRKEY( "setDevAddr" ),   LFUNCVAL( llora_set_setDevAddr ) }, 
    { LSTRKEY( "setDevEui" ),    LFUNCVAL( llora_set_DevEui ) }, 
    { LSTRKEY( "setAppEui" ),    LFUNCVAL( llora_set_AppEui ) }, 
    { LSTRKEY( "setAppKey" ),    LFUNCVAL( llora_set_AppKey ) }, 
    { LSTRKEY( "setNwksKey" ),   LFUNCVAL( llora_set_NwkSKey ) }, 
    { LSTRKEY( "setAppsKey" ),   LFUNCVAL( llora_set_AppSKey ) }, 
    { LSTRKEY( "setAppKey" ),    LFUNCVAL( llora_set_AppKey ) }, 
    { LSTRKEY( "setDr" ),        LFUNCVAL( llora_set_Dr ) }, 
    { LSTRKEY( "setAdr" ),       LFUNCVAL( llora_set_Adr ) }, 
    { LSTRKEY( "setReTx" ),      LFUNCVAL( llora_set_ReTx ) },
    { LSTRKEY( "getDevAddr" ),   LFUNCVAL( llora_get_DevAddr ) }, 
    { LSTRKEY( "getDevEui" ),    LFUNCVAL( llora_get_DevEui ) }, 
    { LSTRKEY( "getAppEui" ),    LFUNCVAL( llora_get_AppEui ) }, 
    { LSTRKEY( "getDr" ),        LFUNCVAL( llora_get_Dr ) }, 
    { LSTRKEY( "getAdr" ),       LFUNCVAL( llora_get_Adr ) }, 
    { LSTRKEY( "getReTx" ),      LFUNCVAL( llora_get_ReTx ) },
    { LSTRKEY( "join" ),         LFUNCVAL( llora_join ) }, 
    { LSTRKEY( "tx" ),           LFUNCVAL( llora_tx ) },
    { LSTRKEY( "whenReceived" ), LFUNCVAL( llora_rx ) },

    // Constant definitions
    { LSTRKEY( "BAND868" ),      LINTVAL( 868 ) },
    { LSTRKEY( "BAND433" ),      LINTVAL( 433 ) },
    { LSTRKEY( "BAND915" ),      LINTVAL( 915 ) },
#endif

#if CONFIG_LUA_RTOS_LORA_DEVICE_TYPE_GATEWAY
    { LSTRKEY( "start" ),        LFUNCVAL( llora_gw_start ) },
#endif

    // Error definitions
    {LSTRKEY("error"),           LROVAL( lora_error_map )},

    {LNILKEY, LNILVAL}
};
jolivepetrus commented 7 years ago

Solved in https://github.com/whitecatboard/Lua-RTOS-ESP32/commit/0e7f394a7d447ca01925f163c9c63643f441049b. Thanks for the pull request.