Skip to content

Commit c729a66

Browse files
committed
fleshed out README
1 parent 6168a25 commit c729a66

File tree

9 files changed

+168
-45
lines changed

9 files changed

+168
-45
lines changed

API.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77
| Notecard API | Python Library API |
88
| -----------------------| -------------------|
99
| `card.attn` | card.attn |
10-
| `card.aux` | ??? |
11-
| `card.contact` | ??? |
12-
| `card.location.mode` | ??? |
13-
| `card.location.track` | ??? |
14-
| `card.motion.mode` | ??? |
15-
| `card.motion.sync` | ??? |
16-
| `card.motion.track` | ??? |
17-
| `card.restart` | ??? |
18-
| `card.restore` | ??? |
10+
| `card.aux` | NOT IMPLEMENTED |
11+
| `card.contact` | NOT IMPLEMENTED |
12+
| `card.location.mode` | NOT IMPLEMENTED |
13+
| `card.location.track` | NOT IMPLEMENTED |
14+
| `card.motion.mode` | NOT IMPLEMENTED |
15+
| `card.motion.sync` | NOT IMPLEMENTED |
16+
| `card.motion.track` | NOT IMPLEMENTED |
17+
| `card.restart` | NOT IMPLEMENTED |
18+
| `card.restore` | NOT IMPLEMENTED |
1919
| `card.status` | card.status |
2020
| `card.temp` | card.temp |
2121
| `card.time` | card.time |
22-
| `card.usage.get` | ??? |
23-
| `card.usage.test` | ??? |
24-
| `card.version` | ??? |
25-
| `card.voltage` | ??? |
22+
| `card.usage.get` | NOT IMPLEMENTED |
23+
| `card.usage.test` | NOT IMPLEMENTED |
24+
| `card.version` | NOT IMPLEMENTED |
25+
| `card.voltage` | NOT IMPLEMENTED |
2626
| `card.wireless` | card.wireless |
2727

2828
## Note Commands
@@ -32,23 +32,23 @@
3232
| Notecard API | Python Library API |
3333
| -----------------------| -------------------|
3434
| `note.add` | note.add |
35-
| `note.changes` | ??? |
36-
| `note.delete` | ??? |
35+
| `note.changes` | NOT IMPLEMENTED |
36+
| `note.delete` | NOT IMPLEMENTED |
3737
| `note.get` | note.get |
38-
| `note.update` | ??? |
38+
| `note.update` | NOT IMPLEMENTED |
3939

40-
## Service Commands
40+
## Hub Commands
4141

42-
`from notecard import service`
42+
`from notecard import hub`
4343

4444
| Notecard API | Python Library API |
4545
| -----------------------| -------------------|
46-
| `service.get` | service.get |
47-
| `service.log` | service.log |
48-
| `service.set` | service.set |
49-
| `service.status` | service.status |
50-
| `service.sync` | service.sync |
51-
| `service.sync.status` | service.syncStatus |
46+
| `hub.get` | hub.get |
47+
| `hub.log` | hub.log |
48+
| `hub.set` | hub.set |
49+
| `hub.status` | hub.status |
50+
| `hub.sync` | hub.sync |
51+
| `hub.sync.status` | hub.syncStatus |
5252

5353
## DFU Commands
5454

@@ -61,20 +61,20 @@
6161

6262
| Notecard API | Python Library API |
6363
| -----------------------| -------------------|
64-
| `get` | ??? |
64+
| `get` | NOT IMPLEMENTED |
6565

6666
## File Commands
6767

6868
| Notecard API | Python Library API |
6969
| -----------------------| -------------------|
70-
| `file.changes` | ??? |
71-
| `file.delete` | ??? |
72-
| `file.stats` | ??? |
70+
| `file.changes` | NOT IMPLEMENTED |
71+
| `file.delete` | NOT IMPLEMENTED |
72+
| `file.stats` | NOT IMPLEMENTED |
7373

7474
## Web Commands
7575

7676
| Notecard API | Python Library API |
7777
| -----------------------| -------------------|
78-
| `web.get` | ??? |
79-
| `web.post` | ??? |
80-
| `web.put` | ??? |
78+
| `web.get` | NOT IMPLEMENTED |
79+
| `web.post` | NOT IMPLEMENTED |
80+
| `web.put` | NOT IMPLEMENTED |

MAKEFILE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default: test
77
venv: $(VENV_NAME)/bin/activate
88

99
test: venv
10-
${PYTHON} -m flake8 test/ notecard/ example/ --count --ignore=E722,F401,F403,W503 --show-source --statistics
10+
${PYTHON} -m flake8 test/ notecard/ examples/ --count --ignore=E722,F401,F403,W503 --show-source --statistics
1111
${PYTHON} -m pytest test --cov=notecard
1212

1313
coverage: venv

README.md

Lines changed: 136 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,140 @@
1-
# [Blues Wireless][blues]
1+
# note-python
22

3-
The note-python Python library for communicating with Blues Wireless Notecard via serial or I²C.
3+
Python library for communicating with the Blues Wireless Notecard over serial or I²C.
44

5-
This library allows you to control a Notecard by coding in Python.
6-
Your program may configure Notecard and send Notes to [Notehub.io][notehub].
5+
![Build](https://github.com/blues/note-python/workflows/Python%20package/badge.svg)
76

8-
See also:
9-
* [note-c][note-c] for C bindings
10-
* [note-go][note-go] for Go bindings
7+
This library allows you to control a Notecard by coding in Python and works in a desktop setting, on Single-Board Computers like the Raspberry Pi, and on Microcontrollers with MicroPython or CircuitPython support.
118

12-
[blues]: https://blues.com
13-
[notehub]: https://notehub.io
14-
[note-arduino]: https://github.com/blues/note-arduino
15-
[note-c]: https://github.com/blues/note-c
16-
[note-go]: https://github.com/blues/note-go
17-
[note-python]: https://github.com/blues/note-python
9+
## Installation
10+
11+
With pi-py:
12+
13+
```bash
14+
pip install note-python
15+
```
16+
17+
For use with MicroPython or CircuitPython, copy the contents of the `notecard` directory into the `lib` directory of your device.
18+
19+
## Usage
20+
21+
```python
22+
import notecard
23+
```
24+
25+
The `note-python` library requires a pointer to a serial or i2c object that you initialize and pass into the library. This object differs based on platform, so consult the [examples](examples/) directory for platform-specific guidance.
26+
27+
### Serial Configuration
28+
29+
```python
30+
# Use python-periphery on a desktop or Raspberry Pi
31+
from periphery import Serial
32+
port = Serial("/dev/serial0", 9600)
33+
34+
card = notecard.OpenSerial(port)
35+
```
36+
37+
### I2C Confgiguration
38+
39+
```python
40+
# Use python-periphery on a desktop or Raspberry Pi
41+
from periphery import Serial
42+
port = I2C("/dev/i2c-1")
43+
card = notecard.OpenI2C(port, 0, 0)
44+
```
45+
46+
### Sending Notecard Requests
47+
48+
Whether using Serial or I2C, sending Notecard requests and reading responses follows the same pattern:
49+
50+
1. Create a JSON object that adheres to the Notecard API
51+
2. Call `card.Transaction`, `card.Request` or `card.RequestResponse` and pass in the request JSON object.
52+
3. Make sure the response contains the data you need
53+
54+
```python
55+
# Construct a JSON Object to add a Note to the Notecard
56+
req = {"req": "note.add"}
57+
req["body"] = {"temp": 18.6}
58+
59+
rsp = card.Transaction(req)
60+
print(rsp) # {"total":1}
61+
```
62+
63+
### Using the Library Fluent API
64+
65+
The `notecard` class allows complete access to the Notecard API via manual JSON object construction and the `Transaction`, `Request`, and `RequestResponse` methods. Alternatively, you can import one or more Fluent API helpers to work with common aspects of the Notecard API without having to author JSON objects, by hand. **Note** that not all aspects of the Notecard API are available using these helpers. For a complete list of supported helpers, visit the [API](API.md) doc.
66+
67+
Here's an example that uses the `hub` helper to set the Notecard Product UID in CircuitPython:
68+
69+
```python
70+
import board
71+
import busio
72+
73+
import notecard
74+
from notecard import card, hub, note
75+
76+
port = busio.I2C(board.SCL, board.SDA)
77+
nCard = notecard.OpenI2C(port, 0, 0, debug=True)
78+
79+
productUID = "com.blues.brandon.tester"
80+
rsp = hub.set(nCard, productUID, mode="continuous", sync=True)
81+
82+
print(rsp) # {}
83+
```
84+
85+
## Documentation
86+
87+
The documentation for this library can be found at the Blues Wireless [wireless.dev](https//wireless.dev/reference/note-python) site.
88+
89+
## Examples
90+
91+
The [examples](examples/) directory contains examples for using this library with:
92+
93+
- [Serial](examples/serial-example.py)
94+
- [I2C](examples/i2c-example.py)
95+
- [RaspberryPi](examples/rpi-example.py)
96+
- [CircuitPython](examples/cpy-example.py)
97+
- [MicroPython](examples/mpy-example.py)
98+
99+
## Contributing
100+
101+
We love issues, fixes, and pull requests from everyone. By participating in this project, you agree to abide by the Blues Inc [code of conduct].
102+
103+
For details on contributions we accept and the process for contributing, see our [contribution guide](CONTRIBUTING.md)
104+
105+
## Running the Tests
106+
107+
If you're planning to contribute to this repo, please be sure to run the tests before submitting a PR. First run:
108+
109+
```bash
110+
pip install -r requirements.txt
111+
```
112+
113+
Then, run the linter and tests using the included `MAKEFILE`.
114+
115+
```bash
116+
make -f MAKEFILE
117+
```
118+
119+
Alternatively, you can inspect the contents of the [MAKEFILE](MAKEFILE) and run `flake8` and `pytest` directly. Be aware, however, that the commands in the `MAKEFILE` run against every pull request, so your best bet is to ensure these tests are successful before submitting your PR.
120+
121+
## More Information
122+
123+
For additional Notecard SDKs and Libraries, see:
124+
125+
* [note-c](note-c) for Standard C support
126+
* [note-go](note-go) for Go
127+
* [note-arduino](note-arduino) for Arduino
128+
129+
## To learn more about Blues Wireless, the Notecard and Notehub, see:
130+
131+
* [blues.com](https://blues.com)
132+
* [notehub.io][Notehub]
133+
* [wireless.dev](https://wireless.dev)
134+
135+
## License
136+
137+
Copyright (c) 2019 Blues Inc. Released under the MIT license. See [LICENSE](LICENSE) for details.
138+
139+
[code of conduct]: https://blues.github.io/opensource/code-of-conduct
140+
[Notehub]: https://notehub.io
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)