Skip to content

ran pre-commit, added licenses #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2020 ladyada for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense

__pycache__
_build
*.pyc
Expand Down
4 changes: 4 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2020 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: 2020 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.

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
39 changes: 11 additions & 28 deletions adafruit_ble/__init__.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
# The MIT License (MIT)
# SPDX-FileCopyrightText: 2019 Dan Halbert for Adafruit Industries
# SPDX-FileCopyrightText: 2019 Scott Shawcroft for Adafruit Industries
#
# Copyright (c) 2019 Dan Halbert for Adafruit Industries
# Copyright (c) 2019 Scott Shawcroft 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.
# SPDX-License-Identifier: MIT

"""

This module provides higher-level BLE (Bluetooth Low Energy) functionality,
Expand Down Expand Up @@ -125,13 +108,13 @@ def paired(self):
@property
def connection_interval(self):
"""Time between transmissions in milliseconds. Will be multiple of 1.25ms. Lower numbers
increase speed and decrease latency but increase power consumption.
increase speed and decrease latency but increase power consumption.

When setting connection_interval, the peer may reject the new interval and
`connection_interval` will then remain the same.
When setting connection_interval, the peer may reject the new interval and
`connection_interval` will then remain the same.

Apple has additional guidelines that dictate should be a multiple of 15ms except if HID
is available. When HID is available Apple devices may accept 11.25ms intervals."""
Apple has additional guidelines that dictate should be a multiple of 15ms except if HID
is available. When HID is available Apple devices may accept 11.25ms intervals."""
return self._bleio_connection.connection_interval

