Open mavishak opened 3 years ago
04.03.2021:
We sent a POST HTTPS request using port 443 and SSL
POST /rest/test/posts.json? HTTP/1.1 Host: **** Content-Type: application/json Content-Length: 49
{"author": "Nemo Resh", "title": "Fish are blue"}
Note: we got the format of the HTTP message using Postman and Firebase documentation Firebase: Saving Data
The HTTP request to firebase should be as follows:
PUT /devices/[device_id]/history/[dd-mm-yyyy]/[hh:mm].json?auth=[DATABASE_SECRET] HTTP/1.1
Host: [DATABASE_HOST] Content-Type: application/json Content-Length: [BODY LENGTH]
{"image_path": "image", "notes": "alarm went off"}
see: How do I authenticate my Firebase with just a string key
user must be able to change Wi-Fi SSID and PSW without passing through the web. There are two ways to achieve this:
device authentication will be done using the database secret and device id.
We need to find a way to get the actual date and time when an alert is created.
We don't expect
void timestamp(void){
time_t rawtime;
struct tm *info;
time( &rawtime );
info = localtime( &rawtime );
memset((char*)command, '\0', COMMAND_SIZE*sizeof(uint8_t));
sprintf((char*)command, "Current local time and date: %s", asctime(info));
write_usart2((uint8_t*)command);
}
The output time and date was not correct:
Current local time and date: Wed Dec 31 23:59:59 1969
We tried playing with firebase server value - timestamp:
_{"imagepath": "image", "notes": "alarm went off!", "time": {".sv": "timestamp"}}
We did not find a way to insert the timestamp in the path and it seems the timestamp does not indicate the actual time and date as it is the time since UNIX epoch, in milliseconds. see: Firebase Timestamp and: Firebase server values Rest API
After consulting our instructor we have decided to use the Firebase timestamp and convert it to the date and time using: UNIX timestamp converters.
var s = new Date(1504095567183).toLocaleDateString("en-US") // expected output "8/30/2017"
console.log(s);
see: convert UNIX timestamp to date and time convert timestamp to date and time in angular
We organized the code. Now the alert is recorded under the device-ID in the Real-Time Database. !TBD:
print=silent
?
Some pointers: