Skip to content
This repository has been archived by the owner on Dec 20, 2018. It is now read-only.

Commit

Permalink
New SenseBox WiFi firmware (using platform.io) started
Browse files Browse the repository at this point in the history
  • Loading branch information
JochenLutz committed Jan 30, 2017
1 parent 5b96462 commit b47a263
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 0 deletions.
2 changes: 2 additions & 0 deletions WLanSenseNode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.pioenvs
.piolibdeps
65 changes: 65 additions & 0 deletions WLanSenseNode/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < http://docs.platformio.org/page/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < http://docs.platformio.org/page/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < http://docs.platformio.org/page/userguide/cmd_ci.html >
#
#
# Please choice one of the following templates (proposed below) and uncomment
# it (remove "# " before each line) or use own configuration according to the
# Travis CI documentation (see above).
#


#
# Template #1: General project. Test it using existing `platformio.ini`.
#

# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# install:
# - pip install -U platformio
#
# script:
# - platformio run


#
# Template #2: The project is intended to by used as a library with examples
#

# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# env:
# - PLATFORMIO_CI_SRC=path/to/test/file.c
# - PLATFORMIO_CI_SRC=examples/file.ino
# - PLATFORMIO_CI_SRC=path/to/test/directory
#
# install:
# - pip install -U platformio
#
# script:
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
36 changes: 36 additions & 0 deletions WLanSenseNode/lib/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

This directory is intended for the project specific (private) libraries.
PlatformIO will compile them to static libraries and link to executable file.

The source code of each library should be placed in separate directory, like
"lib/private_lib/[here are source files]".

For example, see how can be organized `Foo` and `Bar` libraries:

|--lib
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |- readme.txt --> THIS FILE
|- platformio.ini
|--src
|- main.c

Then in `src/main.c` you should use:

#include <Foo.h>
#include <Bar.h>

// rest H/C/CPP code

PlatformIO will find your libraries automatically, configure preprocessor's
include paths and build them.

More information about PlatformIO Library Dependency Finder
- http://docs.platformio.org/page/librarymanager/ldf.html
14 changes: 14 additions & 0 deletions WLanSenseNode/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html

[env:uno]
platform = atmelavr
board = uno
framework = arduino
46 changes: 46 additions & 0 deletions WLanSenseNode/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <Arduino.h>
#include <SPI.h> //include explicitly, dependency management does not handle this
#include <WiFi101.h>

//Custom WiFi Parameters (never commit to Git!)
char ssid[] = "..."; // your network SSID (name)
char pass[] = "..."; // your network password

void wifiConnect() {
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println(F("WiFi shield not present. Stopping."));
while (true); //stop!
}

int status = WL_IDLE_STATUS;
int maxTries = 10;
while ((status != WL_CONNECTED) && (maxTries-- > 0)) {
Serial.print(F("Attempting to connect to WPA SSID: ")); Serial.println(ssid);
status = WiFi.begin(ssid, pass);

delay(6000);
}

if (status != WL_CONNECTED) {
Serial.print(F("Can't connect to SSID ")); Serial.print(ssid); Serial.println(F(". Stopping."));
while (true); //stop!
}
}

void readSensors() {
}

void sendData() {
}

void setup() {
Serial.begin(115200);

delay(2000);
Serial.print("Starting up ...");

wifiConnect();
}

void loop() {
}

0 comments on commit b47a263

Please sign in to comment.