mavishak / cnss-embedded

1 stars 0 forks source link

ROM configuration & Electrical power #32

Open mavishak opened 3 years ago

mavishak commented 3 years ago

08.06.2021

In the last two weeks we have worked towrds three goals:

Connecting device to an electrical power rather than PC

In order to do this we decided to take advantage of the esp8266 perminant memory, meaning that when the user configures their network details we emdietly write an AT command to the esp joining access point.

Configuring unique ID and registering it in Firebase

In order to achieve this we used the 96 bit STM32 unique ID. As there is no primitive type that can hold so many bits we used the next struct:

#define MMIO16(addr)  (*(volatile uint16_t *)(addr))
#define MMIO32(addr)  (*(volatile uint32_t *)(addr))
#define ID_ADDR  0x1FFFF7E8

struct u_id {
    uint16_t off0;
    uint16_t off2;
    uint32_t off4;
    uint32_t off8;
};

This code is writen in congifuration.h (and is not shared on git)

When the user configures their network details we registor the device to Firebase using them and reveal the ID to the user upon success for later use.

As the ID is a password of kinds we decided to reviel it only if the network details turn out to be currect. This way there is an extra layer of security to it.

Allowing user to change network details ar any given point

We enabled USART2 Rx, this way user has a way to comunicate with the device when connected to the PC (with USB). In order to configure device usere must press the ESC button, once device is connected to power there is 1 minute when the device polls this event inorder to allow user to comfertibally configure device. Of course also after this minute the ESC key will work, but the user might need to wait for other events to finish first.

Also, user is advised to turn device off throught the website if they are changing the network details rather than configuring it for th forst time just so thay don't send any unwanted alerts.

Untop of these we have also consititly been testing the reliability of owr firmware. Connecting owr device to the PC or a different power supplly at least 6-10 hours a day, sending from 100 - 400 alerts a day.

We have managed to burn one WiFi module :\ (probably do to the fact that it is rather cheap equipment)