Skip to content

Commit

Permalink
Merge pull request #1337 from spark/fix/listen_mode_flags
Browse files Browse the repository at this point in the history
Listening mode fixes 1️⃣ 3️⃣ 3️⃣ 7️⃣
  • Loading branch information
technobly authored May 25, 2017
2 parents 6608495 + e8d38cc commit f1eee9d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 25 deletions.
4 changes: 0 additions & 4 deletions hal/inc/wlan_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ extern uint32_t lastEvent;
#define SET_LAST_EVENT(x) do {lastEvent = (x);} while(0)
#define GET_LAST_EVENT(x) do { x = lastEvent; lastEvent = 0;} while(0)
#define DUMP_STATE() do { \
DEBUG("\r\nWLAN_MANUAL_CONNECT=%d\r\nWLAN_DELETE_PROFILES=%d\r\nWLAN_SMART_CONFIG_START=%d\r\nWLAN_SMART_CONFIG_STOP=%d", \
WLAN_MANUAL_CONNECT,WLAN_DELETE_PROFILES,WLAN_SMART_CONFIG_START, WLAN_SMART_CONFIG_STOP); \
DEBUG("\r\nWLAN_SMART_CONFIG_FINISHED=%d\r\nWLAN_SERIAL_CONFIG_DONE=%d\r\nWLAN_CONNECTED=%d\r\nWLAN_DHCP=%d\r\nWLAN_CAN_SHUTDOWN=%d", \
WLAN_SMART_CONFIG_FINISHED,WLAN_SERIAL_CONFIG_DONE,WLAN_CONNECTED,WLAN_DHCP,WLAN_CAN_SHUTDOWN); \
DEBUG("\r\nSPARK_WLAN_RESET=%d\r\nSPARK_WLAN_SLEEP=%d\r\nSPARK_WLAN_STARTED=%d\r\nSPARK_CLOUD_CONNECT=%d", \
SPARK_WLAN_RESET,SPARK_WLAN_SLEEP,SPARK_WLAN_STARTED,SPARK_CLOUD_CONNECT); \
DEBUG("\r\nSPARK_CLOUD_SOCKETED=%d\r\nSPARK_CLOUD_CONNECTED=%d\r\nSPARK_FLASH_UPDATE=%d\r\n", \
Expand Down
11 changes: 0 additions & 11 deletions system/inc/system_network_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ enum eWanTimings
DISCONNECT_TO_RECONNECT = S2M(2),
};

extern volatile uint8_t WLAN_CONNECTED;
extern volatile uint8_t WLAN_DISCONNECT;
extern volatile uint8_t WLAN_DHCP;
extern volatile uint8_t WLAN_MANUAL_CONNECT;
extern volatile uint8_t WLAN_DELETE_PROFILES;
extern volatile uint8_t WLAN_SMART_CONFIG_START;
extern volatile uint8_t WLAN_SMART_CONFIG_FINISHED;
extern volatile uint8_t WLAN_SERIAL_CONFIG_DONE;
extern volatile uint8_t WLAN_SMART_CONFIG_STOP;
extern volatile uint8_t WLAN_CAN_SHUTDOWN;

extern volatile uint8_t SPARK_WLAN_RESET;
extern volatile uint8_t SPARK_WLAN_SLEEP;
extern volatile uint8_t SPARK_WLAN_STARTED;
Expand Down
2 changes: 0 additions & 2 deletions system/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,6 @@ extern "C" void HAL_SysTick_Handler(void)
// there's a race condition here - the HAL_notify_button_state function should
// be thread safe, but currently isn't.
HAL_Notify_Button_State(0, false);
// LOG(INFO,"BUTTON PRESSED FOR LISTENING");
// TODO: this code is called repeatedly every 1ms while the button is held (from 3-8s) and should only be called once
network.listen();
HAL_Notify_Button_State(0, true);
}
Expand Down
12 changes: 4 additions & 8 deletions system/src/system_network_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ class ManagedNetworkInterface : public NetworkInterface
volatile uint8_t WLAN_DELETE_PROFILES;
volatile uint8_t WLAN_SMART_CONFIG_START; // Set to 'true' when listening mode is pending
volatile uint8_t WLAN_SMART_CONFIG_ACTIVE;
volatile uint8_t WLAN_SMART_CONFIG_STOP;
volatile uint8_t WLAN_SMART_CONFIG_FINISHED;
volatile uint8_t WLAN_CONNECTED;
volatile uint8_t WLAN_CONNECTING;
Expand Down Expand Up @@ -219,7 +218,6 @@ class ManagedNetworkInterface : public NetworkInterface
LOG_NETWORK_STATE();
WLAN_SMART_CONFIG_ACTIVE = 1;
WLAN_SMART_CONFIG_FINISHED = 0;
WLAN_SMART_CONFIG_STOP = 0;
WLAN_SERIAL_CONFIG_DONE = 0;
bool wlanStarted = SPARK_WLAN_STARTED;

