Example #1
0
class Bluetooth:
    """ 
        This class represents the sending of a message to a connected device
        stating the current temperature and humidity

    """
    def __init__(self):
        """
            On initialisation the Bluetooth class retrieves the current Temperature and Humidity from the DataLogger class
            and sends a notification via Pushbullet with a message stating that a Bluetooth connection has been made aswell
            as the current Temperature and Humidity.
         """
        #declare variables that handle interactions with other classes
        self.__bluetooth = BluetoothManager()
        self.__dataLogger = DataLogger()

        #declare variables that store the current temperature and humidity to 1 decimal point
        self.__currentTemperature = round(self.__dataLogger.getTemperature(),
                                          1)
        self.__currentHumidity = round(self.__dataLogger.getHumidity(), 1)

        # using the bluetoothManager initialisation to create a message for the current temperature and humidity
        self.__bluetooth.createMessage(self.__currentTemperature,
                                       self.__currentHumidity)

        # self.__deviceName = input("Please enter your device' name: ")

        #Hardcode the device that bluetooth will search for
        self.__deviceName = "Yonas"

        #search for the device that needs to be connected once found print on cmd line that it is, if not found continue searching
        self.__bluetooth.connectToNearByDevice(self.__deviceName)

        #once that device has been connected send a pushbullet notifcation with the message
        self.__bluetooth.sendMessage()