Skip to content

Commit

Permalink
[fix] fix static hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
Shoji Imamura committed May 17, 2018
1 parent 3d5f819 commit df9f85e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 15 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

### 取り扱い方

omron_envsensorは、pythonスクリプト内からインポートするもしくはrun.py、cat_csv.pyファイルを用いて活性化してください。これらにはroot権限が必要です
活性化する際には、必須パッケージをインストールした状態のraspberryPi3もしくはraspberryPiZero内から使用しなければなりません
omron_envsensorは、RaspberryPi上のLinuxシステム上からpythonスクリプトからインポートもしくはrun.py、cat_csv.pyファイルを用いて活性化してください。
活性化する際にはroot権限と、必須パッケージがインストールされていなければいけません
必須パッケージのインストールについては **補遺1** を参照してください。
ライブラリのインストールについては **補遺2** を参照してください。

Expand Down Expand Up @@ -36,6 +36,18 @@ sudo pip3 install pygattlib
### 補遺2 インストール

```shell
sudo pip3 install https://github.com/isaaxug/omron_envsensor/archive/0.0.1.zip
sudo pip3 install https://github.com/isaaxug/omron_envsensor/archive/0.0.2.zip
```

### 補遺3 サンプルスクリプトの使用方法

info情報
```shell
sudo python3 run.py
```

CSV出力
```shell
sudo python3 cat_csv.py > csv.csv
```

9 changes: 7 additions & 2 deletions cat_csv.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
#!/usr/bin/env python

from logging import getLogger
logger = getLogger('omron_envsensor')

import sys
from omron_envsensor import OmronEnvSensor
from omron_envsensor.sensorbeacon import csv_header
from omron_envsensor.util import getHostname
import sys
import os

BLUETHOOTH_DEVICEID = os.environ.get('BLUETHOOTH_DEVICEID', 0)

def main():
sys.stdout.write(csv_header())
sys.stdout.write("\r\n")

before_seq = None
o = OmronEnvSensor('pudge', 0)
o = OmronEnvSensor(getHostname(), BLUETHOOTH_DEVICEID)

def callback(beacon):
sys.stdout.write(beacon.csv_format())
Expand Down
3 changes: 2 additions & 1 deletion omron_envsensor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""
omron environment sensor parser
"""
from __future__ import absolute_import

__version__ = '0.0.1'
__version__ = '0.0.2'

from logging import getLogger, NullHandler
logger = getLogger('omron_envsensor')
Expand Down
5 changes: 0 additions & 5 deletions omron_envsensor/ble.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@

"""
"""

from __future__ import absolute_import

from logging import getLogger
Expand Down
4 changes: 4 additions & 0 deletions omron_envsensor/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import struct
import sys
import os

def packet_as_hex_string(pkt, flag_with_spacing=False,
flag_force_capitalize=False):
Expand Down Expand Up @@ -103,3 +104,6 @@ def ushort2short(val):
else:
short_val = val
return short_val

def getHostname():
return os.uname()[1]
13 changes: 10 additions & 3 deletions run.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
#!/usr/bin/env python

from logging import getLogger
logger = getLogger('omron_envsensor')

from omron_envsensor import OmronEnvSensor
from omron_envsensor.util import getHostname
import sys
import os

BLUETHOOTH_DEVICEID = os.environ.get('BLUETHOOTH_DEVICEID', 0)

def main():
import logging
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.INFO)
logger.addHandler(logging.StreamHandler(stream=sys.stdout))

before_seq = None
o = OmronEnvSensor('pudge', 0)
o = OmronEnvSensor(getHostname(), BLUETHOOTH_DEVICEID)

def callback(beacon):
beacon.debug_print(logger)
# logger.info(beacon.bt_address)

o.on_message = callback
o.init()
Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
name = "omron_envsensor",
version = omron_envsensor.__version__,
description = ("OMRON 2JCIE-BL01 SENSOR"),
packages = ['pybluez', 'pygattlib'],
entry_points={
'console_scripts' : [
'omron_env = run:main',
'omron_csv = cat_csv:main',
],
},
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
Expand Down

0 comments on commit df9f85e

Please sign in to comment.