@connection_interval.setter
Expand Down Expand Up @@ -289,8 +272,8 @@ def start_scan(
def stop_scan(self):
"""Stops any active scan.

The scan results iterator will return any buffered results and then raise StopIteration
once empty."""
The scan results iterator will return any buffered results and then raise StopIteration
once empty."""
self._adapter.stop_scan()

def connect(self, advertisement, *, timeout=4.0):
Expand Down
33 changes: 8 additions & 25 deletions adafruit_ble/advertising/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
# The MIT License (MIT)
# SPDX-FileCopyrightText: 2018 Dan Halbert for Adafruit Industries
#
# Copyright (c) 2018 Dan Halbert 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.
# SPDX-License-Identifier: MIT

"""
Advertising is the first phase of BLE where devices can broadcast
"""
Expand All @@ -38,7 +21,7 @@ def to_bytes_literal(seq):

def decode_data(data, *, key_encoding="B"):
"""Helper which decodes length encoded structures into a dictionary with the given key
encoding."""
encoding."""
i = 0
data_dict = {}
key_size = struct.calcsize(key_encoding)
Expand Down Expand Up @@ -73,7 +56,7 @@ def compute_length(data_dict, *, key_encoding="B"):

def encode_data(data_dict, *, key_encoding="B"):
"""Helper which encodes dictionaries into length encoded structures with the given key
encoding."""
encoding."""
length = compute_length(data_dict, key_encoding=key_encoding)
data = bytearray(length)
key_size = struct.calcsize(key_encoding)
Expand Down Expand Up @@ -151,7 +134,7 @@ def __str__(self):
class String(AdvertisingDataField):
"""UTF-8 encoded string in an Advertisement.

Not null terminated once encoded because length is always transmitted."""
Not null terminated once encoded because length is always transmitted."""

def __init__(self, *, advertising_data_type):
self._adt = advertising_data_type
Expand Down Expand Up @@ -265,7 +248,7 @@ def __init__(self):
@classmethod
def from_entry(cls, entry):
"""Create an Advertisement based on the given ScanEntry. This is done automatically by
`BLERadio` for all scan results."""
`BLERadio` for all scan results."""
self = cls()
# If data_dict is available, use it directly. Otherwise decode the bytestring.
if hasattr(entry, "data_dict"):
Expand All @@ -282,7 +265,7 @@ def from_entry(cls, entry):
@property
def rssi(self):
"""Signal strength of the scanned advertisement. Only available on Advertisements returned
from `BLERadio.start_scan()`. (read-only)"""
from `BLERadio.start_scan()`. (read-only)"""
return self._rssi

@classmethod
Expand Down
23 changes: 3 additions & 20 deletions adafruit_ble/advertising/adafruit.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
# The MIT License (MIT)
# SPDX-FileCopyrightText: 2019 Scott Shawcroft for Adafruit Industries
#
# Copyright (c) 2019 Scott Shawcroft 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.
# SPDX-License-Identifier: MIT

"""
`adafruit`
====================================================
Expand Down
4 changes: 4 additions & 0 deletions adafruit_ble/advertising/apple.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2020 ladyada for Adafruit Industries
#
# SPDX-License-Identifier: MIT

# class iBeacon(Advertisement):
# # Apple manufacturer data with subtype 2
# match_prefixes = (b"\xff\x00\x4c\x02",)
Expand Down
33 changes: 8 additions & 25 deletions adafruit_ble/advertising/standard.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
# The MIT License (MIT)
# SPDX-FileCopyrightText: 2019 Scott Shawcroft for Adafruit Industries
#
# Copyright (c) 2019 Scott Shawcroft 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.
# SPDX-License-Identifier: MIT

"""
:py:mod:`~adafruit_ble.advertising.standard`
====================================================
Expand Down Expand Up @@ -211,10 +194,10 @@ def __init__(self, *services):

class ManufacturerData(AdvertisingDataField):
"""Encapsulates manufacturer specific keyed data bytes. The manufacturer is identified by the
company_id and the data is structured like an advertisement with a configurable key
format. The order of the serialized data is determined by the order that the
`ManufacturerDataField` attributes are set in - this can be useful for
`match_prefixes` in an `Advertisement` sub-class."""
company_id and the data is structured like an advertisement with a configurable key
format. The order of the serialized data is determined by the order that the
`ManufacturerDataField` attributes are set in - this can be useful for
`match_prefixes` in an `Advertisement` sub-class."""

def __init__(
self, obj, *, advertising_data_type=0xFF, company_id, key_encoding="B"
Expand Down Expand Up @@ -313,7 +296,7 @@ def __set__(self, obj, value):

class ServiceData(AdvertisingDataField):
"""Encapsulates service data. It is read as a memoryview which can be manipulated or set as a
bytearray to change the size."""
bytearray to change the size."""

def __init__(self, service):
if isinstance(service.uuid, StandardUUID):
Expand Down
52 changes: 17 additions & 35 deletions adafruit_ble/attributes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
# The MIT License (MIT)
# SPDX-FileCopyrightText: 2019 Dan Halbert for Adafruit Industries
#
# Copyright (c) 2019 Dan Halbert 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.
# SPDX-License-Identifier: MIT

"""
:py:mod:`~adafruit_ble.attributes`
====================================================
Expand All @@ -36,34 +19,33 @@
class Attribute:
"""Constants describing security levels.

.. data:: NO_ACCESS
.. data:: NO_ACCESS

security mode: access not allowed
security mode: access not allowed

.. data:: OPEN
.. data:: OPEN

security_mode: no security (link is not encrypted)
security_mode: no security (link is not encrypted)

.. data:: ENCRYPT_NO_MITM
.. data:: ENCRYPT_NO_MITM

security_mode: unauthenticated encryption, without man-in-the-middle protection
security_mode: unauthenticated encryption, without man-in-the-middle protection

.. data:: ENCRYPT_WITH_MITM
.. data:: ENCRYPT_WITH_MITM

security_mode: authenticated encryption, with man-in-the-middle protection
security_mode: authenticated encryption, with man-in-the-middle protection

.. data:: LESC_ENCRYPT_WITH_MITM
.. data:: LESC_ENCRYPT_WITH_MITM

security_mode: LESC encryption, with man-in-the-middle protection
security_mode: LESC encryption, with man-in-the-middle protection

.. data:: SIGNED_NO_MITM
.. data:: SIGNED_NO_MITM

security_mode: unauthenticated data signing, without man-in-the-middle protection
security_mode: unauthenticated data signing, without man-in-the-middle protection

.. data:: SIGNED_WITH_MITM
.. data:: SIGNED_WITH_MITM

security_mode: authenticated data signing, without man-in-the-middle protection
"""
security_mode: authenticated data signing, without man-in-the-middle protection"""

# pylint: disable=too-few-public-methods
NO_ACCESS = _bleio.Attribute.NO_ACCESS
Expand Down
Loading