Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spark_disable_wlan.h and spark_disable_cloud.h for complete user control
- Loading branch information
Showing
3 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
****************************************************************************** | ||
* @file spark_disable_cloud.h | ||
* @author Satish Nair | ||
* @version V1.0.0 | ||
* @date 6-March-2014 | ||
* @brief Header to be included to prevent the core from connecting to cloud | ||
****************************************************************************** | ||
Copyright (c) 2013-14 Spark Labs, Inc. All rights reserved. | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation, either | ||
version 3 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
****************************************************************************** | ||
*/ | ||
|
||
/* Define to prevent recursive inclusion -------------------------------------*/ | ||
#ifndef __SPARK_DISABLE_CLOUD_H | ||
#define __SPARK_DISABLE_CLOUD_H | ||
|
||
class SparkDisableCloud { | ||
public: | ||
SparkDisableCloud() | ||
{ | ||
SPARK_CLOUD_CONNECT = 0; | ||
} | ||
}; | ||
|
||
SparkDisableCloud sparkDisableCloud; | ||
|
||
#endif /* __SPARK_DISABLE_CLOUD_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
****************************************************************************** | ||
* @file spark_disable_wlan.h | ||
* @author Satish Nair | ||
* @version V1.0.0 | ||
* @date 6-March-2014 | ||
* @brief Header to be included to prevent the core from starting the wlan | ||
****************************************************************************** | ||
Copyright (c) 2013-14 Spark Labs, Inc. All rights reserved. | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation, either | ||
version 3 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
****************************************************************************** | ||
*/ | ||
|
||
/* Define to prevent recursive inclusion -------------------------------------*/ | ||
#ifndef __SPARK_DISABLE_WLAN_H | ||
#define __SPARK_DISABLE_WLAN_H | ||
|
||
class SparkDisableWlan { | ||
public: | ||
SparkDisableWlan() | ||
{ | ||
SPARK_WLAN_START = 0; | ||
} | ||
}; | ||
|
||
SparkDisableWlan sparkDisableWlan; | ||
|
||
#endif /* __SPARK_DISABLE_WLAN_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0a08406
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include the following files in application.cpp or WebIDE to disable Wlan / Cloud and execute the setup() and loop()
include "spark_disable_wlan.h"
include "spark_disable_cloud.h"
0a08406
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Satish,
try 1 : #include "spark_disable_cloud.h"
try 2: #include "spark_disable_wlan.h"
** I see that you've deleted two lines of code. That function was incredibly useful if I wanted to run code right from the start and at the same time have a connection to the router and the cloud. I tested it right before you made this commit.
** To build the application.cpp locally, I'm having to do "make clean" almost every time I change code or use different ".h" files. I never had to do that till date.
0a08406
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hope you have pulled the latest commits including the one made after this one.
Now the following should be the behaviour with only #include "spark_disable_cloud.h" in application.cpp
you should be able to start the wlan and connect to Wifi router(assuming you have the right credentials) else without any profile, it will automatically enter smart config mode blinking blue and thus blocking your application. The RGB should flash GREEN(confusing?). If you run Spark.connect() within your application code, you should be able to connect to cloud. Without a Wifi connection, it should flash GREEN.
Now with #include "spark_disable_wlan.h" i.e. WLAN disabled, you should notice only fading WHITE and your application code should run at full speed.
I am in the process of writing up a Spark.wlan(bool) function which should help the user to start/stop wlan from application code.
The reason you see everything building up is because of the many changes done to dependency files in the past commits.
0a08406
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My apologies, it seems like I haven't got the latest commit. I'll rerun the tests with the latest commits and I'll check if I get the expected behavior you just mentioned. Thanks :)
0a08406
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In between I am going to push some change where successfully connected to WLAN will be displayed as SOLID GREEN. currently it FLASHES GREEN on successful AP connection.
0a08406
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing it should breathe green to let you know it successfully connected and still running. In this mode you should be able to talk to your Core over WLAN via UDP and TCP.
0a08406
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@technobly , nice suggestion!
0a08406
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@satishgn I've pulled the most recent commits - just double checked to be sure. I'm just using
#include "spark_disable_cloud.h
to turn off cloud functionality but keep the wireless network up. You said that the flashing green light is expected, but my application isn't starting. I can remove the#include "spark_disable_cloud.h
and flash the core, and everything works fine (other than that it connects to the cloud, which I'd like to remove). Do I need to anything other than this include?0a08406
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbeasley, can you tell me what specifically you are trying to do via application.cpp, so I can try this out on my end to debug what's causing this issue?
0a08406
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbeasley, can you try this code and confirm D7 blinking?
0a08406
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@satishgn The above code works great, though it just guarantees that the loop is running, but not the WiFi connection. Though, that's good to see it gets to the loop.
To answer your previous question, I'm collecting and transmitting analog sensor data to a NodeJS TCP server. The code on the Core consists of:
0a08406
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a
#include
to accomplish this strikes me as clunky. Can we make this a#define
or#undef
macro instead? Best would be a one-line C++ syntax command rather than a preprocessor directive.0a08406
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@towynlin , can we pass compiler macros via WebIDE through a pull down option? and if this could be done that would be conditional compilation. Users cannot change the WiFi/Cloud state at runtime using WiFi.xyz() or Spark.xyz().
@mbeasley, we pushed some commits today which should allow you to control both WiFi and cloud at runtime. In case if you disable wlan at startup using the include, you will need to check the WiFi.status() in your application code before starting a TCP server etc. Start the server once in the loop() instead of setup() only if (WiFi.status==WIFI_ON)
0a08406
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@satishgn @towynlin @technobly
With both compile time and run time control there are some cool things but possibility of confusion and customer support issues.
What is the strategy?
I can see an incredible gains on free RAM, FLASH in the CT off/off listed below
What should the lib granularity be? common-lib build wifi-lib, and common-lib
What ever we choose I think it is best to lets keep #ifdefs to a minimum (use libs, stubs or macros)
wifi | spark
ct=off off (maximize free RAM, FLASH) do we stub out WIFI api with error returns or make it an undefined CT error
ct=on off do we stub out Spark, WIFI apis or CT error?
ct=on on have real APIs
Thouhgts?