Git Product home page Git Product logo

gdsc-hsu / gateway Goto Github PK

View Code? Open in Web Editor NEW
22.0 22.0 9.0 26.28 MB

[Top 3] 2022 Solution Challenge an IoT apporch include Flutter & embedded devices, network protocol, solving/helping covid-19 situation

License: MIT License

Kotlin 0.05% Swift 0.17% Objective-C 0.02% Dart 97.14% HTML 1.61% Ruby 0.92% Shell 0.09%
arduino ble bluetooth bluetooth-low-energy covid covid-19 esp32 firebase flutter gdsc iot

gateway's People

Contributors

asdfghuyjklpoi avatar dangcao1999 avatar truonghoangduy avatar zeroska avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gateway's Issues

[App] Motion not present in area toggle turn off running services.

EPIC :

Motion not present in area toggle turn off running services camera, ml_kit , faceMask and showing off the advertisement

Description :

AS BLE Device scanning the area it will detect whether motion been detected and transfer the data If motion been detected BLE board will send the data over BLE formatted as String and decode into:

# string => bool
true: Motion is detected
false: No Motion has been detected

Specification

  • Turn off running services
  • Keep BLE connection alive
  • When no motion detected showing advertisement
  • Re-initialize gateway check services when motion been decected

Note

  • Fill free to contact for model change, un-clear requirements/explanation

[Backend] Organization able to register and update detail for their devices.

EPIC :

Dependency : #11 when user already has the organization endpoint
The functionality is allow organization to add the device(mobile) and configure device information into their
organization for device management.

System actor : Mobile, Web

Description :

Organization on their Web dashboard and create new device (without any information), only has the QRCode encoded with the device-assess-key, When Mobile scan the QRCode so that it could claim(device-assess-key) the created device and upload it information to the organization.

New device are created with the organization with the following information [x]. When device are added susses-fully organization are able to modify their changeable information

This bellow information will be saved to the mobile app (local data) and use for device authentication.

[x] device information

Device name: string -changeable

Device location: string 
(Name of streets, school campus location or custom markup, GPS stamp) -changeable

Device unique id: string 
(user for api parameter)

Device assess key: string

Device MAC address: string

Tag: array of string
(Device tag for query, filter purpose) -changeable

Device authentication only use device-assess-key , device-id, device-mac
Hardware information data : MAC address


Specification

  • Endpoint for create device, response with the device-id, device-access-key and blank information
  • Endpoint for update changeable information with the already registered device.
  • Endpoint for Mobile to claim and upload it hardware information data to the created device, respond back the device information.
  • Test endpoint by getting device information by device-id

How device claim work

  1. Device scan the QR encoded with device-assess-key
  2. Device claim the new created in the backend by provide scanned device-assess-key
  3. When claim device upload it hardware data to claim the created device

Note

  • Fill free to contact for model change, un-clear requirements/explanation

[Web] Create Organization Page

After login users will get their organization (GET /organization) follow the status code

image

  • Code 400 user does not belong to any organization, they allow to create an organization (dialog)

image

  • 200 meaning they have been in an organization we route them to the dashboard page

  • In dashboard page showing their organization name in the navbar

  • Route them to "Device Management Page" as default when go in to dashboard

[Backend] Research MQTT does the protocol could implement feature the device to connection status. (online, or offline)

Here are some detail about MQTT, blog post could help you research an solution

  • MQTT allows client to connect to broker with (username, password).

  • MQTT protocol has session, and Qos level. Meaning that the broker know when device has been disconnected

  • (copy form) MQTT Last Will and Testament (LWT): when the MQTT broker detects that the client is no longer connected it will publish the LWT message to the configured topic (note LWT is configured on the remote client, not in OH). Then create a switch Item to subscribe for those LWT messages and flip it off when you see a LWT message and back ON when you see any other message (use a rule).

  • LWT vietnamese blog (thông báo cho các khách hàng khác về một khách hàng bị ngắt kết nối một cách vô duyên.) : https://vidieukhien.xyz/2020/03/22/mqtt-tutorial-mqtt-last-will-and-testament/

  • LWT best practice https://www.hivemq.com/blog/mqtt-essentials-part-9-last-will-and-testament/

  • Flutter LWT : implement link

  • Topic for status : org/{org-name}/device/{device-id}/status.

  • Requirement for near realtime is not required (heart-beat or ping is okie).


Google Cloud Solution

GCP has a solution for it: https://stackoverflow.com/questions/54609757/google-core-iot-device-offline-event-or-connection-status , but it has required Stackdirver(GCP monitor tool) to monitor IoT_Core for device disconnection

relatied to GCP solution :
persistent-device-connection-status
google-cloud-detecting-offline-devices

Stuff has been proved

  • Flutter client able to connect to broker with MQTT v3.1
  • Authenticate custom Aedes broker

[Docs] Web dashboard application user-interface

Note

  • Using an UI-libary nebular. I suggest nebular-iot-dash-board.

  • We will use UI library component to design our web dashboard.

  • Firebase Auth for login/register

  • Firebase firestore: to monitor device status in near realtime