Expand All @@ -241,7 +239,7 @@ class ManagedNetworkInterface : public NetworkInterface
system_notify_event(wifi_listen_begin, 0);

/* Wait for SmartConfig/SerialConfig to finish */
while (network_listening(0, 0, NULL))
while (WLAN_SMART_CONFIG_ACTIVE && !WLAN_SMART_CONFIG_FINISHED && !WLAN_SERIAL_CONFIG_DONE)
{
if (WLAN_DELETE_PROFILES)
{
Expand Down Expand Up @@ -374,7 +372,7 @@ class ManagedNetworkInterface : public NetworkInterface

bool listening() override
{
return (WLAN_SMART_CONFIG_ACTIVE && !(WLAN_SMART_CONFIG_FINISHED || WLAN_SERIAL_CONFIG_DONE));
return (WLAN_SMART_CONFIG_START || WLAN_SMART_CONFIG_ACTIVE);
}

void set_listen_timeout(uint16_t timeout) override {
Expand Down Expand Up @@ -508,7 +506,6 @@ class ManagedNetworkInterface : public NetworkInterface
{
LOG_NETWORK_STATE();
WLAN_SMART_CONFIG_FINISHED = 1;
WLAN_SMART_CONFIG_STOP = 1;
}

void notify_connected()
Expand Down Expand Up @@ -613,10 +610,10 @@ class ManagedNetworkInterface : public NetworkInterface
// 2. CC3000 established AP connection
// 3. DHCP IP is configured
// then send mDNS packet to stop external SmartConfig application
if ((WLAN_SMART_CONFIG_STOP == 1) && (WLAN_CONNECTED == 1))
if ((WLAN_SMART_CONFIG_FINISHED == 1) && (WLAN_CONNECTED == 1))
{
on_setup_cleanup();
WLAN_SMART_CONFIG_STOP = 0;
WLAN_SMART_CONFIG_FINISHED = 0;
}
}
};
Expand Down Expand Up @@ -687,7 +684,6 @@ inline void NetworkStateLogger::dump() const {
NETWORK_STATE_PRINTF("WLAN_DELETE_PROFILES: %d\r\n", (int)nif_.WLAN_DELETE_PROFILES);
NETWORK_STATE_PRINTF("WLAN_SMART_CONFIG_START: %d\r\n", (int)nif_.WLAN_SMART_CONFIG_START);
NETWORK_STATE_PRINTF("WLAN_SMART_CONFIG_ACTIVE: %d\r\n", (int)nif_.WLAN_SMART_CONFIG_ACTIVE);
NETWORK_STATE_PRINTF("WLAN_SMART_CONFIG_STOP: %d\r\n", (int)nif_.WLAN_SMART_CONFIG_STOP);
NETWORK_STATE_PRINTF("WLAN_SMART_CONFIG_FINISHED: %d\r\n", (int)nif_.WLAN_SMART_CONFIG_FINISHED);
NETWORK_STATE_PRINTF("WLAN_CONNECTED: %d\r\n", (int)nif_.WLAN_CONNECTED);
NETWORK_STATE_PRINTF("WLAN_CONNECTING: %d\r\n", (int)nif_.WLAN_CONNECTING);
Expand Down

0 comments on commit f1eee9d

Please sign in to comment.