Server for receiving, processing and displaying data received from sensors. Software for microcontroller.
Features:
- Request value from sensor in real time Microcontroller longpolls server for such requests and sends sensor's value in response if needed. Server through WebSocket (SignalR) notifies client which posted request that data was received (and what data exactly).
- Set email notification when sensor reached assigned threshold
- Compare sensors data from different periods of time
File appsettings.json
in Gss.Web
-
Email
section contains creds for site's mailer which will send warning (when sensor value reached set limit) or account messages. -
AzureImages
section contains creds for Azure Blob StorageEach received image will be compressed in thumbnail with Function App
-
MicrocontrollersConnectionsOptions:Socket:IPAddress
address of server (on this address microcontrollers will send data) -
MicrocontrollersConnectionsOptions:Socket:Port
port of server (on this port microcontrollers will send data)
{
"ConnectionStrings": {
"AzureDB": ""
},
"Authentication": {
"JWT": {
"Issuer": "",
"Audience": "",
"Key": "",
"AccessTokenLifetimeMinutes": "30",
"RefreshTokenLifetimeDays": "10"
},
"Google": {
"ClientID": "",
"ClientSecret": ""
}
},
"Email": {
"Address": "",
"Password": "",
"SmtpServer": "smtp.gmail.com",
"SmtpPort": "465",
"SmtpUseSsl": "true"
},
"AzureImages": {
"AccountName": "",
"AccountKey": "",
"ImagesContainer": "images",
"ThumbnailsContainer": "thumbnails",
"SupportedExtensions": [
".png",
".jpg",
".jpeg",
".gif"
]
},
"MicrocontrollersConnectionsOptions": {
"Socket": {
"IPAddress": "",
"Port": "",
"SendTimeout": 100000,
"ReceiveTimeout": 100000,
"ListenQueue": 10
}
}
}
Apply migrations to DB
Update-Database
- in Visual Studio's Package Manager Console
File .env
in Gss.Web\ClientApp
REACT_APP_SERVER_URL=http://localhost:5000/
REACT_APP_IMAGES_URL=https://sensorsappimagestorage.blob.core.windows.net/images/
REACT_APP_THUMBNAILS_URL=https://sensorsappimagestorage.blob.core.windows.net/thumbnails/
REACT_APP_AVATAR_PLACEHOLDER_URL=https://sensorsappimagestorage.blob.core.windows.net/images/acf7abad-1d34-45c4-b3fe-6b02637b599e.png
REACT_APP_UNAUTHORIZED_URL=/unauthorized
REACT_APP_SERVER_ERROR_URL=/serverError
To communicate with server microcontroller uses TCP protocol. If there any error in session handling than connection between server and microcontroller will be terminated.
Session consists of three phases:
-
Microcontroller authorization Microcontroller sends
STM_AUTH|userID;microcontrollerID;password
request. If authorization is successful server will sendServer_OK
response, after which server will wait for second request.- Part before
|
character is command -STM_AUTH
userID
- id of microcontroller ownermicrocontrollerID
- id of microcontrollerpassword
- microcontroller's password
- Part before
-
Request handling There are three requests:
-
STM_DATA|sensorID;sensorValueReadedDateTime;sensorValue
- microcontroller wants to send sensor's data. Successful response -Server_OK
sensorID
- id of sensorsensorValueReadedDateTime
- date and time when value was read (en-US
)sensorValue
- sensor's value
-
STM_RQ|
- microcontroller asks if there is pending request to read sensor value If there is NO pending requests server response will be:Server_AT
. If there is pending request server response will be:Server_SV|requestedSensorID;
after which server will wait for microcontroller request which should beSTM_DATA|sensorID;sensorValueReadedDateTime;sensorValue
. -
STM_DT|
- microcontroller wants to receive server's UTC date&time Response:Server_DT|Date=16;Month=04;Year=12;WeekDay=0;Hours=23;Minutes=12;Seconds=11;
- 16 Apr 2012 Sunday 23:12:11
-
-
Close connection
- Change response status codes from 200 to 201 (where needed)
- Add auth from external services (Google, GitHub etc.)
- Add filters support for Client
- Forgot password? function
- Implement email features on Client (email verification, email change, password reset)
- Time sync logic for
STM_DT
- Requests encryption