murphyslemon / Raspberry_Pi_Server

International Sensor Development Project: This project is a voting system that uses a raspberry pi server and multiple voting devices. The system is easy, secure, scalable, and supports anonymous and registered voting. This repository focuses on the Raspberry Pi server.
0 stars 3 forks source link

ESPDevice class and init function #4

Closed MagnusLii closed 6 months ago

MagnusLii commented 7 months ago

Class for ESP objects and init function.

Goal

The objective is to construct a class tailored for ESP objects. These objects will contain variables crucial for ESP functionality, including the ESP's MAC address, registered usernames, unique ID, vote status, registration confirmation topic string, and vote topic string. Additionally, the class maintains a count of created objects. The initialization function should accept a MAC address and an optional registered username.

Arguments

Object variables

Returns

MagnusLii commented 7 months ago

class Esp:

    registredESPs = 0

    def __init__(self, mac_address, registeredUser='NULL',):
        self.mac_address = mac_address
        self.registeredUser = registeredUser

        self.uniqueID = random.randint(1, 10)  # Needs to be changed later.
        self.voteStatus = 'pass'  # default value is pass.

        self.registration_confirmation_topic = registrationResponeTopic + self.mac_address

        Esp.registredESPs += 1
MagnusLii commented 6 months ago

Having a class for ESPs on the Flask server makes handling ESP related data and requests a headache as all data needs to be updated on the objects and DB. This function is deprecated.