Skip to content

Commit 56dec2c

Browse files
committed
Bump version to 1.2.45
1 parent 876a0a1 commit 56dec2c

28 files changed

+9401
-516
lines changed

docs/meshtastic/ble_interface.html

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ <h1 class="title">Module <code>meshtastic.ble_interface</code></h1>
2727
<summary>
2828
<span>Expand source code</span>
2929
</summary>
30-
<pre><code class="python">&#34;&#34;&#34; Bluetooth interface
30+
<pre><code class="python">&#34;&#34;&#34;Bluetooth interface
3131
&#34;&#34;&#34;
3232
import logging
3333
import pygatt
@@ -44,22 +44,27 @@ <h1 class="title">Module <code>meshtastic.ble_interface</code></h1>
4444
class BLEInterface(MeshInterface):
4545
&#34;&#34;&#34;A not quite ready - FIXME - BLE interface to devices&#34;&#34;&#34;
4646

47-
def __init__(self, address, debugOut=None):
47+
def __init__(self, address, noProto=False, debugOut=None):
4848
self.address = address
49-
self.adapter = pygatt.GATTToolBackend() # BGAPIBackend()
50-
self.adapter.start()
51-
logging.debug(f&#34;Connecting to {self.address}&#34;)
52-
self.device = self.adapter.connect(address)
49+
if not noProto:
50+
self.adapter = pygatt.GATTToolBackend() # BGAPIBackend()
51+
self.adapter.start()
52+
logging.debug(f&#34;Connecting to {self.address}&#34;)
53+
self.device = self.adapter.connect(address)
54+
else:
55+
self.adapter = None
56+
self.device = None
5357
logging.debug(&#34;Connected to device&#34;)
5458
# fromradio = self.device.char_read(FROMRADIO_UUID)
55-
MeshInterface.__init__(self, debugOut=debugOut)
59+
MeshInterface.__init__(self, debugOut=debugOut, noProto=noProto)
5660

5761
self._readFromRadio() # read the initial responses
5862

5963
def handle_data(handle, data):
6064
self._handleFromRadio(data)
6165

62-
self.device.subscribe(FROMNUM_UUID, callback=handle_data)
66+
if self.device:
67+
self.device.subscribe(FROMNUM_UUID, callback=handle_data)
6368

6469
def _sendToRadioImpl(self, toRadio):
6570
&#34;&#34;&#34;Send a ToRadio protobuf to the device&#34;&#34;&#34;
@@ -69,15 +74,18 @@ <h1 class="title">Module <code>meshtastic.ble_interface</code></h1>
6974

7075
def close(self):
7176
MeshInterface.close(self)
72-
self.adapter.stop()
77+
if self.adapter:
78+
self.adapter.stop()
7379

7480
def _readFromRadio(self):
75-
wasEmpty = False
76-
while not wasEmpty:
77-
b = self.device.char_read(FROMRADIO_UUID)
78-
wasEmpty = len(b) == 0
79-
if not wasEmpty:
80-
self._handleFromRadio(b)</code></pre>
81+
if not self.noProto:
82+
wasEmpty = False
83+
while not wasEmpty:
84+
if self.device:
85+
b = self.device.char_read(FROMRADIO_UUID)
86+
wasEmpty = len(b) == 0
87+
if not wasEmpty:
88+
self._handleFromRadio(b)</code></pre>
8189
</details>
8290
</section>
8391
<section>
@@ -91,36 +99,42 @@ <h2 class="section-title" id="header-classes">Classes</h2>
9199
<dl>
92100
<dt id="meshtastic.ble_interface.BLEInterface"><code class="flex name class">
93101
<span>class <span class="ident">BLEInterface</span></span>
94-
<span>(</span><span>address, debugOut=None)</span>
102+
<span>(</span><span>address, noProto=False, debugOut=None)</span>
95103
</code></dt>
96104
<dd>
97105
<div class="desc"><p>A not quite ready - FIXME - BLE interface to devices</p>
98106
<p>Constructor</p>
99107
<p>Keyword Arguments:
100-
noProto &ndash; If True, don't try to run our protocol on the link - just be a dumb serial client.</p></div>
108+
noProto &ndash; If True, don't try to run our protocol on the
109+
link - just be a dumb serial client.</p></div>
101110
<details class="source">
102111
<summary>
103112
<span>Expand source code</span>
104113
</summary>
105114
<pre><code class="python">class BLEInterface(MeshInterface):
106115
&#34;&#34;&#34;A not quite ready - FIXME - BLE interface to devices&#34;&#34;&#34;
107116

108-
def __init__(self, address, debugOut=None):
117+
def __init__(self, address, noProto=False, debugOut=None):
109118
self.address = address
110-
self.adapter = pygatt.GATTToolBackend() # BGAPIBackend()
111-
self.adapter.start()
112-
logging.debug(f&#34;Connecting to {self.address}&#34;)
113-
self.device = self.adapter.connect(address)
119+
if not noProto:
120+
self.adapter = pygatt.GATTToolBackend() # BGAPIBackend()
121+
self.adapter.start()
122+
logging.debug(f&#34;Connecting to {self.address}&#34;)
123+
self.device = self.adapter.connect(address)
124+
else:
125+
self.adapter = None
126+
self.device = None
114127
logging.debug(&#34;Connected to device&#34;)
115128
# fromradio = self.device.char_read(FROMRADIO_UUID)
116-
MeshInterface.__init__(self, debugOut=debugOut)
129+
MeshInterface.__init__(self, debugOut=debugOut, noProto=noProto)
117130

118131
self._readFromRadio() # read the initial responses
119132

120133
def handle_data(handle, data):
121134
self._handleFromRadio(data)
122135

123-
self.device.subscribe(FROMNUM_UUID, callback=handle_data)
136+
if self.device:
137+
self.device.subscribe(FROMNUM_UUID, callback=handle_data)
124138

125139
def _sendToRadioImpl(self, toRadio):
126140
&#34;&#34;&#34;Send a ToRadio protobuf to the device&#34;&#34;&#34;
@@ -130,15 +144,18 @@ <h2 class="section-title" id="header-classes">Classes</h2>
130144

131145
def close(self):
132146
MeshInterface.close(self)
133-
self.adapter.stop()
147+
if self.adapter:
148+
self.adapter.stop()
134149

135150
def _readFromRadio(self):
136-
wasEmpty = False
137-
while not wasEmpty:
138-
b = self.device.char_read(FROMRADIO_UUID)
139-
wasEmpty = len(b) == 0
140-
if not wasEmpty:
141-
self._handleFromRadio(b)</code></pre>
151+
if not self.noProto:
152+
wasEmpty = False
153+
while not wasEmpty:
154+
if self.device:
155+
b = self.device.char_read(FROMRADIO_UUID)
156+
wasEmpty = len(b) == 0
157+
if not wasEmpty:
158+
self._handleFromRadio(b)</code></pre>
142159
</details>
143160
<h3>Ancestors</h3>
144161
<ul class="hlist">

0 commit comments

Comments
 (0)