From dd00e31027adaa32c17ebe972956d917d838a2d2 Mon Sep 17 00:00:00 2001 From: dnc40085 Date: Fri, 22 May 2015 18:01:05 -0700 Subject: [PATCH] Added fix to adc.readvdd33() to prevent crashing in station mode while connected --- app/modules/adc.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/modules/adc.c b/app/modules/adc.c index 72e1e6a0..799d7e72 100644 --- a/app/modules/adc.c +++ b/app/modules/adc.c @@ -24,11 +24,23 @@ static int adc_sample( lua_State* L ) static int adc_readvdd33( lua_State* L ) { uint32_t vdd33 = 0; - - os_intr_lock(); - vdd33 = readvdd33(); - os_intr_unlock(); + if(STATION_MODE == wifi_get_opmode()) + { + // Bug fix + if (wifi_station_get_connect_status()!=0) + { + return luaL_error( L, "Can't read vdd33 while station is connected" ); + } + else + { + vdd33 = readvdd33(); + } + } + else + { + vdd33 = readvdd33(); + } lua_pushinteger(L, vdd33); return 1; }