forked from GeorgeHahn-Lab651/sensei_mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from argparse import ArgumentParser | ||
from aci import AciCommand | ||
from aci_serial import AciUart | ||
from aci import AciEvent | ||
import time | ||
import sensei_cmd | ||
import sensei | ||
import yaml | ||
from os.path import expanduser | ||
import urllib2 | ||
import os.path | ||
|
||
class Uploader(object): | ||
def __init__(self, sensei_config): | ||
api_url = sensei_config["server"]["url"] + 'api/v1/' | ||
self.api = sensei.Api(api_url, sensei_config["server"]["username"], sensei_config["server"]["password"]) | ||
self.aci = AciUart.AciUart(port=sensei_config['mesh_network']['serial_path'], baudrate=115200) | ||
|
||
def get_sensor_updates(self): | ||
updates = [] | ||
while True: | ||
try: | ||
self.acidev.events_queue.get_nowait() | ||
if isinstance(evt, AciEvent.AciEventNew) and evt.is_sensor_update(): | ||
updates.append(evt.sensor_values()) | ||
except Empty: | ||
break | ||
|
||
def radio_obs_from_sensor_updates(updates): | ||
|
||
|
||
def run(self): | ||
# Wait for serial connection to be ready | ||
time.sleep(2) | ||
|
||
while True: | ||
updates = self.get_sensor_updates() | ||
if len(updates) > 0: | ||
self.api.upload_obs([self.]) | ||
else: | ||
time.sleep(2) | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
|
||
config_path = expanduser("~") + "/.sensei.yaml" | ||
if os.path.isfile(config_path): | ||
with open(config_path, 'r') as stream: | ||
try: | ||
sensei_config = yaml.load(stream) | ||
uploader = Uploader(sensei_config) | ||
upload | ||
except yaml.YAMLError as exc: | ||
print(exc) | ||
else: | ||
print(str.format("Please configure settings in %s" %(config_path))) | ||
exit(-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef GPIO_PINS_H | ||
#define GPIO_PINS_H | ||
|
||
#define DBG_TICK_PIN(x) NRF_GPIO->OUTSET = (1 << (x)); \ | ||
__NOP();\ | ||
__NOP();\ | ||
__NOP();\ | ||
__NOP();\ | ||
NRF_GPIO->OUTCLR = (1 << (x)) | ||
|
||
#define SET_PIN(x) NRF_GPIO->OUTSET = (1 << (x)) | ||
#define CLEAR_PIN(x) NRF_GPIO->OUTCLR = (1 << (x)) | ||
|
||
#define TOGGLE_PIN(x) do { uint32_t gpio_state = NRF_GPIO->OUT; \ | ||
NRF_GPIO->OUTSET = ((1<<(x)) & ~gpio_state); \ | ||
NRF_GPIO->OUTCLR = ((1<<(x)) & gpio_state); } while (0) | ||
|
||
#endif //GPIO_PINS_H |