Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Merge edinburgh release(1.0.1) #14

Merged
merged 2 commits into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions Attribution.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This software includes code copyrighted from mraa & upm as follows:
This software includes code copyrighted from mraa, upm and BME680 driver as follows:

mraa
----
Expand Down Expand Up @@ -34,4 +34,52 @@ https://github.com/intel-iot-devkit/upm
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


---------------------------------------------------------------------------

BME680_driver
-------------
Copyright (C) 2017 - 2018 Bosch Sensortec GmbH
https://github.com/BoschSensortec/BME680_driver

---------------------------------------------------------------------------

Copyright Information

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

Neither the name of the copyright holder nor the names of the
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE

The information provided is believed to be accurate and reliable.
The copyright holder assumes no responsibility
for the consequences of use
of such information nor for any infringement of patents or
other rights of third parties which may result from its use.
No license is granted by implication or otherwise under any patent or
patent rights of the copyright holder.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Changes for Edinburgh release:

- Device service updated to use C SDK (v1.0.0)
- Added support to read temperature, humidity and pressure from grove Bosch Sensortec BME680
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The repository can be found on git at [libmraa](https://github.com/intel-iot-dev
2. Build a docker image by using the following command
```
sh> cd device-grove-c
sh> docker build . -t < device-grove-c > -f ./scripts/Dockerfile.alpine-3.8
sh> docker build . -t < device-grove-c > -f ./scripts/Dockerfile.alpine-3.9

```
This command shall build the dependencies - libmraa and device-c-sdk library to build device-grove-c release image.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.0.1
60 changes: 51 additions & 9 deletions res/Grove_Device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Grove_Device"
manufacturer: "Seeed"
model: ""
labels:
- "Grove LED, Grove Button, Grove Buzzer, Grove LCD, Grove LightSensor, Grove Relay, Grove RotarySensor, Grove SoundSensor"
- "Grove LED, Grove Button, Grove Buzzer, Grove LCD, Grove LightSensor, Grove Relay, Grove RotarySensor, Grove SoundSensor, Grove BME680Sensor"
description: "Grove Device to Read/Write sensors connected to GrovePI."

deviceResources:
Expand Down Expand Up @@ -93,7 +93,7 @@ deviceResources:
{ Pin_Num: "A0", Interface: "AIO", Type: "IN" }
properties:
value:
{ type: "Float32", readWrite: "RW", minimum: "0", maximum: "", defaultValue: "0" }
{ type: "Float32", floatEncoding: "eNotation", readWrite: "RW", minimum: "0", maximum: "", defaultValue: "0" }
units:
{ type: "String", readWrite: "R", defaultValue: "lumen" }
- name: SoundIntensity
Expand All @@ -102,7 +102,7 @@ deviceResources:
{ Pin_Num: "A1", Interface: "AIO", Type: "IN", normalize: "false"}
properties:
value:
{ type: "Float32", readWrite: "RW", minimum: "0", maximum: "5", scale: "0.0049", defaultValue: "0" }
{ type: "Float32", floatEncoding: "eNotation", readWrite: "RW", minimum: "0", maximum: "5", scale: "0.0049", defaultValue: "0" }
units:
{ type: "String", readWrite: "R", defaultValue: "Vbiased" }
- name: RotaryAngle
Expand All @@ -111,7 +111,7 @@ deviceResources:
{ Pin_Num: "A2", Interface: "AIO", Type: "IN", normalize: "false" }
properties:
value:
{ type: "Float32", readWrite: "RW", minimum: "0", maximum: "300", scale: "0.2933", defaultValue: "0" }
{ type: "Float32", floatEncoding: "eNotation", readWrite: "RW", minimum: "0", maximum: "300", scale: "0.2933", defaultValue: "0" }
units:
{ type: "String", readWrite: "R", defaultValue: "Degree" }
- name: RotaryVoltage
Expand All @@ -120,12 +120,37 @@ deviceResources:
{ Pin_Num: "A2", Interface: "AIO", Type: "IN", normalize: "false"}
properties:
value:
{ type: "Float32", readWrite: "RW", minimum: "0", maximum: "5", scale: "0.0049", defaultValue: "0" }
{ type: "Float32", floatEncoding: "eNotation", readWrite: "RW", minimum: "0", maximum: "5", scale: "0.0049", defaultValue: "0" }
units:
{ type: "String", readWrite: "R", defaultValue: "V" }


resources:
- name: Temperature
description: "Read Temperature from BME680"
attributes:
{ Pin_Num: "I2C-1", Interface: "I2C", Type: "BME680"}
properties:
value:
{ type: "Float32", floatEncoding: "eNotation", readWrite: "RW", minimum: "-40", maximum: "85", defaultValue: "0" }
units:
{ type: "String", readWrite: "R", defaultValue: "°C" }
- name: Pressure
description: "Read Pressure from BME680"
attributes:
{ Pin_Num: "I2C-1", Interface: "I2C", Type: "BME680", normalize: "false"}
properties:
value:
{ type: "Float32", floatEncoding: "eNotation", readWrite: "RW", minimum: "300", maximum: "1100", scale: "0.01", defaultValue: "0" }
units:
{ type: "String", readWrite: "R", defaultValue: "hPa" }
- name: Humidity
description: "Read Humidity from BME680"
attributes:
{ Pin_Num: "I2C-1", Interface: "I2C", Type: "BME680"}
properties:
value:
{ type: "Float32", floatEncoding: "eNotation", readWrite: "RW", minimum: "10", maximum: "90", defaultValue: "0" }
units:
{ type: "String", readWrite: "R", defaultValue: "rH" }
deviceCommands:
- name: Get_ButtonState
get:
- { operation: "get", object: "ButtonState", property: "value", parameter: "ButtonState" }
Expand All @@ -139,6 +164,11 @@ resources:
- name: Get_SoundIntensity
get:
- { operation: "get", object: "SoundIntensity", property: "value", parameter: "SoundIntensity" }
- name: Get_TempPressHumidity
get:
- { index: "1", operation: "get", object: "Temperature", property: "value", parameter: "Temperature" }
- { index: "2", operation: "get", object: "Pressure", property: "value", parameter: "Pressure" }
- { index: "3", operation: "get", object: "Humidity", property: "value", parameter: "Humidity" }
- name: Set_GreenLed
set:
- { operation: "set", object: "Green-LED", property: "value", parameter: "Green-LED" }
Expand All @@ -160,7 +190,7 @@ resources:
set:
- { operation: "set", object: "Grove-Relay", property: "value", parameter: "Grove-Relay" }

commands:
coreCommands:
- name: Get_ButtonState
get:
path: "/api/v1/device/{deviceId}/Get_ButtonState"
Expand Down Expand Up @@ -205,6 +235,17 @@ commands:
description: "service unavailable"
expectedValues: []

- name: Get_TempPressHumidity
get:
path: "/api/v1/device/{deviceId}/Get_TempPressHumidity"
responses:
- code: "200"
description: "valid and accepted"
expectedValues: ["Temperature", "Pressure", "Humidity"]
- code: "503"
description: "service unavailable"
expectedValues: []

- name: Set_GreenLed
put:
path: "/api/v1/device/{deviceId}/Set_GreenLed"
Expand Down Expand Up @@ -294,3 +335,4 @@ commands:
- code: "503"
description: "service unavailable"
expectedValues: []

42 changes: 19 additions & 23 deletions res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,30 @@
ProfilesDir = ""
SendReadingsOnChanged = true

[Driver]
BME680_Temp_Offset = -1.0

[Logging]
RemoteURL = ""
File = "-"

[[Schedules]]
Name = "Schedule_Grove"
Frequency = "PT2S"

[[ScheduleEvents]]
Name = "RotarySensorMeasurements"
Schedule = "Schedule_Grove"
Path = "/api/v1/device/all/Get_RotarySensorMeasurements"

[[ScheduleEvents]]
Name = "LightIntensity"
Schedule = "Schedule_Grove"
Path = "/api/v1/device/all/Get_LightIntensity"

[[ScheduleEvents]]
Name = "SoundIntensity"
Schedule = "Schedule_Grove"
Path = "/api/v1/device/all/Get_SoundIntensity"

[[DeviceList]]
Name = "GroveDevice"
Profile = "Grove_Device"
Description = "Grove Device to Read/Write sensors connected to GrovePI"
Labels = [ "Grove LED, Grove Button, Grove Buzzer, Grove LCD, Grove LightSensor, Grove Relay, Grove RotarySensor, Grove SoundSensor" ]
[DeviceList.Addressable]
Address = "/api/v1/device/GroveDevice"

Labels = [ "Grove LED, Grove Button, Grove Buzzer, Grove LCD, Grove LightSensor, Grove Relay, Grove RotarySensor, Grove SoundSensor, Grove BME680Sensor" ]
[DeviceList.Protocols]
[DeviceList.Protocols.Other]
Address = "/api/v1/device/GroveDevice"
[[DeviceList.AutoEvents]]
Resource = "Get_RotarySensorMeasurements"
OnChange = false
Frequency = "2s"
[[DeviceList.AutoEvents]]
Resource = "Get_LightIntensity"
OnChange = false
Frequency = "2s"
[[DeviceList.AutoEvents]]
Resource = "Get_SoundIntensity"
OnChange = false
Frequency = "2s"
28 changes: 14 additions & 14 deletions scripts/Dockerfile.alpine-3.8 → scripts/Dockerfile.alpine-3.9
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
FROM alpine:3.8 as builder
FROM alpine:3.9 as builder
MAINTAINER Bindu Rao <bindu@iotechsys.com>
RUN apk add --update --no-cache build-base git gcc cmake make linux-headers yaml-dev libmicrohttpd-dev curl-dev
RUN apk add --update --no-cache build-base git gcc cmake make linux-headers yaml-dev libmicrohttpd-dev curl-dev util-linux-dev

COPY scripts /device-grove/scripts
COPY src /device-grove/src/
RUN mkdir -p /device-grove/build

WORKDIR /device-grove
RUN /device-grove/scripts/build_deps.sh
RUN /device-grove/scripts/build_deps.sh 1
RUN /device-grove/scripts/build.sh

FROM alpine:3.8
FROM alpine:3.9

RUN apk add --update --no-cache linux-headers yaml libmicrohttpd curl-dev
RUN apk add --update --no-cache linux-headers yaml libmicrohttpd curl libuuid

COPY --from=builder /device-grove/build/release/device-grove /device-grove/build/release/
COPY --from=builder /device-grove/build/release/device-grove /.
COPY --from=builder /usr/lib/libcsdk.so /usr/lib
COPY --from=builder /usr/include/edgex /usr/include/edgex
COPY --from=builder /usr/include/thpool.h /usr/include/thpool.h
COPY --from=builder /usr/include/iot /usr/include/iot
COPY --from=builder /usr/local/include/mraa /usr/local/include/
COPY --from=builder /usr/local/include/mraa.h /usr/local/include/
COPY --from=builder /usr/local/lib/libmraa.so* /usr/local/lib/
COPY --from=builder /usr/local/lib64/libcbor.so* /usr/local/lib64/

COPY VERSION /device-grove/
COPY LICENSE /device-grove/
COPY Attribution.txt /device-grove/
COPY res /device-grove/res/
COPY profiles /device-grove/profiles
COPY VERSION /.
COPY LICENSE /.
COPY Attribution.txt /.
COPY res /res
COPY profiles /profiles

ENTRYPOINT ["/device-grove/build/release/device-grove", "-c"]
CMD ["/device-grove/res/"]
ENTRYPOINT ["/device-grove"]
CMD ["--confdir=/res"]
22 changes: 16 additions & 6 deletions scripts/build_deps.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh
set -e -x

BUILD_CSDK=$1

# Dependencies
if [ ! -d deps ]
then
Expand All @@ -15,21 +17,29 @@ then

# patch for raspberryPI
patch -p1 < /device-grove/scripts/rpi_patch

mkdir -p build && cd build

# always install in lib folder
cmake -DBUILDSWIG=OFF -DCMAKE_INSTALL_LIBDIR=lib ../.
make && make install

# get c-sdk from edgexfoundry
# get c-sdk from edgexfoundry and build
if [ "$BUILD_CSDK" = "1" ]
then
cd /device-grove/deps
wget https://github.com/edgexfoundry/device-sdk-c/archive/0.7.1.tar.gz
tar -xzf 0.7.1.tar.gz
cd device-sdk-c-0.7.1

git clone https://github.com/PJK/libcbor
sed -e 's/-flto//' -i libcbor/CMakeLists.txt
cmake -DCMAKE_BUILD_TYPE=Release -DCBOR_CUSTOM_ALLOC=ON libcbor
make
make install

wget https://github.com/edgexfoundry/device-sdk-c/archive/edinburgh.tar.gz
tar -xzf edinburgh.tar.gz
cd device-sdk-c-edinburgh
./scripts/build.sh
cp -rf include/* /usr/include/
cp build/release/c/libcsdk.so /usr/lib/

fi
rm -rf /device-grove/deps
fi
Loading