Using sidebar to navigate to each web page.

# sample routing schema. modify as you will
/: "Home Page"
/login: " Login Page"
/signup: "Sign up Page"
/device/{id}: "Device Detail Page"
/device/management: "Device Management Page"
/device/new: "Create new device"
/organization/new : "Create Organization Page"

Page

Home Page

  • Showing organization detail, allow to see device id, status, name, and location as a list with paging and sorting to locate the device
  • Allow the user to click on the device name to route Device Detail Page

Device Detail Page

  • Showing data log belonging to that only device, current device status, and device information.

Device Management Page

  • Allow user to see all their device in table with paging
  • In table click to device allow them to navigate to "Device Detail Page"
  • In table having a selection for remove device,
  • Having a button allows the user to add new device and route them to "Create new Device Page"

Create new Device Page ->

  • To create device users have to type in their device information when they are finished they are able to submit the form.

  • When the form is submitted and successful they will see their device status and their device configured QR code.

Login/Sign up

  • Page allows the user to sign in with an Email & Password

  • If they don't have an account they could create their account.

Create Organization Page:

  • Page allows the user when they first sign-in able to create an organization
  • They will be able to type in their organization information
  • Upload an .IMG as their organization image.

[App] Get ORG preview detail before confirmation.

  • After scanning device will have the backend endpoint
  • Using scanned backend endpoint render ORG preview media (IMG, name, ...)
  • User see their preview organization, they has to conform it, then UI able them to submit their device info into Backend API

branch name : "feature-org-preview"

Organization able to view statistic over device data log

EPIC :

Organization could do statistic query data over device log.

Description :

Organization on the web could see log for current device by #12.

Log are too large for them to look at, they are able to make query like to find or locate device log they wanted. The data response back will be device log located at #13

  1. Query : Between start of timespan <-> end of timespan
  2. Query : Pacific day like 12/2 (only show result in that day)

Note : Query 1,2 are not combine only use one or another

URL:/{device-id}/________


Specification

  • Endpoint

Note

  • Fill free to contact for model change, un-clear requirements/explanation

[App] Device identity configure, and re-configure when startup

EPIC :

The functionality allows user when they configure their device into their organization dashboard as return they will have their device credential, after the app re-open the app could be able to re-config themselves with saved credential without having to re-configure manually.

Description :

  • First time they configure the app has to save the Device Credential cached location (share_pref).
  • And then they could use those cached credentials to config themselves.
  • After the app is closed and re-open, functionality could allow loading the data from the cached location and re-configured themselves.

Note

  • Fill free to contact for model change, un-clear requirements/explanation

[Backend] Organization able to view device data log + device detail.

EPIC

