GithubHelp home page GithubHelp logo

pyonair / pyonair-pycom Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 3.0 2.44 MB

Home Page: http://www.PyonAir.org

License: Apache License 2.0

Python 100.00%
lopy pycom hardware air-quality particle-monitor

pyonair-pycom's People

Contributors

ceruleanmars avatar danhaus avatar emiliolosbostos avatar javasscriptt avatar ossonts avatar pe-varga avatar pjb304 avatar up929312 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pyonair-pycom's Issues

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://pyonair.org/PyonAir-pycom/ (HTTP status client error (404 Not Found) for url (https://pyonair.org/PyonAir-pycom/))

Full Github Actions output

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://www.pyonair.org/ (error sending request for url (https://www.pyonair.org/): error trying to connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:../ssl/statem/statem_clnt.c:1915: (Hostname mismatch))

Full Github Actions output

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://www.pyonair.org/ (error sending request for url (https://www.pyonair.org/): error trying to connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:../ssl/statem/statem_clnt.c:1915: (Hostname mismatch))

Full Github Actions output

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://pyonair.org/PyonAir-pycom/ (error sending request for url (https://www.pyonair.org/PyonAir-pycom/): error trying to connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:../ssl/statem/statem_clnt.c:1915: (Hostname mismatch))

Full Github Actions output

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://pyonair.org/PyonAir-pycom/ (error sending request for url (https://pyonair.org/PyonAir-pycom/): error trying to connect: dns error: failed to lookup address information: No address associated with hostname)

Full Github Actions output

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://pyonair.org/PyonAir-pycom/ (HTTP status client error (404 Not Found) for url (https://pyonair.org/PyonAir-pycom/))

Full Github Actions output

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://pyonair.org/PyonAir-pycom/ (error sending request for url (https://pyonair.org/PyonAir-pycom/): error trying to connect: dns error: failed to lookup address information: No address associated with hostname)

Full Github Actions output

Are transmit timings consistent?

image

This has been left unattanded since it was turned on. The first message was transmitted ~10 minutes later with all readings as 0.

The next 2 messages were transmitted at 15 min intervals, then it dropped to 9 minutes, and back up to 13 minutes. All without me changing anything, is this expected behaviour?

read and cast to float is dangerous!

read and cast to float is dangerous!

#TODO: read and cast to float is dangerous!

        _thread.start_new_thread(self.lora.lora_send, (arg1, arg2))


def get_random_time(logger):
    """
    Get random number of seconds within interval
    :return: s_to_next_lora
    :rtype: int
    """
    #TODO: why is there no interval?? / not on object and no logger (added)
    config = Configuration(logger)
    # get random number of seconds within (interval - lora_timeout) and add one so it cannot be zero
    s_to_next_lora = int((machine.rng() / (2 ** 24)) * (int(float(config.get_config("interval"))*60) -
                                                        int(config.get_config("lora_timeout")))) + 1
    #TODO: read and cast to float is dangerous!
    return s_to_next_lora

    #TODO: stop getting config values so ofter -- look once -- static

cb5f377311dc0708bf5bcc282c9296a756d51249

that is a mess

that is a mess

global configuration dictionary

config = Configuration()

# TODO: that is a mess

            logger.exception('Failed to reset configurations')
            raise ConfigurationException(str(e))

    def getConfigDictionary(self):
        # TODO: that is a mess
        # global configuration dictionary
        #config = Configuration()
        return self.configuration

59451b465992528a4bc85cd204c5c330476b4830

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://www.pyonair.org/ (error sending request for url (https://www.pyonair.org/): error trying to connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:../ssl/statem/statem_clnt.c:1915: (Hostname mismatch))

Full Github Actions output

remove this multi option

remove this multi option

#TODO remove this multi option

            return self.configuration
        if isinstance(keys, list):
            return list(self.configuration[k] for k in keys if k in self.configuration)
            #TODO remove this multi option
        else:
            return self.configuration[keys]

9894c859107990b15a778bb24182091fc4e1455f

Many many attempts for OTAA activation

Why does it attempt to join so many times? I've seen many attempts before it starts to send the data. Flo has observed the same thing.

I don't think this is due to poor LoRaWAN coverage because SNR 10.25 RSSI -69 has been observered from the node.

memory hog, sort this class - static?

memory hog, sort this class - static?

#TODO: memory hog, sort this class - static?

import ujson
from Constants import *

#TODO: memory hog, sort this class - static?

class ConfigurationException(Exception):
    """
    Exception to be thrown if Exception occurs in configuration
    """
    #TODO: why?
    pass


class Configuration:

    def __init__(self,logger):
        self.logger= logger
        self.configuration = {} 
        #RM 
        
        self.read_configuration()

    # Configuration Accessor/Getter
    def get_config(self, keys=None):
        """
        If keys are given, return corresponding values in a list, if one key is given, return the corresponding value,
        if no arguments are given, return the config dictionary
        :param keys: keys in configuration dictionary
        :type keys: None, list of keys or a single key
        :return: values in configuration dictionary
        :rtype: dict, list of any, any
        """
        #TODO: Warn if key not in dict
        if keys is None:
            return self.configuration
        if isinstance(keys, list):

b174713f7c6f6ab71a548a520ae1cf935aa12e81

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://pyonair.org/PyonAir-pycom/ (HTTP status client error (404 Not Found) for url (https://pyonair.org/PyonAir-pycom/))

Full Github Actions output

LoPy does not connect

I am stuck at the step "Connect LoPy4 to PC" on https://s-u-pm-sensor.gitbook.io/pyonair/tutorial/software-installation/lopy4-software

I powered up the board and measured the voltages. Everythink looks fine. Then I am trying to connect the board to my Windows PC via the FTDI cable and it does not connect. Atom looks like this:
image

It does not go further. I tried on another PC but it is the same.
If I press the reset button on the LoPy4, some data transmission happens between the LoPy4 and the PC. Then it looks like this:
image

Can anyone help me with this?

Thanks in advance.

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://www.pyonair.org/ (error sending request for url (https://www.pyonair.org/): error trying to connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:../ssl/statem/statem_clnt.c:1915: (Hostname mismatch))

Full Github Actions output

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://pyonair.org/PyonAir-pycom/ (error sending request for url (https://pyonair.org/PyonAir-pycom/): error trying to connect: dns error: failed to lookup address information: No address associated with hostname)

Full Github Actions output

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://www.pyonair.org/ (error sending request for url (https://www.pyonair.org/): error trying to connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:../ssl/statem/statem_clnt.c:1915: (Hostname mismatch))

Full Github Actions output

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://pyonair.org/PyonAir-pycom/ (error sending request for url (http://www.pyonair.com/): error trying to connect: dns error: failed to lookup address information: Name or service not known)

Full Github Actions output

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://pyonair.org/PyonAir-pycom/ (error sending request for url (https://pyonair.org/PyonAir-pycom/): error trying to connect: dns error: failed to lookup address information: No address associated with hostname)

Full Github Actions output

when the sensirion gets a data too short error it fails several times

May want to wait longer before trying it again?

ERROR:SPS030 Interface:Data too short to parse
ERROR - 2020-03-27 15:00:34 - status_logger - Failed to read from sensor SPS030
PM1 - 2020-03-27 15:00:35,37,29,60,46,61,55,6639,1869,374,30,2,2
PM2 - 2020-03-27 15:00:35,27,28,28,28,183,212,214,214,214,1
PM1 - 2020-03-27 15:00:35,37,29,59,45,60,54,6540,1860,372,25,2,2
WARN:SPS030 Interface:Attempt 1/1 failed
ERROR:SPS030 Interface:Data too short to parse
ERROR - 2020-03-27 15:00:35 - status_logger - Failed to read from sensor SPS030
PM1 - 2020-03-27 15:00:36,37,29,59,45,60,54,6540,1860,372,25,2,2
PM2 - 2020-03-27 15:00:36,27,28,28,28,184,213,214,214,214,1
PM1 - 2020-03-27 15:00:36,37,29,60,46,61,55,6540,1860,372,25,2,2
WARN:SPS030 Interface:Attempt 1/1 failed
ERROR:SPS030 Interface:Data too short to parse
ERROR - 2020-03-27 15:00:36 - status_logger - Failed to read from sensor SPS030
PM1 - 2020-03-27 15:00:36,38,29,60,46,61,55,6696,1883,375,23,1,1
PM2 - 2020-03-27 15:00:36,27,28,28,28,184,213,214,214,214,1
PM1 - 2020-03-27 15:00:37,38,29,60,46,61,55,6696,1883,375,23,1,1
WARN:SPS030 Interface:Attempt 1/1 failed
ERROR:SPS030 Interface:Data too short to parse
ERROR - 2020-03-27 15:00:37 - status_logger - Failed to read from sensor SPS030
PM1 - 2020-03-27 15:00:37,38,29,60,45,61,55,6696,1883,375,23,1,1
PM2 - 2020-03-27 15:00:37,27,28,28,28,184,213,214,214,214,1
PM1 - 2020-03-27 15:00:38,38,29,58,44,59,54,6627,1866,362,23,1,1
WARN:SPS030 Interface:Attempt 1/1 failed
ERROR:SPS030 Interface:Data too short to parse
ERROR - 2020-03-27 15:00:38 - status_logger - Failed to read from sensor SPS030
PM1 - 2020-03-27 15:00:38,38,29,58,44,59,54,6627,1866,362,23,1,1
PM2 - 2020-03-27 15:00:38,27,28,28,28,184,214,215,215,215,1
PM1 - 2020-03-27 15:00:38,38,29,58,44,59,54,6627,1866,362,23,1,1
WARN:SPS030 Interface:Attempt 1/1 failed
ERROR:SPS030 Interface:Data too short to parse
ERROR - 2020-03-27 15:00:38 - status_logger - Failed to read from sensor SPS030
PM1 - 2020-03-27 15:00:39,39,30,59,45,64,57,6921,1960,355,21,6,3
WARN:SPS030 Interface:Attempt 1/1 failed
ERROR:SPS030 Interface:Data too short to parse
ERROR - 2020-03-27 15:00:39 - status_logger - Failed to read from sensor SPS030
PM1 - 2020-03-27 15:00:40,39,30,59,45,63,56,6801,1918,365,23,6,2
PM2 - 2020-03-27 15:00:40,27,28,28,28,185,214,216,216,216,1
PM1 - 2020-03-27 15:00:40,40,30,60,45,64,57,6918,1958,379,24,6,2
WARN:SPS030 Interface:Attempt 1/1 failed
ERROR:SPS030 Interface:Data too short to parse
ERROR - 2020-03-27 15:00:40 - status_logger - Failed to read from sensor SPS030
PM1 - 2020-03-27 15:00:41,40,30,63,47,66,58,7056,1989,398,26,5,2
PM2 - 2020-03-27 15:00:41,27,29,29,29,186,215,216,216,216,1
PM1 - 2020-03-27 15:00:41,40,30,63,47,68,59,7083,2011,406,28,6,2
WARN:SPS030 Interface:Attempt 1/1 failed
ERROR:SPS030 Interface:Data too short to parse
ERROR - 2020-03-27 15:00:41 - status_logger - Failed to read from sensor SPS030
PM1 - 2020-03-27 15:00:41,41,31,64,48,69,59,7191,2035,423,30,6,2
PM2 - 2020-03-27 15:00:41,27,29,29,29,186,216,217,217,217,1
PM1 - 2020-03-27 15:00:42,41,31,63,47,68,59,7104,2021,396,29,6,2
WARN:SPS030 Interface:Attempt 1/1 failed
ERROR:SPS030 Interface:Data too short to parse

