Skip to content

Commit

Permalink
Merge pull request #34 from adafruit/REUSE
Browse files Browse the repository at this point in the history
Ran pre-commit, added licenses
  • Loading branch information
FoamyGuy committed Jan 17, 2021
2 parents 1b1d4d9 + eab6103 commit 69b1af2
Show file tree
Hide file tree
Showing 26 changed files with 634 additions and 149 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense

__pycache__
_build
*.pyc
Expand All @@ -8,4 +12,4 @@ bundles
*.DS_Store
.eggs
dist
**/*.egg-info
**/*.egg-info
4 changes: 4 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense

[MASTER]

# A comma-separated list of package or module names from where C extensions may
Expand Down
4 changes: 4 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense

python:
version: 3
requirements_file: requirements.txt
14 changes: 10 additions & 4 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!--
SPDX-FileCopyrightText: 2014 Coraline Ada Ehmke
SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries
SPDX-License-Identifier: CC-BY-4.0
-->

# Adafruit Community Code of Conduct

## Our Pledge
Expand Down Expand Up @@ -43,7 +49,7 @@ Examples of unacceptable behavior by participants include:

The goal of the standards and moderation guidelines outlined here is to build
and maintain a respectful community. We ask that you don’t just aim to be
"technically unimpeachable", but rather try to be your best self.
"technically unimpeachable", but rather try to be your best self.

We value many things beyond technical expertise, including collaboration and
supporting others within our community. Providing a positive experience for
Expand Down Expand Up @@ -74,9 +80,9 @@ You may report in the following ways:
In any situation, you may send an email to <support@adafruit.com>.

On the Adafruit Discord, you may send an open message from any channel
to all Community Moderators by tagging @community moderators. You may
also send an open message from any channel, or a direct message to
@kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442,
to all Community Moderators by tagging @community moderators. You may
also send an open message from any channel, or a direct message to
@kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442,
@sommersoft#0222, @Mr. Certainly#0472 or @Andon#8175.

Email and direct message reports will be kept confidential.
Expand Down
324 changes: 324 additions & 0 deletions LICENSES/CC-BY-4.0.txt

Large diffs are not rendered by default.

170 changes: 170 additions & 0 deletions LICENSES/GPL-3.0-or-later.txt

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions LICENSES/MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
MIT License Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 changes: 20 additions & 0 deletions LICENSES/Unlicense.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute
this software, either in source code form or as a compiled binary, for any
purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and
to the detriment of our heirs and successors. We intend this dedication to
be an overt act of relinquishment in perpetuity of all present and future
rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information,
please refer to <https://unlicense.org/>
3 changes: 3 additions & 0 deletions README.rst.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries

SPDX-License-Identifier: MIT
4 changes: 4 additions & 0 deletions adafruit_tinylora/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""This file is included to prevent pylint
failing with the following error: no-name-in-module.
note: revisit/remove this file when this pylint error has been resolved.
Expand Down
55 changes: 18 additions & 37 deletions adafruit_tinylora/adafruit_tinylora.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
# Copyright 2015, 2016 Ideetron B.V.
# SPDX-FileCopyrightText: 2015-2016 Ideetron B.V.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# Modified by Brent Rubell for Adafruit Industries.
# SPDX-License-Identifier: GPL-3.0-or-later

"""
`Adafruit_TinyLoRa`
====================================================
Expand Down Expand Up @@ -81,8 +68,7 @@


class TTN:
"""TTN Class
"""
"""TTN Class"""

def __init__(self, dev_address, net_key, app_key, country="US"):
"""Interface for TheThingsNetwork
Expand All @@ -98,33 +84,28 @@ def __init__(self, dev_address, net_key, app_key, country="US"):

@property
def country(self):
"""Returns the TTN Frequency Country.
"""
"""Returns the TTN Frequency Country."""
return self.region

@property
def device_address(self):
"""Returns the TTN Device Address.
"""
"""Returns the TTN Device Address."""
return self.dev_addr

@property
def application_key(self):
"""Returns the TTN Application Key.
"""
"""Returns the TTN Application Key."""
return self.app_key

@property
def network_key(self):
"""Returns the TTN Network Key.
"""
"""Returns the TTN Network Key."""
return self.net_key


# pylint: disable=too-many-instance-attributes
class TinyLoRa:
"""TinyLoRa Interface
"""
"""TinyLoRa Interface"""

# SPI Write Buffer
_BUFFER = bytearray(2)
Expand Down Expand Up @@ -237,10 +218,10 @@ def deinit(self):

def send_data(self, data, data_length, frame_counter, timeout=2):
"""Function to assemble and send data
:param data: data to send
:param data_length: length of data to send
:param frame_counter: frame counter variable, declared in code.py.
:param timeout: TxDone wait time, default is 2.
:param data: data to send
:param data_length: length of data to send
:param frame_counter: frame counter variable, declared in code.py.
:param timeout: TxDone wait time, default is 2.
"""
# data packet
enc_data = bytearray(data_length)
Expand Down Expand Up @@ -283,9 +264,9 @@ def send_data(self, data, data_length, frame_counter, timeout=2):

def send_packet(self, lora_packet, packet_length, timeout):
"""Sends a LoRa packet using the RFM Module
:param bytearray lora_packet: assembled LoRa packet from send_data
:param int packet_length: length of LoRa packet to send
:param int timeout: TxDone wait time.
:param bytearray lora_packet: assembled LoRa packet from send_data
:param int packet_length: length of LoRa packet to send
:param int timeout: TxDone wait time.
"""
# Set RFM to standby
self._write_u8(_MODE_STDBY, 0x81)
Expand Down Expand Up @@ -342,8 +323,8 @@ def set_datarate(self, datarate):
}
try:
self._sf, self._bw, self._modemcfg = data_rates[datarate]
except KeyError:
raise KeyError("Invalid or Unsupported Datarate.")
except KeyError as err:
raise KeyError("Invalid or Unsupported Datarate.") from err

def set_channel(self, channel):
"""Sets the RFM Channel (if single-channel)
Expand Down
35 changes: 8 additions & 27 deletions adafruit_tinylora/adafruit_tinylora_encryption.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
# AES-Python, Copyright (C) 2012 Bo Zhu http://about.bozhu.me
# SPDX-FileCopyrightText: 2012 Bo Zhu
# SPDX-FileCopyrightText: Brent Rubell for Adafruit Industries
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
# Modified by Brent Rubell for Adafruit Industries
# SPDX-License-Identifier: MIT

"""
`adafruit_tinylora_encryption.py`
======================================================
Expand All @@ -28,8 +12,7 @@
"""
# from http://cs.ucsb.edu/~koc/cs178/projects/JT/aes.c
def xtime(col):
"""xtime impl. for _mix_single_column()
"""
"""xtime impl. for _mix_single_column()"""
return (((col << 1) ^ 0x1B) & 0xFF) if (col & 0x80) else (col << 1)


Expand Down Expand Up @@ -263,8 +246,7 @@ def _aes_shift_rows(arr):
)

def calculate_mic(self, lora_packet, lora_packet_length, mic):
"""Calculates the validity of data messages, generates a message integrity check bytearray.
"""
"""Calculates the validity of data messages, generates message integrity check bytearray."""
block_b = bytearray(16)
key_k1 = bytearray(16)
key_k2 = bytearray(16)
Expand Down Expand Up @@ -363,8 +345,7 @@ def _mic_generate_keys(self, key_1, key_2):

@staticmethod
def _shift_left(data):
""" Shifts data bytearray left by 1
"""
"""Shifts data bytearray left by 1"""
for i in range(16):
if i < 15:
if (data[i + 1] & 0x80) == 0x80:
Expand All @@ -378,7 +359,7 @@ def _shift_left(data):

@staticmethod
def _xor_data(new_data, old_data):
""" XOR two data arrays
"""XOR two data arrays
:param bytearray new_data: Calculated data.
:param bytearray old_data: data to be xor'd.
"""
Expand Down
23 changes: 3 additions & 20 deletions adafruit_tinylora/ttn_as.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
# The MIT License (MIT)
# SPDX-FileCopyrightText: 2018 Brent Rubell for Adafruit Industries
#
# Copyright (c) 2018 Brent Rubell for Adafruit
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# SPDX-License-Identifier: MIT

"""
`ttn_as.py`
======================================================
Expand Down
23 changes: 3 additions & 20 deletions adafruit_tinylora/ttn_au.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
# The MIT License (MIT)
# SPDX-FileCopyrightText: 2018 Brent Rubell for Adafruit Industries
#
# Copyright (c) 2018 Brent Rubell for Adafruit
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# SPDX-License-Identifier: MIT

"""
`ttn_au.py`
======================================================
Expand Down
23 changes: 3 additions & 20 deletions adafruit_tinylora/ttn_eu.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
# The MIT License (MIT)
# SPDX-FileCopyrightText: 2018 Brent Rubell for Adafruit Industries
#
# Copyright (c) 2018 Brent Rubell for Adafruit
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# SPDX-License-Identifier: MIT

"""
`ttn_eu.py`
======================================================
Expand Down

0 comments on commit 69b1af2

Please sign in to comment.