---
# System prepended metadata

title: Website Overview
tags: [SmartBridge]

---

# Website Overview
###### tags: `SmartBridge`
*    Every web page is the **index.\[php|html\]** in roots of documentaries.
*    For pages need any kind of graph, **Chart.js** is required and also **Webpack** to bundle up the imported modules. 
## Login 
In */api/login/*
*Purpose: Enable different view for different users and supervisors*

* Uses new mysqli instead of the old PDO
* Mainly showed pages 
    * **index.html:** Login page. Login form submit to src/authenticate.php.
    * **/src/var.php:** Stores names and urls of each service into an arrays. 
    * **/src/authenticate.php:** 
        * Verify the input ID and password.
        * If password is successfully verified, begin a new session and redirect.
    * **/src/home.php:** Page will redirect here for normal users (root == 0). Here list all available services for the account. 
    * **/src/superuser.php:** Page will redirect here for  superusers. Include functions below:
        *  In `USER` tab, superusers can modify other accounts' profiles. Including profiles management and the creation of a new user. 
            *  profiles.php, typeManager.php,  createUser.php, passManager.php, remark.php(stores notes in profile), delete_UID.php, runtime_log.php
        * In `ADD UID` tab, superusers can add UID to corresponded user accounts.
            * handle-file.php
        * In `IP SERVER` tab, superusers can add IP or domain name, OTA to corresponded user accounts. It is used for classifying China clients and others.
            * handle-uid-server.php

### Function Type
This is **type** code for all the website. 

* `gw_slip`
    * Falldown detection
    * **Name:** 跌倒偵測
* `body_temp_{type}`
    * **type:** Refer to [link](https://hackmd.io/@lziTWi3qQcCAGYzl1jomhA/Bk9q7bkQK/edit) for more info about each type
* `temp_hum`
    * Environment temperature of pig farm
    * **Name:** 養豬場溫度與濕度
* `human_detect`
    * Human detection
    * **Name:** 人員偵測
* `distri_temp`
    * distribution box temperature
    * **Name:** 電箱溫度 

### Database (smarcxvi_customer_login)
* account
    * Stores all the account
    * **user_id(Primary Key)**
        * Unique ID for each user
    * **username**
        * Unique username for each user
        * Only 3 capital letter
    * **password**
        * Hashed password the password
    * **root_access**
        * Whether the user have root access
        * Information of normal user can be edited by root user
        * 0: not root user, 1: root user
* account_info
    * Store function availble to that account
    * **user_id(Primary Key)** 
        * Unique ID for each user
    * **function_type(Primary Key)**
        * Type of function, mentioned above.
    * **type(Primary Key)**
        * Only for **body_temp** as function type
        * Non body_temp will be set to **empty string**
        * Refer to [link](https://hackmd.io/@lziTWi3qQcCAGYzl1jomhA/Bk9q7bkQK/edit) for more info about each type
    * **max_temperature**
        * Only valid for **body_temp** as function type
    * **min_temperature**
        * Only valid for **body_temp** as function type
    



## Falldown
### Database (smarcxvi_fall_down)
* heartbeat
    * *Record heartbeat send by gateway*
    * **uid:** UID of gateway
    * **device:** Sensor number
    * **timestamp:** Timestamp of upload, provided by the RESTful API. Don't use auto-fill in database.
* room_uid
    * *Maps uid to room number*
    * **room:** Room name/number
    * **uid:** Contain 21 character. First 20 character is gateway UID, and the last character is number of device.
    ```uid = {gateway's uid}+{device number}```
* slippage_trigger
    * *Record falldown trigger send by the sensor*
    * **uid:** UID of gateway
    * **device:** Sensor number
    * **timestamp:** Timestamp of upload, provided by the RESTful API. Don't use auto-fill in database.
* uid_device
    * *A record of UID and device that previously uploaded before*

    * **uid:** UID of gateway
    * **device:** Device number

## Human Temperature Management (not use)
*Purpose: Supposedly being used in a hospital or a nursing home, the purpose is to monitor the temperature of patients*
### Database (smarcxvi_human_management)
* gateway_uid: uid of gateway points to  user name
* human_temperature: Store data for each uploaded sensor
    * **gateway_uid**: uid of gateway
    * **sensor_uid**: (0~7) the number of a sensor on a gateway
    * **human_uid**: gateway_uid+sensor_uid
    * **ta**: environment temperature
    * **tb**: body temperature
    * **timestamp**: time
* human_uid(not use)
* room_uid: room name point to human_uid
* temperature_threshold: the threshold of fever or hypothermia

## Human Detection (not use)
*Purpose: Detect human exist in places or not*
### Database (smarcxvi_human_detection)
* heartbeat_human_detect
    *  *Record sent by heartbeat* 
    *  **uid**: 20 characters of uid
    *  **device**: device  number given by gateway between 0~7
    *   **maxtemp**: max taget temperature
    *   **maxlocation**: max environment temperature
    *   **timestamp**
* rood_uid
    *   **room**:room name
    *   **uid**: varchar(21) {uid}+{device}
* triggered_human_detect
    * *Data instert to this table when device is triggered (Someone enter or leave. Not update regularly)*  
    *   **uid**:20 characters
    *   **device**: device number between 0~7
    *   **triggered**:leave(0), enter(1) 
    *   **maxtemp**
    *   **maxlocation**
    *   **timestamp**
* detection_triggered
    *   Probably not use 

## Face Recognition
### Database (smarcxvi_face_recog)
* human_info
    * *Record of all the staffs/visitors/strangers/blacklisted that have passed through the gate*
    * **human_id:** primary/unique key
    * **name:** as defined
    * **facename:** the file name of the picture of this person
    * **birthday:** as defined
    * **gender:** as defined
    * **type:** identify whether this person is stranger(0), staff(1), blacklist(2), visitor(3)
* auth
    * *Identify the gates a specific person can pass through*
    * **human_id:** same with the human_id from `human_info`
    * **gate_id:** a string and is updated(appended) when a new door is permitted for a person
* gate_permission
    * *(backway) Identify the person with permission to pass through a gate*
* gate_log
    * *Record of time when a specific person pass through a gate*
    * **temp:** the temperature measured when this person passed through the gate
    * **timestamp:** the time when this person passed through the gate
* device_config
    * *A reference for calibration need during the update*
    * **uid:** gateway uid
    * **firmware** 
    * **gate_enable** 
    * **temp_calibration** 

## Pig Farm Management
*Purpose: Monitor temperature and humidity of pig farms. Smart-plug system control fans in pig farms automatically*
### Database (smarcxvi_pig_temp_humid)
* gateway_uid
    * *Record the gateway uid owned by the user*
    * **name:** user name
    * **uid:** gateway uid
* pig_temperature
    * *Record of Temperature and Humidity measured*
    * **gateway_uid:** 20 digits
    * **sensor_uid:** 1 digit
    * **pig_uid:** combination of gateway_uid and sensor_uid
* base_temp 
    * A control panel and record of what temperature and humidity wanted by the user
    * **pig_uid:** combination of gateway_uid and sensor_uid
    * **base_temp:** the max temperature wanted
    * **smart_plug:** automatically open or turn off the fans
    * **Status:** physical control mode(1), auto mode(2), site manual control mode(3)
    * **compen_temp:** compensation temperature
    * **compen_humid:** compensation humidity
* sensor_uid
    * *Record the name of the sensor as desired*
    * **sensor:** the name
    * **uid:** sensor id

## Pregnant Pig Management
### Database (smarcxvi_pregnant_pig)
* gateway_uid: uid of gateway point to  user name
* pig_temperature: Store data for each uploaded sensor
    * **gateway_uid**: uid of gateway
    * **sensor_uid**: (0~7) the number of a sensor on a gateway
    * **pig_uid**: gateway_uid+sensor_uid
    * **ta**: environment temperature
    * **tb**: pig temperature
    * **timestamp**: time
* room_uid: room name point to human_uid
* temperature_threshold: the threshold of fever or hypothermia

## Distribution Box
*Purpose: Monitor temperature of distribution boxes*
### Database (smarcxvi_sensor_temperature)
* gateway_uid: uid of gateway point to user name
* temperature: Store data for each uploaded sensor
    * **uid**: uid of gateway (varchar(20))
    * **device**: (0~7) the number of a sensor on a gateway
    * **value**: the temperature of the distribution box
    * **timestamp**: time
* uid_device: List the device numbers owned by the gateway