Skip to content

Instantly share code, notes, and snippets.

@pocha
Last active February 21, 2017 07:36
Show Gist options
  • Save pocha/b3f8e47639cbd13e2c88e4648ad05cdf to your computer and use it in GitHub Desktop.
Save pocha/b3f8e47639cbd13e2c88e4648ad05cdf to your computer and use it in GitHub Desktop.

Hybrid App for WiFi connectivity & Data accounting

Hybrid - as this app needs porting to other platforms. Basically - the UI part needs to be in hybrid (phonegap/ionic) - the core parts anyway need to be done in native (as phonegap plugins)

Work scope - PoC app preferably working on an Android phone

This app is going to be open source & (mostly) will be used for a free WiFi Gujrat Govt project . Details at https://gil.gujarat.gov.in/tendercms/TenderDocs/2017123145318973.pdf

If interested to work on this project - drop me a word at pocha.sharma at gmail / 9 5 3 8 3 8 4 5 4 5

Work Scope

  1. The app needs to run in foreground . In Android, this also shows up a persistent notification which is fine. Not sure how it works on iOS & windows. Running in foreground means the app cant be force closed. A few phones like Xiaomi ones dont honor this & still force close a foreground app. That is fine.
  2. In the app DB - there will be list of WiFi profiles bundled. WiFi profile is WiFi SSID & password. When you connect to a new WiFi - Android creates a WiFi profile of the SSID & the password you entered so that it automatically connects to the WiFi when you come in the vicinity. Also keep WiFi BSSID which is like MAC address for a WiFi helping in its unique identification. For testing purpose - bundle your home WiFi SSID & wrong password .
  3. On app start - the app scans for available WiFi & tries to find the match in local DB. If it founds a match - it tries to connect to the WiFi by creating its WiFi profile.
  4. If connecting to WiFi fails (may happen as the password might be changed) - it sends SMS to a predefined number requesting new password. It gets a SMS reply from a (different) pre-defined number. The app updates its WiFi DB with the new password & connects to WiFi again. For testing purpose - you can simulate an incoming SMS in the code itself.
  5. On successful connection, the app keeps accounting the WiFi data (both upload & download) & report to a REST API. For testing purpose - you could keep 2 counters in app DB & keep on adding to them every 1 minute.
  6. On app shutdown (you may create a stop button or this could be force shutdown or app delete) - the WiFi profile created should be removed & WiFi should be disconnected.
  7. There is a UI component which gets data from REST API. Ideally it shows the overall data usage of the user. The same UI should come up when user tap on the notification bar. For testing purpose - locally store the accounted data & show it up on the UI.
  8. When the WiFi is not in connected state & other things like WiFi discovery or SMS is happening - its good to show what process is currently happening on UI thread. Although - this can just be showing ‘initializing/connecting to WiFi’ kind of screen too.

Resources :-

  1. https://github.com/hirokikawanishi1106/StartForegroundTest - running Android app in foreground & keep on scanning for WiFi.
  2. https://github.com/BetterVoice/bv-bgs-foreground - phonegap plugin for running foreground service in Android
  3. https://github.com/hypery2k/cordova-hotspot-plugin/tree/master/src/android/com/mady/wifi/datatransfer - sample WiFi data on regular basis in Android
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment