lab_presence

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

README.md (3882B)


      1 # lab_presence
      2 An app that visualizes laboratory occupancy status.
      3 
      4 - hub: Maintain status in the laboratory.
      5 - client: Someone checking presence status from outside.
      6 - remote: Someone who changes their presence status from an external location
      7 - NFC: Update your presence status in the laboratory.
      8 - slint: Display presence status in the laboratory.
      9 - webserver: Ensuring redundancy for hub and cloud presence status, and serving as a gateway for external communication.
     10 
     11 ```mermaid
     12 flowchart TD
     13     hub --> webserver
     14     client --> webserver
     15     NFC --> hub
     16     webserver --> hub
     17     webserver --> database
     18     slint --> hub
     19     remote --> webserver
     20 
     21     subgraph public-cloud
     22         database
     23         webserver
     24     end
     25     subgraph Lab
     26         hub
     27         NFC
     28         slint
     29     end
     30 ```
     31 
     32 API Refarence
     33 https://spec.matrix.org/v1.18/client-server-api/#client-behaviour-8
     34 However, to determine which state was the most recent when the Lab network was disconnected, it seems necessary to also send the timestamp of when that status was saved.
     35 
     36 # specs
     37 ## get presence(for slint or sync between the webserver and the hub)
     38 
     39 |item|spec|
     40 |-|-|
     41 |http method|get|
     42 |end point|/api/v1/presence/{userId}/status|
     43 |auth|Authorization: Bearer <token>|
     44 
     45 <token> is a hashed onetime device-specific access token.
     46 
     47 ### Request
     48 
     49 Request parameters
     50 
     51 |Name|Type|Description|
     52 |-|-|-|
     53 |userId|string|Required: The user whose presence state to get|
     54 
     55 ### Response
     56 
     57 |Status|Description|
     58 |-|-|
     59 |200|The presence state for this user.|
     60 |403|You are not allowed to see this user’s presence status.|
     61 |404|There is no presence state for this user. This user may not exist or isn’t exposing presence information to you.|
     62 
     63 #### 200
     64 ```json
     65 {
     66     "presence": string,
     67     "status_msg": string,
     68     "timestamp": unixtime
     69 }
     70 ```
     71 #### 403
     72 ```json
     73 {
     74   "errcode": "M_FORBIDDEN",
     75   "error": "You are not allowed to see their presence"
     76 }
     77 ```
     78 #### 404
     79 ```json
     80 {
     81   "errcode": "M_UNKNOWN",
     82   "error": "An unknown error occurred"
     83 }
     84 ```
     85 
     86 ## change presence remotely
     87 
     88 |item|spec|
     89 |-|-|
     90 |http method|put|
     91 |end point|/api/v1/presence/{userId}/status|
     92 |auth|Authorizaiton: Bearer <token>|
     93 
     94 <token> is a hashed onetime device-specific access token.
     95 
     96 ### Request
     97 
     98 Request parameters
     99 
    100 |Name|Type|Description|
    101 |-|-|-|
    102 |userId|string|Required: The user whose presence state to get|
    103 ```json
    104 {
    105     "presence": string,
    106     "status_msg": string,
    107 }
    108 ```
    109 
    110 ### Response
    111 
    112 |Status|Description|
    113 |-|-|
    114 |200|The presence state for this user.|
    115 |403|You are not allowed to see this user’s presence status.|
    116 |404|There is no presence state for this user. This user may not exist or isn’t exposing presence information to you.|
    117 
    118 #### 200
    119 ```json
    120 {}
    121 ```
    122 #### 403
    123 ```json
    124 {
    125   "errcode": "M_FORBIDDEN",
    126   "error": "authorization failed",
    127 }
    128 ```
    129 #### 404
    130 ```json
    131 {
    132   "errcode": "M_NOT_FOUND",
    133   "error": "requested user was not found."
    134 }
    135 ```
    136 
    137 ## login(to get onetime device-specific access token)
    138 
    139 |item|spec|
    140 |-|-|
    141 |http method|post|
    142 |end point|/api/v1/login|
    143 |auth|none|
    144 
    145 ### Request
    146 
    147 Request parameters
    148 
    149 |Name|Type|Description|
    150 |-|-|-|
    151 |device_id|string|Required: device id|
    152 |device_secret|string|Required: device secret(like refresh token)|
    153 
    154 ```json
    155 {
    156     "device_id": "",
    157     "device_secret": ""
    158 }
    159 ```
    160 
    161 ### Response
    162 
    163 |Status|Description|
    164 |-|-|
    165 |200|The presence state for this device.|
    166 |403|You are not allowed to get onetime access token.|
    167 |404|There is no presence state for this device. This device may not exist or isn't exposing presence information to you.|
    168 
    169 #### 200
    170 ```json
    171 {
    172     "access_token": "",
    173     "expires_in": 3600
    174 }
    175 ```
    176 #### 403
    177 ```json
    178 {
    179     "errcode": "M_FORBIDDEN",
    180     "error": "authorization failed",
    181 }
    182 ```
    183 #### 404
    184 ```json
    185 {
    186     "errcode": "M_NOT_FOUND",
    187     "error": "requested device was not found."
    188 }
    189 ```
    190 
    191 ---
    192 
    193 # another presence updete system can add!
    194 If you have right to look lab's internet ARP table, you can use it.