Implemented platform specific stuff
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-09-30 03:35:20 +02:00
parent 561dea69ba
commit 3a129f8518
4 changed files with 38 additions and 7 deletions

View File

@ -1,5 +1,8 @@
#!/usr/bin/env python3
from typing import Optional
from .abcsensor import AbcSensor
from utils import config
from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformRecordDriver
"""
Sound sensor high level API
@ -15,11 +18,17 @@ class SoundSensor(AbcSensor):
"""
SoundSensor class. Responsible for sound retrieval from any microphones present.
"""
def getvalue(self) -> str:
def __init__(self):
BirbnetesIoTPlatformRecordDriver.init(config.SAMPLE_LENGTH)
def getvalue(self) -> Optional[str]:
"""
Retrieve a 5 second sound clip from a microphone.
Retrieve a configurable length second sound clip from a microphone.
:return:
"""
# Recieve sound from microphone and save it to a file on the filesystem.
# Then return the filename
return "filename.wav"
return BirbnetesIoTPlatformRecordDriver.get_recording(False)
def __del__(self):
# In theory you should not put anything to __del__ as it is not guaranteed to be called.
BirbnetesIoTPlatformRecordDriver.cleanup()