Skip to content

blues/notecard-pseudo-sensor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NotecardPseudoSensor

NotecardPseudoSensor provides an API interface to the internal sensors of the Blues Wireless Notecard. The goal of this abstraction is to offer a sensor to use with more advanced tutorials, which enables focus on the syntax necessary to perform basic Notecard transactions for those new to the platform.

Example sketches in can be found in the examples directory.

This library takes a dependency on the note-arduino library, which is used to sample and collect temperature readings from the Notecard.

Installation

  1. Open the Arduino IDE and click Tools > Manage Libraries....
  2. Search for "Blues" in the input box and click the "Install" button next to the "Blues Wireless Notecard Pseudo Sensor" result.
  3. Create a new sketch and select the Sketch > Include Library > Contributed Libraries > Blues Wireless Notecard Pseudo Sensor menu option, to add the following includes to your sketch:
#include <Notecard.h>
#include <NotecardPseudoSensor.h>

Usage

#include <Notecard.h>
#include <NotecardPseudoSensor.h>

using namespace blues;

// Create an instance of the Notecard and NotecardPseudoSensor
Notecard notecard;
NotecardPseudoSensor sensor(notecard);

notecard.begin();
float temperature = sensor.temp();

Documentation

The documentation for this library can be found here.

Examples

The examples directory contains examples for using this library with:

Contributing

We love issues, fixes, and pull requests from everyone. Please run the unit-tests (as described in the following section), prior to submitting your PR. By participating in this project, you agree to abide by the Blues Inc code of conduct.

For details on contributions we accept and the process for contributing, see our contribution guide.

Tests

The unit-tests are written using the Catch2 framework, and mocking is implemented using the FakeIt framework.

Running Tests

From the test directory in a terminal application, execute the following command:

g++ ../src/NotecardPseudoSensor.cpp NotecardPseudoSensor.test.cpp cjson.mock.cpp -Wall -Wextra -Wpedantic -I . -I ../src/ -I Catch2/single_include/ -I FakeIt/single_header/catch/ -DMOCK && ./a.out || echo "Tests Result: $?"

Success

Upon success, you will see the following message:

===============================================================================
All tests passed (6 assertions in 6 test cases)

Failure

When a test fails, you will see a message similar to the following:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.out is a Catch v2.13.4 host application.
Run with -? for options

-------------------------------------------------------------------------------
NotecardPseudoSensor::temp() returns the value parsed from the Notecard
response
-------------------------------------------------------------------------------
NotecardPseudoSensor.test.cpp:57
...............................................................................

NotecardPseudoSensor.test.cpp:74: FAILED:
  CHECK( result == JNumberValueResult+1 )
with expansion:
  9.17f == 10.17f

===============================================================================
test cases: 6 | 5 passed | 1 failed
assertions: 6 | 5 passed | 1 failed

Tests Result: 1

Adding a New Test

If wish to add new functionality to the NotecardPseudoSensor class, then please also add the supporting unit-tests to ensure its functionality. If you unfamiliar with the unit-testing and mocking frameworks, please use the links above to help get started. If you are still having trouble, reach out to us in the developer forums. Happy hacking!

Learn more about Blues Wireless, the Notecard and Notehub

License

Copyright (c) 2021 Blues, Inc. Released under the MIT license. See LICENSE for details.