This functionality allow organization to view device detail ([device information] #12) by doing so they could see the [data has been log] #13 further on organization could make query on those data.

Description

Use-case 1 : view device detail
Organization on the web app could view the device information by make query to device-id, these are the data they will get

[Model for device information #12]

Use-case 2 view device data log
After the organization has the view detail of the device they has an option to view data.
Data pull form the backend will have 2 options (stateless, state-full).

[Model for data log #13]

Specification

  • Endpoint for view device detail
  • Endpoint for view device data log, two option state-full and stateless

[GEN] Core feature interaction Flow chart

  1. Proximity (10-12cm)
  2. THERMOMETER (35-38*C)
  3. FaceMask (is wearing or not)
  4. RESET(SKIP)
  5. QR code. (Covid QR Code)
  6. RFID (Student card)
  7. Hand sanitizer (Optional)

Those are the data required when user interaction with the core function of the app.

[App] W4 UI defect

  • Missing i18n
  • Overflow text occur
  • Device orientation (lock)

Test devise Iphone 6 plus 5.5 inch

Missing i18n, Overflow text occur (Iphone 6plus)

Device orientation (lock)

[App+UI] Device scanning

Description

Device scanning: this functionality allows the user to scan the IoT device, UI should be clear to indicate which step the user is currently in. After the device being scanned successful, the functionality will transfer the scanned result in order to establish Flutter to IoT device via ble connection.

[App-state]

  • AC S1: User could scan and locate a device
  • AC S2: The scanned device must be valid and be programmed by ours.
  • AC S3: If the scanning process is not found, notify users whether they could re-scan or does their device has not been on.
  • AC S4: Read general information about the successfully scanned device

[App-GUI] spectification
UI element required to indicate user base on state behavior

  • AC UI1: Scanning process
  • AC UI2: Device founded or match
  • AC UI3: If not founded or match must have UI for user to rescan
  • AC UI4: Show general information about the scanned device
  • AC UI5: Button to make a connection

[DOCS] [Backend] User able to create their organization

EPIC :

User able to create their organization, and following on using the rest of the backend api belong to their created organization

Description :

Web client after they log in with email, password. If they are not participating in an organization they have an option to create an organization.

When an organization is created successfully, they will be able to use their organization endpoint

"https://{our_project_domain}/org/{organization_id}/"

organization_name: "Google Developer Student Clubs of Hoa Sen university"
organization_img: "xxx-xxxx-xxxx.jpeg"
organization_endpoint : "https://{our_project_domain}/org/{organization_id}/"
organization_id: "gdsc-hsu"

*Note:

  • organization_id is uquie (frist-come-frist-serve)
  • organization_name: could be duplicated

Specification

  • Bullet end point

Note

  • Fill free to contact for model change, un-clear requirements/explanation

Device are able to"POST" their sensor data

EPIC:

The functionality allow device (mobile) to transfer their data into organization backend. Later they could gather the data or make query or filter on it.

Description:

The device (mobile) app after each person interact their data [x] will be transfer to organization backend.

Header: device access token

[x]

body_temperature : float
face_mask: bool
covid_identification: 
        identification_method: QR | RFID
        identification_data : string
is_complete : bool (indicate weather user completing all the step, or they just do covid_identification)
Timestamp:

Note:

  • Timestamp using server time

Specification

  • End point for device to post their data.

Note

  • Fill free to contact for model change, un-clear requirements/explanation

[Web] Device Management Page

Allow users to see all their device belong to their orgnaization.

  • Design UI ( I suggest table view)
  • Show basic device information (id,name , location , tag, status)
  • For realtime using Firestore

Some noted in table nice to have

  • In table click to device allow them to navigate to "Device Detail Page"
  • In table having a selection for remove device,
  • Having a button allows the user to add new devices and route them to the "Create new Device Page"

[App] Device Connection

Description

The functionality base on the following DeviceScan the valid device when scanning complete will move on to establish the ble connection

#### Rules
1. Device has to be valid (be programmed by ours)
2. Device has to turn on and broadcast BLE single

[App-state]

  • AC S1: During ble app-iot device established connection any disconnection occur must be informed and establish device to app reconnection as automated
  • AC S2: Device connection state has to be notified (connected, waiting, disconnected,....)
  • AC S3: When device has lost connection -> initialize the process of re-scan - re-connection

[App-UI]

  • AC UI1: When reconnection state happen notify user via dialog
  • AC UI2: When connected state notify and auto closed (timeout in 2s) dialog
  • AC UI3: When waiting state notify current is waiting to connect
UI3 -> U2
    \UI1/

[Docs] Organization able to monitor device status (online ,offline)

EPIC :

An organization able to monitor device status (online , offline)

Description :

As devices (mobile_app) are working organizations want to check the device connection status. So that they could identify in real-time does the device is still functional (online) or has been shut down (offline).

#19 After doing research we are using MQTT for this feature.


Ex meaning for suggestion, you could delare your own impl if you not cool with it fill free to notify me

Ex: Firestore collection

var device_connection = firestore.col("device-status").col("device-id").{}

Ex: Stored object

status: offline|online
timespan: int "Based on this we could know what time does the device has been in those statuses"

[DevOps] BLE Emulator Suite

Automate, clicking use for emulator BLE Sensor been measure by ESP32 (using real IoT-sensor to do those steps are harshh 😢 )

  • #8
  • Declare Automation step ex : user walk in take measurement range, temper if so create JSON declare step
  • CLI emulator
  • AC 2: Web port interaction, using AC1
  • AC 3: Desktop BLE Emulator https://github.com/pybluez/pybluez

[DevOps] BLE GATT auto-generator

  • AC 1: YMAL file as for configuring BLE GATT UUID, CHARACTERISTIC, and SERVICES
  • AC 2: READ YMAL file and Export(write) to Dart, C programming langue
  • AC 3: Flutter(Dart) ESP32(C) must use the exported (auto-generated) by AC 2

YMAL example

gatt_profile:
  - BLE_SERVICE_PROXIMITY_UUID : "00000A00-5226-4AE0-8977-656FD3C42DA2"
  - BLE_CHARACTERISTIC_PROXIMITY_DISTANCE: "00000A02-5226-4AE0-8977-656FD3C42DA2"

[GEN] Team development/debug environment setup

Documentation how you guys set up your required environment to begin development process.

This will include how we could mock other process by each teem.

  • 1. Flutter
  • 1. IoT
    Backend, Web is way more flexible in development process
  1. Backend
  2. Web dashboard

Note:

  • Bug aware by other mock required for your task if you noted it, report and lead will generate hot-fix

[DevOps] HMW DESIGN AN ARCHITECTURE ALLOW USER SELFT-HOST OURS OPEN-SOURCE

HMW DESIGN AN ARCHITECTURE ALLOW USER SELFT-HOST OURS OPEN-SOURCE

Base on the discussion we're having ours (architecture)solution will enable user self-host ours open source architecture with an GCP

Requirements

  1. Mobile app able to find the self-host backend. (Links, QR)
  2. Backend are able to located the Mobile app wanted to connect to it.
  3. Backend provide device access key (device-id) for mobile app.
  4. (One device-id per mobile app)
  5. Open-source(web, backend) in the picture down bellow are able to be provision in their gcp account. via terraform

=> After Mobile app successful find the backend self-host, and establish with backend device access key (device-id). The mobile app(device) will belong to the backend self-hosted (organization).

Img
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.