mirror of https://github.com/cmur2/miflorad.git
Compare commits
91 Commits
Author | SHA1 | Date |
---|---|---|
dependabot[bot] | 0515e78ab5 | |
renovate[bot] | cf47a5d77a | |
renovate[bot] | 7670aeb280 | |
dependabot[bot] | e17644b015 | |
renovate[bot] | 451b9544e1 | |
renovate[bot] | 4b16705cdb | |
renovate[bot] | 82f2ca35af | |
renovate[bot] | 065c578982 | |
renovate[bot] | 391baa4d06 | |
renovate[bot] | 7cb36807ef | |
cn | 4fce9d222e | |
Christian Nicolai | 36d6563db0 | |
cn | 0089a3dd2c | |
renovate[bot] | d5020103f3 | |
renovate[bot] | 1ee6adbf42 | |
renovate[bot] | 15c187f3d8 | |
Renovate Bot | 4a635752d8 | |
Renovate Bot | 2e9361ceea | |
Christian Nicolai | fcc9cd18e7 | |
Renovate Bot | 36cb063a42 | |
Renovate Bot | 9781213858 | |
Christian Nicolai | 21f139d3cc | |
cn | 72c4c94cb7 | |
dependabot[bot] | 0268126d70 | |
cn | 23c2371649 | |
dependabot[bot] | fb076d3a66 | |
dependabot[bot] | 717496be57 | |
cn | f995734bc9 | |
dependabot[bot] | e8c1b0b37e | |
dependabot[bot] | 5530c139f4 | |
dependabot[bot] | 092f2c747c | |
dependabot[bot] | fb5b12df53 | |
dependabot[bot] | f05b4e8105 | |
cn | 5508b0dff3 | |
cn | a6d6a14149 | |
cn | ecab1a41f5 | |
cn | 1a0a661fab | |
dependabot[bot] | 898dcfed50 | |
dependabot[bot] | a7c8b40a4c | |
dependabot-preview[bot] | 40e165a045 | |
dependabot-preview[bot] | 29d172d3e0 | |
cn | 4ce572c0f6 | |
cn | c20f510c8c | |
Renovate Bot | 4b00f1ed0e | |
cn | ba77404d7f | |
renovate[bot] | 1bbaa6f6e1 | |
renovate[bot] | e91aa7be92 | |
cn | 97164bc4b8 | |
renovate[bot] | 9e0f892b23 | |
renovate[bot] | b5d9a412b2 | |
cn | 72e47578bb | |
renovate[bot] | 22f796f22a | |
renovate[bot] | 161f07ed5b | |
cn | 86ae169404 | |
renovate[bot] | b848e814e3 | |
cn | 143dc374cf | |
cn | 0595d76f00 | |
renovate[bot] | cbe0bd62ae | |
renovate[bot] | 3e30b6fcc1 | |
renovate[bot] | bb849059d0 | |
renovate[bot] | 42b16dbae1 | |
cn | 9c1f76fbc4 | |
cn | d241c8c6be | |
cn | 4531a05af3 | |
cn | f74628e2e4 | |
renovate[bot] | d2964bfde2 | |
renovate[bot] | d467e80126 | |
renovate[bot] | 0ad3fdf9f5 | |
renovate[bot] | 32d0daa0bb | |
renovate[bot] | 16cae91017 | |
renovate[bot] | d46ba7c1b3 | |
renovate[bot] | dbae6940bf | |
renovate[bot] | 702e38766c | |
renovate[bot] | a458e784a9 | |
cn | befef9d063 | |
renovate[bot] | 388aff5252 | |
renovate[bot] | a3b3ad0702 | |
cn | c036ea0f73 | |
cn | 73a9fdf0d4 | |
renovate[bot] | 8f918ce825 | |
renovate[bot] | 3b8614e9b4 | |
renovate[bot] | aa4d9c0044 | |
renovate[bot] | b8bdbf2643 | |
renovate[bot] | 2d6c4db1d2 | |
renovate[bot] | fad9f951ec | |
renovate[bot] | 88c3052751 | |
renovate[bot] | bf21c4f0ab | |
renovate[bot] | 362aca19f3 | |
cn | d970deddb7 | |
cn | 6e08af6fa0 | |
cn | 4f265b76a8 |
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "actionlint",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
"message": 4,
|
||||
"code": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
extends: [
|
||||
"config:base",
|
||||
":dependencyDashboard",
|
||||
":prHourlyLimitNone",
|
||||
":prConcurrentLimitNone",
|
||||
":label(dependency-upgrade)",
|
||||
],
|
||||
schedule: ["before 8am on thursday"],
|
||||
branchPrefix: "renovate-",
|
||||
dependencyDashboardHeader: "View repository job log [here](https://app.renovatebot.com/dashboard#github/cmur2/miflorad).",
|
||||
separateMinorPatch: true,
|
||||
commitMessagePrefix: "module: ",
|
||||
commitMessageAction: "update",
|
||||
commitMessageTopic: "{{depName}}",
|
||||
commitMessageExtra: "to {{#if isSingleVersion}}v{{{newVersion}}}{{else}}{{{newValue}}}{{/if}}",
|
||||
packageRules: [
|
||||
// Commit message formats
|
||||
{
|
||||
matchManagers: ["github-actions"],
|
||||
commitMessagePrefix: "ci: ",
|
||||
},
|
||||
// less noisy updates
|
||||
{
|
||||
packageNames: [
|
||||
"github.com/currantlabs/gatt",
|
||||
"github.com/muka/ble",
|
||||
"github.com/muka/go-bluetooth",
|
||||
],
|
||||
extends: ["schedule:weekly"],
|
||||
},
|
||||
{
|
||||
packageNames: [
|
||||
"github.com/coreos/go-systemd",
|
||||
"github.com/mgutz/ansi",
|
||||
"github.com/mgutz/logxi",
|
||||
"golang.org/x/net",
|
||||
],
|
||||
extends: ["schedule:monthly"],
|
||||
},
|
||||
],
|
||||
regexManagers: [],
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
---
|
||||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
schedule:
|
||||
- cron: '3 4 * * 4' # weekly on thursday morning
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go:
|
||||
- '1.19'
|
||||
- '1.20'
|
||||
fail-fast: false
|
||||
env:
|
||||
GO111MODULE: on
|
||||
GOPROXY: direct
|
||||
GOSUMDB: off
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Go ${{ matrix.go }}
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
- name: Build
|
||||
run: |
|
||||
make
|
||||
|
||||
actionlint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Check workflow files
|
||||
run: |
|
||||
echo "::add-matcher::.github/actionlint-matcher.json"
|
||||
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
|
||||
./actionlint
|
|
@ -2,3 +2,4 @@
|
|||
cmd/miflorad/miflorad
|
||||
cmd/munin-miflora/munin-miflora
|
||||
cmd/munin-miflora-gatt/munin-miflora-gatt
|
||||
pkg/miflorad-*
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
github-release 1.0
|
|
@ -1,9 +0,0 @@
|
|||
---
|
||||
sudo: false
|
||||
language: go
|
||||
go:
|
||||
- "1.11.x"
|
||||
- master
|
||||
|
||||
env:
|
||||
- GO111MODULE=on
|
|
@ -0,0 +1,187 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
58
Makefile
58
Makefile
|
@ -1,4 +1,13 @@
|
|||
.POSIX:
|
||||
|
||||
# https://tech.davis-hansson.com/p/make/
|
||||
SHELL := bash
|
||||
.ONESHELL:
|
||||
.SHELLFLAGS := -eux -o pipefail -c
|
||||
.DELETE_ON_ERROR:
|
||||
.SILENT:
|
||||
.DEFAULT_GOAL := all
|
||||
MAKEFLAGS += --warn-undefined-variables
|
||||
MAKEFLAGS += --no-builtin-rules
|
||||
|
||||
MIFLORA_ADDR?=00:00:00:00:00:00
|
||||
MIFLORAD_VERSION?=master
|
||||
|
@ -7,41 +16,64 @@ RUN_COMMAND=miflorad
|
|||
RUN_OPTIONS=$(MIFLORA_ADDR)
|
||||
|
||||
.PHONY: all
|
||||
all: clean build test
|
||||
all: clean build test ## Run clean, build and test (default goal)
|
||||
|
||||
.PHONY: run
|
||||
run: clean build test
|
||||
run: clean build test ## Run clean, build, test and finally launch the $RUN_COMMAND as root
|
||||
sudo cmd/$(RUN_COMMAND)/$(RUN_COMMAND) $(RUN_OPTIONS)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
clean: ## Remove all produced executables
|
||||
rm -f cmd/miflorad/miflorad
|
||||
rm -f cmd/munin-miflora/munin-miflora
|
||||
rm -f cmd/munin-miflora-gatt/munin-miflora-gatt
|
||||
|
||||
.PHONY: build
|
||||
build: cmd/miflorad/miflorad cmd/munin-miflora/munin-miflora cmd/munin-miflora-gatt/munin-miflora-gatt
|
||||
build: cmd/miflorad/miflorad cmd/munin-miflora/munin-miflora cmd/munin-miflora-gatt/munin-miflora-gatt ## Build all produced executables
|
||||
|
||||
.PHONY: test
|
||||
test: build
|
||||
cd cmd/miflorad && go test -v -race && cd ../..
|
||||
cd common && go test -v -race && cd ..
|
||||
test: build ## Run all tests
|
||||
pushd cmd/miflorad
|
||||
go test -v -race
|
||||
popd
|
||||
pushd common
|
||||
go test -v -race
|
||||
popd
|
||||
|
||||
.PHONY: remote-run
|
||||
remote-run: clean
|
||||
cd cmd/$(RUN_COMMAND) && CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags="-s -w" && cd ../..
|
||||
remote-run: clean ## Run clean, build $RUN_COMMAND for Linux on ARM and launch it via SSH on extzero
|
||||
pushd cmd/$(RUN_COMMAND)
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags="-s -w"
|
||||
popd
|
||||
file cmd/$(RUN_COMMAND)/$(RUN_COMMAND)
|
||||
scp cmd/$(RUN_COMMAND)/$(RUN_COMMAND) extzero:$(RUN_COMMAND)
|
||||
ssh extzero "./$(RUN_COMMAND) $(RUN_OPTIONS)"
|
||||
|
||||
.PHONY: release
|
||||
release: ## Build and upload release version of miflorad to Github
|
||||
mkdir -p pkg
|
||||
pushd cmd/miflorad
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "../../pkg/miflorad-$(MIFLORAD_VERSION)-linux-amd64" -ldflags="-s -w"
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o "../../pkg/miflorad-$(MIFLORAD_VERSION)-linux-arm" -ldflags="-s -w"
|
||||
popd
|
||||
# github-release "v$(MIFLORAD_VERSION)" pkg/miflorad-$(MIFLORAD_VERSION)-* --commit "master" --tag "v$(MIFLORAD_VERSION)" --prerelease --github-repository "cmur2/miflorad"
|
||||
github-release "v$(MIFLORAD_VERSION)" pkg/miflorad-$(MIFLORAD_VERSION)-* --commit "master" --tag "v$(MIFLORAD_VERSION)" --github-repository "cmur2/miflorad"
|
||||
|
||||
.PHONY: cmd/miflorad/miflorad
|
||||
cmd/miflorad/miflorad:
|
||||
cd cmd/miflorad && CGO_ENABLED=0 go build -buildmode=pie -ldflags "-X main.version=$(MIFLORAD_VERSION)" && cd ../..
|
||||
pushd cmd/miflorad
|
||||
CGO_ENABLED=0 go build -buildmode=pie
|
||||
|
||||
.PHONY: cmd/munin-miflora/munin-miflora
|
||||
cmd/munin-miflora/munin-miflora:
|
||||
cd cmd/munin-miflora && CGO_ENABLED=0 go build -buildmode=pie && cd ../..
|
||||
pushd cmd/munin-miflora
|
||||
CGO_ENABLED=0 go build -buildmode=pie
|
||||
|
||||
.PHONY: cmd/munin-miflora-gatt/munin-miflora-gatt
|
||||
cmd/munin-miflora-gatt/munin-miflora-gatt:
|
||||
cd cmd/munin-miflora-gatt && CGO_ENABLED=0 go build -buildmode=pie && cd ../..
|
||||
pushd cmd/munin-miflora-gatt
|
||||
CGO_ENABLED=0 go build -buildmode=pie
|
||||
|
||||
.PHONY: help
|
||||
help: ## Print this help text
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
||||
|
|
19
README.md
19
README.md
|
@ -1,6 +1,6 @@
|
|||
# miflorad
|
||||
|
||||
[![Build Status](https://travis-ci.org/cmur2/miflorad.svg?branch=master)](https://travis-ci.org/cmur2/miflorad)
|
||||
![Build Status](https://github.com/cmur2/miflorad/workflows/ci/badge.svg)
|
||||
|
||||
This project aims to produce tools written in Go for interfacing with Xiaomi Flora sensors for IoT use cases.
|
||||
|
||||
|
@ -48,3 +48,20 @@ handle = 0x0040, char properties = 0x02, char value handle = 0x0041, uuid = 0000
|
|||
|
||||
- [https://wiki.hackerspace.pl/projects:xiaomi-flora](https://wiki.hackerspace.pl/projects:xiaomi-flora) (very nice teardown)
|
||||
- [https://github.com/open-homeautomation/miflora](https://github.com/open-homeautomation/miflora) (python library)
|
||||
|
||||
## Doing a release
|
||||
|
||||
Install the [github-release binary](https://github.com/buildkite/github-release) helper somewhere into your path as `github-release`.
|
||||
|
||||
You also need a [personal access token](https://github.com/settings/tokens) for your Github account.
|
||||
|
||||
The below will create a Github release of `miflorad` based on your current git working copy and create a matching git tag:
|
||||
|
||||
```bash
|
||||
export GITHUB_RELEASE_ACCESS_TOKEN=my-personal-access-token
|
||||
MIFLORAD_VERSION=x.y.z make release
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
miflorad is licensed under the Apache License, Version 2.0. See LICENSE for more information.
|
||||
|
|
|
@ -34,9 +34,9 @@ func TestPublishGraphite(t *testing.T) {
|
|||
case mifloraErrorMetric:
|
||||
for line := range publish {
|
||||
parts := strings.Split(line, " ")
|
||||
assert.Equal(t, len(parts), 3)
|
||||
assert.Equal(t, parts[0], "foo.base.miflora.peri.failed")
|
||||
assert.Equal(t, parts[1], "1")
|
||||
assert.Equal(t, 3, len(parts))
|
||||
assert.Equal(t, "foo.base.miflora.peri.failed", parts[0])
|
||||
assert.Equal(t, "1", parts[1])
|
||||
timestamp, err := strconv.ParseInt(parts[2], 10, 64)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, timestamp >= 0)
|
||||
|
@ -44,8 +44,8 @@ func TestPublishGraphite(t *testing.T) {
|
|||
case mifloraDataMetric:
|
||||
for line := range publish {
|
||||
parts := strings.Split(line, " ")
|
||||
assert.Equal(t, len(parts), 3)
|
||||
assert.Equal(t, strings.Index(parts[0], "foo.base.miflora.peri"), 0)
|
||||
assert.Equal(t, 3, len(parts))
|
||||
assert.Equal(t, 0, strings.Index(parts[0], "foo.base.miflora.peri"))
|
||||
assert.True(t, len(parts[1]) > 0)
|
||||
timestamp, err := strconv.ParseInt(parts[2], 10, 64)
|
||||
assert.NoError(t, err)
|
||||
|
@ -78,17 +78,17 @@ func TestPublishInflux(t *testing.T) {
|
|||
case mifloraErrorMetric:
|
||||
line := <-publish
|
||||
parts := strings.Split(line, " ")
|
||||
assert.Equal(t, len(parts), 3)
|
||||
assert.Equal(t, parts[0], "miflora,id=peri")
|
||||
assert.Equal(t, parts[1], "failed=1")
|
||||
assert.Equal(t, 3, len(parts))
|
||||
assert.Equal(t, "miflora,id=peri", parts[0])
|
||||
assert.Equal(t, "failed=1", parts[1])
|
||||
timestamp, err := strconv.ParseInt(parts[2], 10, 64)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, timestamp >= 0)
|
||||
case mifloraDataMetric:
|
||||
line := <-publish
|
||||
parts := strings.Split(line, " ")
|
||||
assert.Equal(t, len(parts), 3)
|
||||
assert.Equal(t, parts[0], "miflora,id=peri")
|
||||
assert.Equal(t, 3, len(parts))
|
||||
assert.Equal(t, "miflora,id=peri", parts[0])
|
||||
assert.True(t, len(parts[1]) > 0)
|
||||
timestamp, err := strconv.ParseInt(parts[2], 10, 64)
|
||||
assert.NoError(t, err)
|
||||
|
|
|
@ -21,9 +21,6 @@ import (
|
|||
|
||||
const mqttConnectTimeout = 10 * time.Second
|
||||
|
||||
// program version, will be populated on build
|
||||
var version string
|
||||
|
||||
var (
|
||||
scanTimeout = flag.Duration("scantimeout", 10*time.Second, "timeout after that a scan per peripheral will be aborted")
|
||||
readRetries = flag.Int("readretries", 2, "number of times reading will be attempted per peripheral")
|
||||
|
@ -94,21 +91,14 @@ func checkTooShortInterval() error {
|
|||
numPeripherals := int64(len(flag.Args()))
|
||||
numReadRetries := int64(*readRetries)
|
||||
if (*scanTimeout).Nanoseconds()*numReadRetries*numPeripherals >= (*interval).Nanoseconds() {
|
||||
return errors.New(fmt.Sprintf(
|
||||
"The interval of %s is too short given the scan timeout of %s for %d peripheral(s) with %d retries each! Exiting...\n",
|
||||
*interval, *scanTimeout, numPeripherals, *readRetries))
|
||||
return errors.Errorf(
|
||||
"The interval of %s is too short given the scan timeout of %s "+
|
||||
"for %d peripheral(s) with %d retries each! Exiting...\n",
|
||||
*interval, *scanTimeout, numPeripherals, *readRetries)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getVersion() string {
|
||||
if version == "" {
|
||||
return "dev"
|
||||
} else {
|
||||
return version
|
||||
}
|
||||
}
|
||||
|
||||
func getMQTTOptions() *mqtt.ClientOptions {
|
||||
if *brokerUseTLS {
|
||||
return mqtt.NewClientOptions().
|
||||
|
@ -126,7 +116,7 @@ func getMQTTOptions() *mqtt.ClientOptions {
|
|||
func readData(peripheral *peripheral, client ble.Client) (common.SensorDataResponse, error) {
|
||||
// re-request meta data (for battery level) if last check more than 24 hours ago
|
||||
// Source: https://github.com/open-homeautomation/miflora/blob/ffd95c3e616df8843cc8bff99c9b60765b124092/miflora/miflora_poller.py#L92
|
||||
if time.Since(peripheral.lastMetaDataFetch) >= 24*time.Hour {
|
||||
if time.Since(peripheral.lastMetaDataFetch) >= 1*time.Hour {
|
||||
metaData, err := impl.RequestVersionBattery(client)
|
||||
if err != nil {
|
||||
return common.SensorDataResponse{}, errors.Wrap(err, "can't request version battery")
|
||||
|
@ -151,13 +141,12 @@ func readData(peripheral *peripheral, client ble.Client) (common.SensorDataRespo
|
|||
}
|
||||
|
||||
func connectPeripheral(peripheral *peripheral, send chan mifloraMetric) error {
|
||||
fmt.Fprintf(os.Stderr, "Scanning for %s...\n", peripheral.id)
|
||||
|
||||
// only way to get back the found advertisement, must be buffered!
|
||||
foundAdvertisementChannel := make(chan ble.Advertisement, 1)
|
||||
|
||||
filter := func(adv ble.Advertisement) bool {
|
||||
if strings.ToUpper(adv.Addr().String()) == strings.ToUpper(peripheral.id) {
|
||||
if strings.EqualFold(adv.Addr().String(), peripheral.id) {
|
||||
foundAdvertisementChannel <- adv
|
||||
return true
|
||||
}
|
||||
|
@ -195,7 +184,7 @@ func connectPeripheral(peripheral *peripheral, send chan mifloraMetric) error {
|
|||
|
||||
timeReadoutTook := time.Since(timeReadoutStart).Seconds()
|
||||
|
||||
client.CancelConnection()
|
||||
err3 := client.CancelConnection()
|
||||
|
||||
<-done
|
||||
|
||||
|
@ -203,6 +192,10 @@ func connectPeripheral(peripheral *peripheral, send chan mifloraMetric) error {
|
|||
return errors.Wrap(err2, "can't read data")
|
||||
}
|
||||
|
||||
if err3 != nil {
|
||||
return errors.Wrap(err3, "can't disconnect after reading data")
|
||||
}
|
||||
|
||||
send <- mifloraDataMetric{
|
||||
peripheralId: common.MifloraGetAlphaNumericID(peripheral.id),
|
||||
sensorData: sensorData,
|
||||
|
@ -215,28 +208,33 @@ func connectPeripheral(peripheral *peripheral, send chan mifloraMetric) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func readPeripheral(peripheral *peripheral, send chan mifloraMetric) error {
|
||||
func readPeripheral(quit chan struct{}, peripheral *peripheral, send chan mifloraMetric) error {
|
||||
var err error
|
||||
fmt.Fprintf(os.Stderr, "Scanning for %s...", peripheral.id)
|
||||
L:
|
||||
for retry := 0; retry < *readRetries; retry++ {
|
||||
// check for quit signal (non-blocking) and terminate
|
||||
select {
|
||||
case <-quit:
|
||||
break L
|
||||
default:
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stderr, " %d", retry+1)
|
||||
err = connectPeripheral(peripheral, send)
|
||||
// stop retrying once we have a success, last err will be returned (or nil)
|
||||
if err == nil {
|
||||
break
|
||||
fmt.Fprintf(os.Stderr, ".")
|
||||
break L
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "\n")
|
||||
return err
|
||||
}
|
||||
|
||||
func readAllPeripherals(quit chan struct{}, send chan mifloraMetric) {
|
||||
for _, peripheral := range allPeripherals {
|
||||
// check for quit signal (non-blocking) and terminate
|
||||
select {
|
||||
case <-quit:
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
err := readPeripheral(peripheral, send)
|
||||
err := readPeripheral(quit, peripheral, send)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to read peripheral %s, err: %s\n", peripheral.id, err)
|
||||
// id := common.MifloraGetAlphaNumericID(peripheral.id)
|
||||
|
@ -249,7 +247,8 @@ func readAllPeripherals(quit chan struct{}, send chan mifloraMetric) {
|
|||
func main() {
|
||||
flag.Parse()
|
||||
if len(flag.Args()) < 1 {
|
||||
fmt.Fprintf(os.Stderr, "Usage: %s [options] peripheral-id [peripheral-ids...] \n", os.Args[0])
|
||||
fmt.Fprintf(os.Stderr,
|
||||
"Usage: %s [options] peripheral-id [peripheral-ids...] \n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
@ -266,7 +265,8 @@ func main() {
|
|||
case "influx":
|
||||
format = influxFormat
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr, "Unrecognized publish format %s! Exiting...\n", *publishFormatFlag)
|
||||
fmt.Fprintf(os.Stderr, "Unrecognized publish format %s! Exiting...\n",
|
||||
*publishFormatFlag)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
@ -347,8 +347,8 @@ func main() {
|
|||
fmt.Fprintf(os.Stderr, "Received %s! Stopping...\n", signal)
|
||||
intervalTicker.Stop()
|
||||
close(quit)
|
||||
// wait for last readPeripheral to finish (worst case)
|
||||
time.Sleep(*scanTimeout * time.Duration(*readRetries))
|
||||
// wait for last connectPeripheral to finish (worst case)
|
||||
time.Sleep(*scanTimeout)
|
||||
|
||||
mqttClient.Disconnect(1000)
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
func getVersion() string {
|
||||
info, ok := debug.ReadBuildInfo()
|
||||
if !ok {
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
for _, kv := range info.Settings {
|
||||
switch kv.Key {
|
||||
case "vcs.revision":
|
||||
return kv.Value[0:8]
|
||||
}
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
|
@ -19,6 +19,6 @@ func TestNumericFirmwareVersion(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, table := range tables {
|
||||
assert.Equal(t, table.metaData.NumericFirmwareVersion(), table.firmware)
|
||||
assert.Equal(t, table.firmware, table.metaData.NumericFirmwareVersion())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestMessage(t *testing.T) {
|
||||
assert.Equal(t, "", MifloraGetAlphaNumericID(""))
|
||||
assert.Equal(t, "1234567890ab", MifloraGetAlphaNumericID("12:34:56:78:90:ab"))
|
||||
}
|
|
@ -19,7 +19,7 @@ func TestParseVersionBattery(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, table := range tables {
|
||||
assert.Equal(t, ParseVersionBattery(table.bytes), table.metaData)
|
||||
assert.Equal(t, table.metaData, ParseVersionBattery(table.bytes))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,6 @@ func TestParseSensorData(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, table := range tables {
|
||||
assert.Equal(t, ParseSensorData(table.bytes), table.sensorData)
|
||||
assert.Equal(t, table.sensorData, ParseSensorData(table.bytes))
|
||||
}
|
||||
}
|
||||
|
|
36
go.mod
36
go.mod
|
@ -1,20 +1,26 @@
|
|||
module miflorad
|
||||
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 // indirect
|
||||
github.com/currantlabs/gatt v0.0.0-20161006170101-f949eac78f4e
|
||||
github.com/eclipse/paho.mqtt.golang v1.1.1
|
||||
github.com/fatih/structs v1.1.0 // indirect
|
||||
github.com/go-ble/ble v0.0.0-20181002102605-e78417b510a3
|
||||
github.com/godbus/dbus v0.0.0-20181031085051-66d97ae // indirect
|
||||
github.com/mattn/go-colorable v0.0.9 // indirect
|
||||
github.com/mattn/go-isatty v0.0.4 // indirect
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
|
||||
github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab // indirect
|
||||
github.com/muka/ble v0.0.0-20180314094923-5613a57406d1 // indirect
|
||||
github.com/muka/go-bluetooth v0.0.0-20190123084403-a5ba83cc4d9b
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/sirupsen/logrus v1.3.0 // indirect
|
||||
github.com/stretchr/testify v1.3.0
|
||||
golang.org/x/net v0.0.0-20190111034749-915654e7eabc // indirect
|
||||
github.com/eclipse/paho.mqtt.golang v1.4.3
|
||||
github.com/go-ble/ble v0.0.0-20200120171844-0a73a9da88eb
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/stretchr/testify v1.9.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
|
||||
github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/raff/goble v0.0.0-20200327175727-d63360dcfd80 // indirect
|
||||
golang.org/x/net v0.23.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.18.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
84
go.sum
84
go.sum
|
@ -1,52 +1,56 @@
|
|||
github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 h1:3jFq2xL4ZajGK4aZY8jz+DAF0FHjI51BXjjSwCzS1Dk=
|
||||
github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/currantlabs/gatt v0.0.0-20161006170101-f949eac78f4e h1:qu1wqkuctiqRtgZu8kNMtFxQ7/xXuOxSJZ2kYoOxFM0=
|
||||
github.com/currantlabs/gatt v0.0.0-20161006170101-f949eac78f4e/go.mod h1:GCdlaU9vOYeye8wQtSZNyZ4j5PhmnJ2HUqhRZO0KoZI=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/eclipse/paho.mqtt.golang v1.1.1 h1:iPJYXJLaViCshRTW/PSqImSS6HJ2Rf671WR0bXZ2GIU=
|
||||
github.com/eclipse/paho.mqtt.golang v1.1.1/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
|
||||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||
github.com/go-ble/ble v0.0.0-20181002102605-e78417b510a3 h1:rsLGztXl2QJvj4x/PAWzC1Zx6tnTDKlosaXAZfaXM8M=
|
||||
github.com/go-ble/ble v0.0.0-20181002102605-e78417b510a3/go.mod h1:UMPB54/KFpdTdfH7Yovhk3J6kzgzE88e3QZi8cbayis=
|
||||
github.com/godbus/dbus v0.0.0-20181031085051-66d97ae h1:NTs1uIj/Ru/QlpKwd9C9dnv/5zblvCXH7Dbn2oi3p98=
|
||||
github.com/godbus/dbus v0.0.0-20181031085051-66d97ae/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
|
||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
|
||||
github.com/eclipse/paho.mqtt.golang v1.4.3 h1:2kwcUGn8seMUfWndX0hGbvH8r7crgcJguQNCyp70xik=
|
||||
github.com/eclipse/paho.mqtt.golang v1.4.3/go.mod h1:CSYvoAlsMkhYOXh/oKyxa8EcBci6dVkLCbo5tTC1RIE=
|
||||
github.com/go-ble/ble v0.0.0-20200120171844-0a73a9da88eb h1:YLbB9CgjUw1U9GxEqGvM2ld9YqHRoBeEEM7f8A8l9x0=
|
||||
github.com/go-ble/ble v0.0.0-20200120171844-0a73a9da88eb/go.mod h1:nwmyxHsP2cqjashMTTAl3A5t6V3vzev1rLgMb/pZ7jc=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
||||
github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab h1:n8cgpHzJ5+EDyDri2s/GC7a9+qK3/YEGnBsd0uS/8PY=
|
||||
github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab/go.mod h1:y1pL58r5z2VvAjeG1VLGc8zOQgSOzbKN7kMHPvFXJ+8=
|
||||
github.com/muka/ble v0.0.0-20180314094923-5613a57406d1 h1:DrMDOYCxMG7TUMjhBWnRsgPfpPlz0sFL11ukl+2+CZU=
|
||||
github.com/muka/ble v0.0.0-20180314094923-5613a57406d1/go.mod h1:1lEPQDLh8Z86+REeQMqID8UpXCSdHF0fvU0qZj3b1eA=
|
||||
github.com/muka/go-bluetooth v0.0.0-20181012115104-31d8f53bf9a1 h1:VKhCDuxZ3+Bg+Plf7+CxgGRlNEdwHDKUqHoZLzer8Ms=
|
||||
github.com/muka/go-bluetooth v0.0.0-20181012115104-31d8f53bf9a1/go.mod h1:brKFFAJeW2mWp1W5D/GJhwbn3IpNR69jIm1qGWZcl50=
|
||||
github.com/muka/go-bluetooth v0.0.0-20190123084403-a5ba83cc4d9b/go.mod h1:brKFFAJeW2mWp1W5D/GJhwbn3IpNR69jIm1qGWZcl50=
|
||||
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/raff/goble v0.0.0-20190909174656-72afc67d6a99/go.mod h1:CxaUhijgLFX0AROtH5mluSY71VqpjQBw9JXE2UKZmc4=
|
||||
github.com/raff/goble v0.0.0-20200327175727-d63360dcfd80 h1:IZkjNgPZXcE4USkGzmJQyHco3KFLmhcLyFdxCOiY6cQ=
|
||||
github.com/raff/goble v0.0.0-20200327175727-d63360dcfd80/go.mod h1:CxaUhijgLFX0AROtH5mluSY71VqpjQBw9JXE2UKZmc4=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1bNv/cAU/n+6l8tRSis=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190107174441-1a61f4433d85/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190111034749-915654e7eabc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
|
||||
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191126131656-8a8471f7e56d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"extends": [
|
||||
"config:base"
|
||||
],
|
||||
"commitMessagePrefix": "module:",
|
||||
"commitMessageAction": "update",
|
||||
"packageRules": [
|
||||
{
|
||||
"packageNames": ["^golang.org/x/net"],
|
||||
"enabled": false
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
//shows how to watch for new devices and list them
|
||||
package legacy
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/muka/go-bluetooth/api"
|
||||
"github.com/muka/go-bluetooth/emitter"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const adapterID = "hci0"
|
||||
|
||||
// func main() {
|
||||
// manager, err := api.NewManager()
|
||||
// if err != nil {
|
||||
// log.Error(err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
//
|
||||
// err = manager.RefreshState()
|
||||
// if err != nil {
|
||||
// log.Error(err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
//
|
||||
// var address = "C4:7C:8D:66:D5:27"
|
||||
//
|
||||
// dev, err := api.GetDeviceByAddress(address)
|
||||
// if err != nil {
|
||||
// log.Error(err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
//
|
||||
// if dev == nil {
|
||||
// log.Infof("No device found!")
|
||||
// os.Exit(1)
|
||||
// }
|
||||
//
|
||||
// dev.GetAllServicesAndUUID()
|
||||
//
|
||||
// props, err := dev.GetProperties()
|
||||
// if err != nil {
|
||||
// log.Error(err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
//
|
||||
// log.Infof("name=%s addr=%s rssi=%d", props.Name, props.Address, props.RSSI)
|
||||
//
|
||||
// err = dev.Connect()
|
||||
// if err != nil {
|
||||
// log.Error(err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
//
|
||||
// if !dev.IsConnected() {
|
||||
// log.Infof("Device not connected!")
|
||||
// os.Exit(1)
|
||||
// }
|
||||
//
|
||||
// y, err := dev.GetCharByUUID("00002a00-0000-1000-8000-00805f9b34fb")
|
||||
// if err != nil {
|
||||
// log.Error(err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
//
|
||||
// log.Infof(y.Path)
|
||||
//
|
||||
// err = dev.Disconnect()
|
||||
// if err != nil {
|
||||
// log.Error(err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
// }
|
||||
|
||||
// func main() {
|
||||
// log.SetLevel(log.DebugLevel)
|
||||
//
|
||||
// // clean up connection on exit
|
||||
// defer api.Exit()
|
||||
//
|
||||
// manager, err := api.NewManager()
|
||||
// if err != nil {
|
||||
// log.Error(err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
//
|
||||
// err = manager.RefreshState()
|
||||
// if err != nil {
|
||||
// log.Error(err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
//
|
||||
// boo, err := api.AdapterExists(adapterID)
|
||||
// if err != nil {
|
||||
// log.Error(err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
// log.Debugf("AdapterExists: %b", boo)
|
||||
//
|
||||
// err = api.StartDiscoveryOn(adapterID)
|
||||
// if err != nil {
|
||||
// log.Error(err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
// log.Debugf("Started discovery")
|
||||
//
|
||||
// err = api.On("discovery", emitter.NewCallback(func(ev emitter.Event) {
|
||||
// discoveryEvent := ev.GetData().(api.DiscoveredDeviceEvent)
|
||||
// dev := discoveryEvent.Device
|
||||
// handleDevice(dev)
|
||||
// }))
|
||||
//
|
||||
// select {}
|
||||
// }
|
||||
//
|
||||
// func handleDevice(dev *api.Device) {
|
||||
// if dev == nil {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// props, err := dev.GetProperties()
|
||||
// if err != nil {
|
||||
// log.Error(err)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// log.Infof("name=%s addr=%s rssi=%d", props.Name, props.Address, props.RSSI)
|
||||
// }
|
Loading…
Reference in New Issue