コード例 #1
0
def test_is_connected_is_false():
    '''
    Tests is connected. Make sure counterfit is running until you see a message telling you to close it
    '''
    CounterFitConnection.init('127.0.0.1', 5000)
    print("Please close counterfit")
    time.sleep(10)
    assert not CounterFitConnection.is_connected()
コード例 #2
0
def test_camera_image():
    '''
    Tests reading an image from a camera sensor. The image is saved locally
    '''
    CounterFitConnection.init('127.0.0.1', 5000)
    image_data = CounterFitConnection.read_binary_sensor('Picamera')

    with open('test_image.png', 'wb') as image_file:
        image_file.write(image_data.read())
コード例 #3
0
ファイル: app.py プロジェクト: CounterFit-IoT/CounterFit
import time

from counterfit_connection import CounterFitConnection
from counterfit_shims_grove.grove_light_sensor_v1_2 import GroveLightSensor
from counterfit_shims_grove.grove_led import GroveLed

CounterFitConnection.init('127.0.0.1', 5000)

light_sensor = GroveLightSensor(1)
led = GroveLed(2)

while True:
    sensor_value = light_sensor.light
    print(f'Light sensor reading: {sensor_value}')

    if sensor_value > 200:
        print('Turning LED off')
        led.off()
    else:
        print('Turning LED on')
        led.on()

    time.sleep(2)
def init_counterfit_device():
    '''
    Test fixture to initialise the connection to the CounterFit Virtual IoT device running on localhost on port 5000
    '''
    CounterFitConnection.init('127.0.0.1', 5000)
コード例 #5
0
def test_is_connected():
    '''
    Tests is connected. Make sure counterfit is running
    '''
    CounterFitConnection.init('127.0.0.1', 5000)
    assert CounterFitConnection.is_connected()
コード例 #6
0
def test_init_counterfit_device():
    '''
    Tests the connection. You should see the CounterFit app status change to connected
    '''
    CounterFitConnection.init('127.0.0.1', 5000)