Test 64GB card

64gb SD card fails,
see if keeping a 32gb partition on the 64gb card works

Repair overrride later

Repair overrride later

Override Preferences - DEVELOPER USE ONLY - keep all overwrites here

status_logger.warning("Overriding configuration with the content of debug_config.json")

with open('/flash/debug_config.json', 'r') as f:

config.set_config(ujson.loads(f.read()))

status_logger.warning("Configuration changed to: " + str(config.get_config()))

Check if GPS is enabled in configurations

Check if device is configured, or SD card has been moved to another device

#TODO: Repair overrride later

    add a corresponding decoder to the back-end."""
    config.save_config({"fmt_version": 1})

    #TODO: Repair overrride later
    # Override Preferences - DEVELOPER USE ONLY - keep all overwrites here
    # if 'debug_config.json' in os.listdir('/flash'):
    #     status_logger.warning("Overriding configuration with the content of debug_config.json")
    #     with open('/flash/debug_config.json', 'r') as f:
    #         config.set_config(ujson.loads(f.read()))
    #         status_logger.warning("Configuration changed to: " + str(config.get_config()))

    # Check if GPS is enabled in configurations
    
    if config.get_config("GPS") == "OFF":
        gps_on = False
    else:
        gps_on = True



    #=======REmove this config stuff === warn this devide id may be used -- check
    # Check if device is configured, or SD card has been moved to another device

9e40503065b9f660cf6a83f44417a0edacaa0f08

Warn if key not in dict

Warn if key not in dict

#TODO: Warn if key not in dict

import ujson
from Constants import *

#TODO: memory hog, sort this class - static?

class ConfigurationException(Exception):
    """
    Exception to be thrown if Exception occurs in configuration
    """
    #TODO: why?
    pass


class Configuration:

    def __init__(self,logger):
        self.logger= logger
        self.configuration = {} 
        #RM 
        
        self.read_configuration()

    # Configuration Accessor/Getter
    def get_config(self, keys=None):
        """
        If keys are given, return corresponding values in a list, if one key is given, return the corresponding value,
        if no arguments are given, return the config dictionary
        :param keys: keys in configuration dictionary
        :type keys: None, list of keys or a single key
        :return: values in configuration dictionary
        :rtype: dict, list of any, any
        """
        #TODO: Warn if key not in dict
        if keys is None:
            return self.configuration
        if isinstance(keys, list):

201faa5ecc973014abc3d5332e19b28a9c9850e8

stop getting config values so ofter -- look once -- static

stop getting config values so ofter -- look once -- static

#TODO: stop getting config values so ofter -- look once -- static

        _thread.start_new_thread(self.lora.lora_send, (arg1, arg2))


def get_random_time(logger):
    """
    Get random number of seconds within interval
    :return: s_to_next_lora
    :rtype: int
    """
    #TODO: why is there no interval?? / not on object and no logger (added)
    config = Configuration(logger)
    # get random number of seconds within (interval - lora_timeout) and add one so it cannot be zero
    s_to_next_lora = int((machine.rng() / (2 ** 24)) * (int(float(config.get_config("interval"))*60) -
                                                        int(config.get_config("lora_timeout")))) + 1
    #TODO: read and cast to float is dangerous!
    return s_to_next_lora

    #TODO: stop getting config values so ofter -- look once -- static

3bbff6706d7d26b35089bacfae4d8d1d84319153

why?

why?

import ujson
from Constants import *

#TODO: memory hog, sort this class - static?

class ConfigurationException(Exception):
    """
    Exception to be thrown if Exception occurs in configuration
    """
    #TODO: why?
    pass


class Configuration:

    def __init__(self,logger):
        self.logger= logger
        self.configuration = {} 
        #RM 
        
        self.read_configuration()

    # Configuration Accessor/Getter
    def get_config(self, keys=None):
        """
        If keys are given, return corresponding values in a list, if one key is given, return the corresponding value,
        if no arguments are given, return the config dictionary
        :param keys: keys in configuration dictionary
        :type keys: None, list of keys or a single key
        :return: values in configuration dictionary
        :rtype: dict, list of any, any
        """
        #TODO: Warn if key not in dict
        if keys is None:
            return self.configuration
        if isinstance(keys, list):

c0069a3770fc7a7e60ad431a229e8e8f631aa500

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://www.pyonair.org/ (error sending request for url (https://www.pyonair.org/): error trying to connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:../ssl/statem/statem_clnt.c:1915: (Hostname mismatch))

Full Github Actions output

user button is now disabled -- do something other than this

user button is now disabled -- do something other than this

#TODO: user button is now disabled -- do something other than this

from machine import Timer, reset
#from new_config import new_config
from helper import led_lock
import _thread


#TODO: user button is now disabled -- do something other than this

class UserButton:
    def __init__(self, logger):
        """

