Shorewall Hairpinning
Hairpinning is a method for getting internally originating from hosts in the lan addressing the external IP of the gateway to be routed through the gateway.
Setting it up with Shorewall is described in the Shorewall FAQs or, if the Shorewall documentation is installed, in the Local Shorewall FAQs
Reading Heart Rate from the Zephyr HxM BT
The Zephyr HxM BT heart rate monitor may be easily integrated into the meeTrainer application. The API specification for the HxM specifies that it transmits one 60 byte packet every second, and that the heart rate is shipped in one byte with index 12 into this packet.
1 # Externally pairing and setup of the SP must be done as root:
2 # $ rfcomm connect rfcomm1 00:07:80:5A:35:42 1
3
4 import serial
5 import struct
6 import time
7
8 pkg_struct = struct.Struct('60B')
9 pkg_size = pkg_struct.size
10 zhxm = serial.Serial('/dev/rfcomm1')
11
12 hr_idx = 12
13 dist_idx = [50, 51]
14 speed_idx = [52, 53]
15 strides_idx = 54
16
17 def read_hr():
18 zhxm.read(zhxm.inWaiting())
19 d = pkg_struct.unpack(zhxm.read(pkg_size))
20 return d[hr_idx]
21
22
23 #
24 # Make a running plot for the past 60 seconds of HR measurements
25 #
26 import matplotlib.pyplot as plt
27 import numpy as np
28 hrs = read_hr() * np.ones(60,dtype=np.uint8)
29 plt.ion()
30 fig = plt.figure()
31 fig.set
32 ax = fig.add_subplot(111)
33 ax.grid(True)
34 ax.set_yticks(np.arange(40,220,5))
35 ax.set_ylim(40, 220)
36 hr_line, = ax.plot(hrs, 'ro-')
37 while True:
38 hr = read_hr()
39 hrs = np.roll(hrs,1)
40 hrs[0] = hr
41 hr_line.set_ydata(hrs)
42 fig.canvas.draw()
43 time.sleep(0.5)
44
45 zhxm.close()