8ad2c43aaf6ae13c751afe63b30de9e11942a387

Set log level to level in config file

Set log level to level in config file

#TODO: Set log level to level in config file

from _pybytes_config import PybytesConfig
from machine import RTC, unique_id
from machine import SD, Pin, reset
import network # Used to disable WiFi
from initialisation import initialisation #initialise_time # TODO: clunky refactor
from helper import blink_led

import loggingpycom 
from LoggerFactory import LoggerFactory

from UserButton import UserButton

from Constants import *


#===================Disable default wifi===================

try:
    wlan = network.WLAN()
    wlan.deinit()
except Exception as e:
    print("Unable to disable WiFi")

#===============LED
pycom.heartbeat(False)  # disable the heartbeat LED
pycom.rgbled(0x552000)  # flash orange to indicate startup


#=========================Mount SD card=======
try:
    sd = SD()
    os.mount(sd, '/sd')
    #TODO: Error catch , set led for no SD card
except Exception as e:
    print("SD did not mount")


#===================Get a logger up and running asap!
logger_factory = LoggerFactory()
#TODO: Set log level to level in config file
status_logger = logger_factory.create_status_logger(DEFAULT_LOG_NAME, level=loggingpycom.DEBUG, terminal_out=True,
                                                        filename=LOG_FILENAME)
status_logger.warning("Rebooted")


#======================== Setup user interupt button
user_button = UserButton(status_logger)
pin_14 = Pin("P14", mode=Pin.IN, pull=Pin.PULL_DOWN)
pin_14.callback(Pin.IRQ_RISING | Pin.IRQ_FALLING, user_button.button_handler)





#TODO: provision if key on sd card

#set connect to false in config file?

#========Pybytes
pycom.nvs_set('pybytes_debug',99 ) #0 warning - 99 all
Pybytes.update_config('pybytes_autostart', False, permanent=True, silent=False, reconnect=False)
#pdb.set_trace()
pycom.pybytes_on_boot(False)
conf = PybytesConfig().read_config()
print("CONFIG:  ")

95bd1808573d9883887152f899319d1ceb3a8421

just use this in the config! dont translate

just use this in the config! dont translate

https://github.com/pyonair/PyonAir-pycom/blob/5cf2508329518e00434d4f503a03005616748f17/code/lib/initialisation.py#L143

import GpsSIM28
from PM_read import pm_thread
from loggingpycom import INFO, WARNING, CRITICAL, DEBUG, ERROR
#import Configuration
from Configuration import Configuration 
import _thread
import strings as s
import os
import pycom

class initialisation:

    def __init__(self, logger):
        self.logger = logger

    def initialise_time(self, rtc, gps_on, logger):
        """
        Acquire UTC timestamp from RTC module or GPS
        :param rtc: pycom real time clock
        :type rtc: RTC object
        :param gps_on: True or False
        :type gps_on: bool
        :param logger: status logger
        :type logger: LoggerFactory object
        :return: no_time, update_time_later
        :rtype: bool, bool
        """

        no_time = False
        update_time_later = True
        try:
            # Get time from RTC module
            rtc.init(clock.get_time())
            # RTC module is not calibrated
            if rtc.now()[0] < 2019 or rtc.now()[0] >= 2100:
                # Get time and calibrate RTC module via GPS
                if gps_on:
                    if GpsSIM28.get_time(rtc, logger):
                        update_time_later = False
                    else:  # No way of getting time
                        logger.exception("Failed to get current time from GPS")
                        no_time = True  # navigate to configurations with yellow LED
                # Calibrate RTC module via WiFi Configurations and then reboot
                else:
                    logger.critical("Visit configurations page and press submit to set the RTC module")
                    no_time = True
        # RTC module is not available
        except Exception as e:
            logger.exception("Failed to get time from RTC module")
            # Get time via GPS
            if gps_on:
                if GpsSIM28.get_time(rtc, logger):
                    update_time_later = False
                else:  # No way of getting time
                    logger.exception("Failed to get current time from GPS")
                    no_time = True  # navigate to configurations with yellow LED
            else:  # No way of getting time
                no_time = True  # navigate to configurations with yellow LED

        if no_time:
            logger.info("""Failed to get UTC timestamp from both RTC and GPS modules.
                        User has to connect and configure the device with GPS or RTC connected.
                        Device will reboot in 3 minutes unless button is pressed for 3 seconds and device is configured.
                        
                        Possible issues and solutions:
                        RTC module is not connected - connect an RTC module and/or connect a GPS and enable its operation
                        GPS module is not connected - connect a GPS and enable its operation and/or connect an RTC module
                        RTC is not calibrated - simply press submit on configurations page
                        GPS is connected but not enabled - enable GPS on configurations page
                        GPS is enabled but not connected - connect a GPS module or have an RTC module connected and 
                            disable GPS on configurations page
                        GPS timeout - put device under clear sky and/or increase GPS timeout in configurations""")
        elif gps_on:
            pycom.rgbled(0x552000)  # flash orange until its loaded

        return no_time, update_time_later


    def initialise_pm_sensor(self, sensor_name, pins, serial_id, status_logger):
        """

        :param sensor_name: PM1 or PM2
        :type sensor_name: str
        :param pins: pins for serial bus (TX, RX)
        :type pins: tuple(int, int)
        :param serial_id: id for serial bus (0, 1 or 2)
        :type serial_id: int
        :param status_logger: status logger
        :type status_logger: LoggerFactory object
        """
        try:
            # Start PM sensor thread
            _thread.start_new_thread(pm_thread, (sensor_name, status_logger, pins, serial_id))

            status_logger.info("Sensor " + sensor_name + " initialised")
        except Exception as e:
            status_logger.exception("Failed to initialise sensor " + sensor_name)


    def initialise_file_system(self):
        """
        Create directories for logging, processing, archive, and sending data if they do not exist.
        """
        # Create directories in /sd/
        for directory in s.filesystem_dirs:
            if directory not in os.listdir(s.root_path):
                os.mkdir(s.root_path + directory)

        # Create Averages directory in /sd/Archive/ directory
        if s.archive_averages not in os.listdir(s.root_path + s.archive):
            os.mkdir(s.archive_path + s.archive_averages)


    def remove_residual_files(self):
        """
        Removes residual files from the last boot in the current and processing dirs
        """
        for path in [s.current_path, s.processing_path]:
            for file in os.listdir(path[:-1]):  # Strip '/' from the end of path
                if file != s.lora_file_name:
                    os.remove(path + file)


    def get_logging_level(self):
        """
        Get logging level from configurations
        :return: logging level
        :rtype: str
        """
        logging_lvl = Configuration(self.logger).get_config("logging_lvl")
        if logging_lvl == "Critical":
            return CRITICAL
        elif logging_lvl == "Error":
            return ERROR
        elif logging_lvl == "Warning":
            return WARNING
        elif logging_lvl == "Info":
            return INFO
        elif logging_lvl == "Debug":
            return DEBUG
        #TODO: just use this in the config! dont translate

01d109f4d1e8b82e8f84609c6fbdd22ad194252a

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://pyonair.org/PyonAir-pycom/ (error sending request for url (http://www.pyonair.com/): error trying to connect: dns error: failed to lookup address information: Name or service not known)

Full Github Actions output

be careful with read and substring -- check for []

be careful with read and substring -- check for []

#TODO: be careful with read and substring -- check for []

            while True:
                # data_in = '$GPGGA,085259.000,5056.1384,N,00123.1522,W,1,8,1.17,25.1,M,47.6,M,,*7D\r\n'
                data_in = (str(serial.readline()))[1:]
                #TODO: be careful with read and substring -- check for []

                if (int(chrono.read()) - com_counter) >= 10:
                    gps_deinit(serial, self.logger, message, indicator_led)
                    self.logger.error("GPS enabled, but not connected")
                    return False

                if data_in[1:4] != "$GP":

53999c1350140e8e9b9b407426d65dec06b7d3c7

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://www.pyonair.org/ (error sending request for url (https://www.pyonair.org/): error trying to connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:../ssl/statem/statem_clnt.c:1915: (Hostname mismatch))

Full Github Actions output

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://pyonair.org/PyonAir-pycom/ (error sending request for url (https://www.pyonair.org/PyonAir-pycom/): error trying to connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:../ssl/statem/statem_clnt.c:1915: (Hostname mismatch))

Full Github Actions output

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://www.pyonair.org/ (error sending request for url (https://www.pyonair.org/): error trying to connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:../ssl/statem/statem_clnt.c:1915: (Hostname mismatch))

Full Github Actions output

delete init object?

delete init object?

#TODO: delete init object?

        status_logger.info("Starting GPS thread...")
        _thread.start_new_thread(GpsSIM28.SetRTCtime, (rtc, status_logger))

    #TODO:  delete init object?
except Exception as e:
    status_logger.exception("Exception in the main")
    led_lock.acquire()

c44f7d95dc26a0ec8129f712dc8f31ee04e7bc55

just use this in the config! dont translate

just use this in the config! dont translate

https://github.com/pyonair/PyonAir-pycom/blob/8ba5b86f781a01c9b95443788c6f43ff070cbde6/code/lib/initialisation.py#L144

                    os.remove(path + file)


    # def get_logging_level(self):
    #     """
    #     Get logging level from configurations
    #     :return: logging level
    #     :rtype: str
    #     """
    #     logging_lvl = Configuration(self.logger).get_config("logging_lvl")
    #     if logging_lvl == "Critical":
    #         return CRITICAL
    #     elif logging_lvl == "Error":
    #         return ERROR
    #     elif logging_lvl == "Warning":
    #         return WARNING
    #     elif logging_lvl == "Info":
    #         return INFO
    #     elif logging_lvl == "Debug":
    #         return DEBUG
    #     #TODO: just use this in the config! dont translate

0a6daac481155a5bb9f84b196d1922e9cc570b09

Error catch , set led for no SD card

Error catch , set led for no SD card

#TODO: Error catch , set led for no SD card

from _pybytes_config import PybytesConfig
from machine import RTC, unique_id
from machine import SD, Pin, reset
import network # Used to disable WiFi
from initialisation import initialisation #initialise_time # TODO: clunky refactor
from helper import blink_led

import loggingpycom 
from LoggerFactory import LoggerFactory

from UserButton import UserButton

from Constants import *


#===================Disable default wifi===================

try:
    wlan = network.WLAN()
    wlan.deinit()
except Exception as e:
    print("Unable to disable WiFi")

#===============LED
pycom.heartbeat(False)  # disable the heartbeat LED
pycom.rgbled(0x552000)  # flash orange to indicate startup


#=========================Mount SD card=======
try:
    sd = SD()
    os.mount(sd, '/sd')
    #TODO: Error catch , set led for no SD card
except Exception as e:
    print("SD did not mount")


#===================Get a logger up and running asap!
logger_factory = LoggerFactory()
#TODO: Set log level to level in config file
status_logger = logger_factory.create_status_logger(DEFAULT_LOG_NAME, level=loggingpycom.DEBUG, terminal_out=True,
                                                        filename=LOG_FILENAME)
status_logger.warning("Rebooted")


#======================== Setup user interupt button
user_button = UserButton(status_logger)
pin_14 = Pin("P14", mode=Pin.IN, pull=Pin.PULL_DOWN)
pin_14.callback(Pin.IRQ_RISING | Pin.IRQ_FALLING, user_button.button_handler)





#TODO: provision if key on sd card

#set connect to false in config file?

#========Pybytes
pycom.nvs_set('pybytes_debug',99 ) #0 warning - 99 all
Pybytes.update_config('pybytes_autostart', False, permanent=True, silent=False, reconnect=False)
#pdb.set_trace()
pycom.pybytes_on_boot(False)
conf = PybytesConfig().read_config()
print("CONFIG:  ")

2355e3c5c520a6c98eb76d9663f3c56879796501

Averge calculation causes core dump

Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400989ef PS : 0x00060033 A0 : 0x800962f7 A1 : 0x3ffe2300
A2 : 0x3ffbc548 A3 : 0x00060020 A4 : 0x3ffd661c A5 : 0x00000001
A6 : 0x000000fe A7 : 0x00000001 A8 : 0x00000000 A9 : 0x3ffc5684
A10 : 0x3ffc5684 A11 : 0x00000000 A12 : 0x3ffd661c A13 : 0x00000001
A14 : 0x000000fe A15 : 0x3ffc56e8 SAR : 0x00000002 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000004 LBEG : 0x4009d8f0 LEND : 0x4009d91e LCOUNT : 0xffffffff

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://www.pyonair.org/ (error sending request for url (https://www.pyonair.org/): error trying to connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:../ssl/statem/statem_clnt.c:1915: (Hostname mismatch))

Full Github Actions output

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://pyonair.org/PyonAir-pycom/ (error sending request for url (https://pyonair.org/PyonAir-pycom/): error trying to connect: dns error: failed to lookup address information: No address associated with hostname)

Full Github Actions output

Link Checker Report

Errors were reported while checking the availability of links.


๐Ÿ“ Summary
---------------------
๐Ÿ” Total...........12
โœ… Successful......11
โณ Timeouts.........0
๐Ÿ”€ Redirected.......0
๐Ÿ‘ป Excluded.........0
๐Ÿšซ Errors...........1

Errors in README.md
โœ— https://pyonair.org/PyonAir-pycom/ (error sending request for url (https://www.pyonair.org/PyonAir-pycom/): error trying to connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:../ssl/statem/statem_clnt.c:1915: (Hostname mismatch))

Full Github Actions output

get rid of thsi config page -- pybytes all the way

get rid of thsi config page -- pybytes all the way

#TODO: get rid of thsi config page -- pybytes all the way

#from  
import Configuration
import strings as s


#TODO: get rid of thsi config page -- pybytes all the way

def get_html_form():
    """
    Constructs a webpage that includes a form to fill in by the user to acquire new configurations for the device

08434f16c5a816b42706d290255e767c85194db9

why is this like this, why not sleep for init_time -- do i need to clear the ser...

why is this like this, why not sleep for init_time -- do i need to clear the serial buffer?

warm up time - readings are not logged

#TODO: why is this like this, why not sleep for init_time -- do i need to clear the serial buffer?

        sensor = Plantower(pins=pins, id=serial_id)

        time.sleep(1)
        #TODO: why is this like this, why not sleep for init_time -- do i need to clear the serial buffer?
        # warm up time  - readings are not logged
        while init_count < init_time:
            try:

8be48e0b37b5d256e955c06be8537d52dcef294b

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.