Code Monkey home page Code Monkey logo

beep's Introduction

BEEP - Open source bee monitoring (v3.0.1)

BEEP is open source combination of a bee monitoring app + automatic bee hive measurement device. It's key feature is to integrate a user friendly responsive web app for manual inspections with automatically measured sensor data. Check the website https://beep.nl/index.php/home-english for more information.

BEEP System overview

BEEP System overview

You are free to use our BEEP app and API.

BEEP App

The BEEP app is a VUE app, communicating with a (Laravel PHP) BEEP API (this repository).

NB: The BEEP VUE (v3) app replaced the BEEP Angular JS (v2) app in 2021.

The BEEP app is publicly available at: https://app.beep.nl. It has about 5000+ users worldwide and is available in 9 languages (Jan 2022).

BEEP API / Backend

This repository. Serving both app v3 as app v2. Publicly available at https://api.beep.nl

BEEP base

The BEEP base v3 is an open source ultra low power automatic hive monitoring system. Design of the device and PCB (with accompanying firmware) be found at [this repository]](https://github.com/beepnl/measurement-system-v3). It measures weight, temperature and sound. We produce a yearly batch of BEEP bases for the European (868MHz LoRaWAN) market, that are sold via the BEEP webshop. The BEEP base sends it's data through The Things Network LoRaWAN to the BEEP API.

You can also use your own measurement device with the BEEP app by POSTing your measurement data to the BEEP API.

The BEEP base can be configured by Bluetooth using our native BEEP base apps for Android and iOS.

BEEP API Installation

If you would like to install this BEEP API (the code in this) repo on your own server, or contribute; please read on below.

0. Server specs

NB: We recommend to use Laravel Forge to easily install all the software you need on any Linux based server

1. Clone this repo

git clone https://github.com/beepnl/BEEP.git
cd BEEP

2. Database

Create a MySQL database (type: InnoDB, encoding: UTF_8, collation: utf8mb4_unicode_ci) called:

bee_data

NB: Make sure to pass the user and credentials to the newly made .env file after step 3.

3. Install dependencies

if [ ! -f '.env' ]; then cp .env.example .env && php artisan key:generate; fi
composer install && sudo chmod -R 777 storage && sudo chmod -R 777 bootstrap/cache && php artisan storage:link && php artisan migrate --force

NB: To stick to a certain PHP version (on the server e.g. 7.4.33), use composer install --ignore-platform-reqs or composer update --ignore-platform-reqs

4. Set up your end-points

Laravel Forge

Simply use the default Nginx template and install Let's Encrypt SSL certificate via the interface.

Apache

Install the desired config files from /apache to your apache/sites-available folder and enable them with a2ensite [config file name]

Install SSL certificates to your endpoints with Let's Encrypt

5. Add Influx database

Installation

Install InfluxDB or set up an account at InfluxCloud

Optional: migrate from local Influx v1.7.3 db to managed InfluxDB Cloud

wget https://dl.influxdata.com/influxdb/releases/influxdb2-client-2.0.6-linux-amd64.tar.gz
tar xvfz influxdb2-client-2.0.6-linux-amd64.tar.gz
cd influxdb2-client-2.0.6-linux-amd64
./influx config create --config-name beep-cloud-test --host-url https://eu-central-1-1.aws.cloud2.influxdata.com --org [your-email] --token [copy-from-influx-cloud] --active
./influx v1 dbrp create --db [influx-v1-db-name] --rp autogen --bucket-id [copy-from-influx-cloud] --default
sudo influx_inspect export -datadir /var/lib/influxdb/data -waldir /var/lib/influxdb/wal -database test_beep_nl -retention autogen -start 2021-01-01T00:00:00Z -end 2022-01-01T00:00:00Z -out test_beep_nl_temp.lp
sudo tail -n +4 test_beep_nl_temp.lp > test_beep_nl.lp
./influx write --bucket-id [copy-from-influx-cloud] --file test_beep_nl.lp --rate-limit "300 MB / 5 min" --skipRowOnError

Setup

Create a databse and user

influx
> CREATE USER user_influx WITH PASSWORD 'pass_influx' WITH ALL PRIVILEGES
> CREATE DATABASE bee_data
> exit

NB: Make sure to pass the user and credentials to the .env file that has been created in step 3. NB: If your Influx version was < 1.1.x (no TSI support), when using backups to transfer data: first install the old version that you are currently using on a new server, import the backups, then update to the newest Influx version!

Configuring your own back-end system

1. Set up valid credentials

a. Set up e-mail credentials in the .env config file

b. (Angular JS webapp v2) For the webapp to reach the API, rename the file 'public/webapp/js/constants.js.example' to 'public/webapp/js/constants.js' and edit it to change the 'api_url' to your own back-end API end-point

c. To enable schedules (e.g. for loading weather data), install a crontab with sudo crontab -e and add: * * * * * cd /home/bitnami/apps/appdir && /opt/bitnami/php/bin/php artisan schedule:run >> /dev/null 2>&1

2. Register new user

a. Go to api.[your_domain]/webapp#!/login/create

b. Create a new user

c. Promote the user to 'superadmin'

Open your database (with a database viewer like PhpMyadmin, Sequel Pro, MySQL Workbench, etc.), or just do a command line query: Define a relation in table role_user with (1,1) (linking user_id 1 to role_id 1).

Your user has just been promoted to the super administrator of the system, so you can use the back-end management interface to configure the complete system.

d. Go to api.[your_domain]/admin to log in with the same credentials that you created your app user with in step 3b.

e. You should see the back-end dashboard, looking like this:

Management interface

BEEP Management interface

Installation using docker compose

A simple setup for small installations can be achived with docker-compose. The tool will spinn up a mysqldb, influx, a webserver and initialize the beep database.

  1. Install docker-compose
  2. Checkout BEEP and switch into the code repository
  3. Adjust docker-compose.yaml(set suitable environment variables).
  4. Run docker-compose up. During the first start, you might see some database connectivity issues. Docker compose will restart the BEEP Server component untill a database connection is available. So don't worry.
  5. Register as a new user: http://localhost:8000/webapp.
  6. Grant user administrator rights: docker-compose exec mysql mysql -h localhost -P 3306 -ppass -u user -D bee_data -Bse "INSERT INTO role_user (user_id,role_id) VALUES(1,1);"
  7. Login to mamagement interface: http://localhost:8000/admin

To upgrade beep to the latest version, simply stop and start docker-compose.

As the setup is based on docker containers, code changes inside the repository will not have an effeact till the underlying docker image is updated.

Get your BEEP base measurement data into the BEEP app

  1. Create a TTN account at https://console.thethingsnetwork.org/ (or other LoRa network) and create an HTTP integration pointing to https://api.beep.nl/api/lora_sensors, or point your own measurement device data stream HTTP POST to https://api.beep.nl/api/sensors (please refer to our Slack channel for API description)
  2. Use the native Android / iOS app to configure your BEEP base by Bluetooth.
  3. With the app, connect the BEEP base to the BEEP TTN network (auto configuration), or connect the BEEP base (manually) to your own LoRa network
  4. The native app adds a BEEP base measurement device to your BEEP account
  5. If you are still with a fresh installation, login to your api (```api.[your_domain]/login´´´) and got to Devices -> Sensor Measurements. Add sensor definitions here.
  6. You can see the measurement data at the Data menu item of the webapp.

Contributing

Thank you for considering contributing to the BEEP framework! If you would like to contribute, please fork this repository, edit on your Github account, and finally send Pull Requests to this repository to include new features.

Please request access to our slack community at https://beep-global.slack.com if you would like to know more, or cooperate.

Adding a language

  1. Create a Beep user account at https://app.beep.nl/#!/login/create
  2. Send an e-mail to [email protected] with you user e-mail address, asking to become a translator for a certain language
  3. Log into the backend to start translating

Roadmap

In short on our roadmap:

Upcoming:

  • Many new features for health checking and sensor measurements (2019 Q3 - 2023 Q3)

History:

  • BEEP base v3.3 - December 2021
  • App v3 (VUEjs) development - 2020-2021
    • Alerts (e-mail, app)
    • Many improvements
  • BEEP base v3.2 - April 2021
  • App v2.2.1 - Continuous App improvements - 2020-2021
  • App v2.2 - January 2020
    • Photo addition
    • Weather data
    • Research
    • Helpdesk integration
  • BEEP base v3.1 (2019 Q3-Q4)
  • App v2.1.0 - May 29 2019
    • Collaborate: Hive, data and inspection list sharing (2019 Q2)
    • User feedback improvements (2019 Q1 + Q2)
  • App v2.0.2 - April 30 2019
    • Integration sensor data / hive inspections (2018 Q4)
  • BEEP base v2 - December 2019
  • App v2.0 - July 10th 2018
    • Apiary and hive overview improved
    • Dynamic inspection list
    • Create your own inspection list and order
    • Automatic measurement view improvement
  • App v1.0 - June 15th 2017
    • One click creation of apiaries with multiple hives
    • Manual hive inspections
    • Display automatic measurements

Documentation

Documentation and manual of the app can be found at https://beep.nl/beep-app.

API documentation of the BEEP API can be found at https://api.beep.nl/docs/.

For Developers - Getting started

Here we describe the first steps to setup a programming environment, in case you want to contribute to the app but are not yet a professional laravel developer.

If you setup your own BEEP instance, you might still want to have a local version running, so that you can test changes immedieatly.

  • Clone the repository to your Laptop or Computer.

  • We recomend using php version 8.0

  • We recommend to install and use Laravel Valet.

    For Mac: https://laravel.com/docs/10.x/valet#installation (you might want to browse to the newest version)

    For Linux: https://cpriego.github.io/valet-linux/

    For Linux, make sure that you meet the requirements: https://cpriego.github.io/valet-linux/requirements

  • Install following additional php extensions: fpm, intl, gd, mysql

  • Make sure valet uses the correct php version

    For Mac: valet use [email protected]

    For Linux: valet use 8.0

  • fill out the .env file

    Set APP_URL=beep.test or choose an other url

    Set the information for the mysql, influx and redis connections. If you connect to your remote server, make sure the ports are open on your server. You might also need to set a password for redis in this case.

    Use php artisan key:generate to generate a key and add it to your env file.

  • navigate to /public and run valet link

  • run valet secure to add an ssl certificate

  • run composer install and valet start

  • You should be able to access the app, e.g. on https://beep.test

Tips and Troubleshooting:

  • If you get an error like "Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0"." you might need to run composer global update

  • You can also link your local vue app to this url in the .env file. If you do this and you get cors errors, this might be because of one of the following reasons:

  • The url you set is wrong. You have to open beep.test first (or your url) and add a security exception for your browser.

  • If you want to test your new api functions, we recommend to use Postman: https://www.postman.com/downloads/

  • In some cases, e.g. in case you made changes to the measurements database, you need to run php artisan cache:clear to make the changes effective in your api calls.

Security Vulnerabilities

If you discover a security vulnerability within BEEP, please send an e-mail to [email protected].

License

The BEEP framework is open-sourced software licensed under the GNU AGPLv3 license.

beep's People

Contributors

dependabot[bot] avatar ezja avatar joek avatar juliabd avatar pvgennip avatar thediren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

beep's Issues

Property "inside" on sensordefinitions not accepting boolean values

A post to PATCH sensordefinition/178 with body:

{"device_hardware_id":"0123F2A286A98ACEEE","input_measurement_id":77,"inside":true,"name":"My first temp sensor"}

Returns:

{"id":178,"created_at":"2020-05-20 20:19:03","updated_at":"2020-06-04 23:39:02","name":"My first temp sensor","inside":null,"offset":null,"multiplier":null,"input_measurement_id":77,"output_measurement_id":null,"device_id":224,"input_abbr":"t_0","output_abbr":null}

So the true boolean is patched to null.

Throw a 401 error when using no or expired token when using content/type application/json

Currently, when consuming the api as a JSON client, with content-type set to application/json, a 302 redirect is thrown when using none or an expired/invalid token. There is no way for the client to detect that its token has expired. Other than having a 302 imply an authentication failure and grep the body for login :(

Please throw 401 errors when the token is not present or invalid, and the content-type is anything other than html, e.g. application/json.

Also see #14 for further improvements. Currently there is no way to derive the ttl of the token and we need to wait for a call to fail, before we present the login screen.

api/user PATCH updates needed

  1. verify new email after it has been changed
  2. refresh API token after user patch request
  3. in API docs: change 'password_confirm' to 'password_confirmation' and add 'name' as parameter
  4. add current password as required parameter for patch request

Internal server error when trying to create a sensor definition

When calling POST /api/sensordefinition with the following (minimal) body:

{"device_hardware_id":"0e0123f2a286a98aceee","offset":11,"multiplier":1,"input_measurement_abbreviation":"w_v"}

It works. But when doing the same with the following payload:

{"device_hardware_id":"0e0123f2a286a98aceee","offset":11,"multiplier":1,"input_measurement_abbreviation":"w_v","output_measurement_abbreviation":"weight_kg"}

I get an internal server error:

LogicException: App\Measurement::pq_name must return a relationship instance. in file /opt/bitnami/apps/test.beep.nl/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php on line 420

The issue seems to be with the output_measurement_abbreviation. When adding this, the 500 appears. We discussed before that weight_kg is the appropriate value, and it worked before. I also checked the taxonomy if this value was present, just to be sure. But no go.

LoRa message of new BEEP base registers wrong hardware_id

In the hardware_id of the registered BEEP bases, there is the first byte of the response included (i.e. "0e") This should be removed from:

  • Database
  • LoRa message port 2 interpretation on API (KPN)
  • LoRa message port 2 interpretation on TTN decoder (TTN)

When editing an inspection make sure colony_size value is not overwritten when hive properties change

For inspections including colony size calculations (via top photo analysis or liebefelder method):
When hive properties (frames, brood/honey layers) change, the input values for colony_size change, and therefore the colony_size is recalculated. This also happens when editing an inspection where colony_size has previously been calculated, even if you don't want to edit the colony_size. The recalculated colony_size value will be saved when saving the edited inspection, which is undesirable.

Suggestion for solution:
Set the frame and layer values for colony_size calculation to 'null' by default. If these values are null, retrieve the colony_size value from the database (if existent) as colony_size value. As soon as the values are (re-)entered, the calculated value will be displayed instead.

Change response for collection endpoints in case of empty collections

Please have collection endpoints, such as GET /api/devices return an empty array if the collection is empty, and make sure the http response code is also 200 OK.

Also have this behavior when applying query strings to collection endpoints e.g. GET /api/devices?hardware_id.

Currently endpoints, such as the one above, throw a 404 code and a string. This makes the client deserialization harder than necessary (invalid json, exception branching).

Current behavior for non collection endpoints such as GET /api/devices/{id} is fine as is (404).

Not possible to delete a device if it has sensor attached

DELETE /devices/{id} results in the following 500 error when the device to delete has sensors attached:

SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test_beep_nl`.`sensor_definitions`, CONSTRAINT `sensor_definitions_device_id_foreign` FOREIGN KEY (`device_id`) REFERENCES `sensors` (`id`) ON UPDATE CASCADE) (SQL: delete from `sensors` where `id` = 213)```

Adding weather data from KNMI

Dear Pim and Marten,

I just became aware of #67 and want to humbly make you aware about what @gutzbenj, @wetterfrosch and all other contributors are conceiving over at https://github.com/earthobservations/wetterdienst.

While this is currently just about ingesting weather information from @DeutscherWetterdienst, we want to tap into data from other domestic weather agencies soon.

So, maybe you can share some information about where we might want to look into when approaching open weather data from the Dutch weather agency?

With kind regards,
Andreas.

cc @ClemensGruber

TTN decoder yields wrong hardware_version and hardware_id?

Just looking at the code of ttn-payload-decoder.js the decoder, I think it has two errors for hardware_version and one for hardware_id.

The test payload of 0100010003000402935685E6FFFF94540E01237A26A67D24D8EE1D000001 on port 2 currently yields "37718.34278 ID:16749907" and "01237a26a67d24d8ee" but I think those should read "168790.34278 ID:4294939732" and "0e01237a26a67d24d8ee".

hardware_version is missing first byte?

decoded.firmware_version = ... + bytes[6]);
decoded.hardware_version = ((bytes[8] << 8) + bytes[9]) + ...

The code skips bytes[7]. Also, the code seems to document that's actually part of this hw version attribute:

// 0100010003000402935685E6FFFF94540E01237A26A67D24D8EE1D000001
// 01 00 01 00 03 00 04 02 93 56 85 E6 FF FF 94 54 0E 01 23 7A 26 A6 7D 24 D8 EE 1D 00 00 01 
// 0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 
//    pl  fw version    hw version                 ATTEC ID (14)                 app config

Same goes for other parts of the decoder, skipping bytes[9]:

decoded.firmware_version = ... + bytes[8]);
decoded.hardware_version = ((bytes[10] << 8) + ... 

hardware_version is not handling the MSB in "ID" correctly?

Note that when using bitwise operators in a TTN decoder, JavaScript expects signed 32 bits numbers using two's complement encoding, hence allowing for numbers from -2,147,483,648 through 2,147,483,647.

Knowing that, the following smells:

... + " ID:" + ((bytes[12] << 32) + (bytes[13] << 16) + (bytes[14] << 8) + bytes[15]);

First, I'm quite sure the << 32 should read << 24? As JavaScript is working with 32 bits values, using << 32 effectively is the same as not shifting at all: 0xFF << 32 is actually 0x000000FF, and 0xFF << 40 is 0x0000FF00, and so on. Unlikely that's what you want?

Second, given that JavaScript expects two's complement encoding, using bytes[12] << 24 will yield a negative number if bytes[12] has its leftmost bit set. (So: if the value is 0x80 or above, or if bytes[12] & 0x80 is not zero.)

When using << 24 rather than << 32 then you can test with the payload you're already showing in the code, which holds FFFF9454 in 0100010003000402935685E6FFFF94540E01237A26A67D24D8EE1D000001 on port 2.

This can be circumvented by using the zero-fill right shift >>> (which, unlike the other bitwise operators, returns an unsigned 32 bits integer), along with actually shifting zero bits. Or by not using bitwise operators at all. Any of the following will work:

... + " ID:" + ((bytes[12] << 24 >>> 0) + (bytes[13] << 16) + (bytes[14] << 8) + bytes[15]);

... + " ID:" + (((bytes[12] << 24) + (bytes[13] << 16) + (bytes[14] << 8) + bytes[15]) >>> 0);

... + " ID:" + (bytes[12] * 0x1000000 + bytes[13] * 0x10000 + bytes[14] * 0x100 + bytes[15]);

Aside, when using bitwise OR rather than addition, one needs fewer parentheses, as addition has a higher precedence than the shift operator:

... + " ID:" + ((bytes[12] << 24 | bytes[13] << 16 | bytes[14] << 8 | bytes[15]) >>> 0);

Better yet, just define a helper that takes an array of bytes and returns an unsigned integer:

// Convert the array of bytes to an unsigned integer, MSB.
// This is only safe up to 0x1FFFFFFFFFFFFF, so: 6 bytes.
function toUInt(bytes) {
  return bytes.reduce(function(acc, b) {
    // Unsigned, so don't use any bitwise operators, which would always
    // yield a signed 32 bits integer instead.
    return acc * 0x100 + b;
  }, 0);
}

With another helper to accept a full array of bytes and a start index and length:

function getUInt(bytes, start, len) {
  return toUInt(bytes.slice(start, start + len));
}

...one could then rewrite:

decoded.hardware_version = ((bytes[8] << 8) + bytes[9]) + "." + ((bytes[10] << 8) + bytes[11])
    + " ID:" + ((bytes[12] << 32) + (bytes[13] << 16) + (bytes[14] << 8) + bytes[15]);

...to:

decoded.hardware_version = getUInt(bytes, 7, 3) + "." + getUInt(bytes, 10, 2)
    + " ID:" + getUInt(bytes, 12, 4);

(This also assumes bytes[7] indeed needs to be included.)

hardware_id is missing first byte?

The code skips byte[16]. The documentation in the code suggests it's part of hardware_id, named ATTEC ID in the example.

decoded.hardware_version = ... + bytes[15]);
decoded.hardware_id      = toHexString(bytes[17], 2) + toHexString(bytes[18], 2) + toHexString(bytes[19], 2)
                         + toHexString(bytes[20], 2) + toHexString(bytes[21], 2) + toHexString(bytes[22], 2)
                         + toHexString(bytes[23], 2) + toHexString(bytes[24], 2) + toHexString(bytes[25], 2);

Also, adding a helper that takes an array to print as hex keeps the code short:

// Get a hexadecimal representation with leading zeroes for each byte.
function toHex(bytes) {
  return bytes.reduce(function(acc, byte) {
    return acc + ('0' + byte.toString(16)).slice(-2);
  }, '');
}

...

decoded.hardware_id = toHex(bytes.slice(16, 26));

Bonus

It seems lines like the following are meant to convert fewer than 4 bytes into a signed integer?

decoded.t_i = hexToInt(toHexString(bytes[ds18b20_values_start_byte], 2) 
            + toHexString(bytes[ds18b20_values_start_byte+1], 2), 4); 

If true, then sign extension is your friend:

// Sign-extend a 16 bits number to 32 bits to make JavaScript understand negative values, by
// shifting the MSB 24 bits to the left, followed by a sign-propagating right shift of 16 bits
// to effectively shift 8 bits.
bits.decoded.t_i = bytes[ds18b20_values_start_byte] << 24 >> 16 | bytes[ds18b20_values_start_byte + 1];

Of course, a helper might be better:

// Get a signed integer from 2 bytes, MSB.
function toInt16(bytes) {
  // Sign-extend to 32 bits to support negative values: shift 16 bytes
  // too far to the left, followed by sign-propagating right shift
  return bytes[0] << 24 >> 16 | bytes[1];
}

function getInt16(bytes, start) {
  return toInt16(bytes.slice(start, start + 2));
}

...

bits.decoded.t_i = getInt16(bytes, ds18b20_values_start_byte);

Enjoy!

Force https in .htaccess

Hi,
I am pretty new to BEEP but I am super excited about the project as I had the idea of an open source hive management solution too but no time to dig into.

Currently I am working on a docker-compose deployment to simplify the deployment on a private server and local development (for this part some work is still needed).

During this process I faced one issue which is hard to automate.

Problem:
The force https section in the .htaccess file is preventing to run a none https deployment in a local setup. The result is, I have to adjust this file every time I am checking out the project.

Solution proposal:
If the force https part is part of the apache/beep-public.conf we can avoid having this inside the .htaccess.

Payload converter will not be supported in next release of TTN

The next version of the TTN LoRaWAN Stack, V3, is due on the community network somewhere this year. As per https://www.thethingsnetwork.org/forum/t/convert-custom-payload-to-lpp-payload-in-ttn-console/12171/9:

We’re dropping the converter and validator in V3 as they’re not being used; you can put conversion in the decoder, and it makes more sense to drop/filter out invalid values higher upstream.

And as per https://thethingsstack.io/v3.8.4/getting-started/migrating-from-v2/major-changes/

Payload Formats

The Things Network Stack V2 has support for payload decoders, converters, validators (for uplink) and encoders (for downlink). These can be either CayenneLPP or Javascript functions.

The Things Stack has support for an uplink payload formatter (similar to the payload decoder) and a downlink payload formatter (similar to the payload encoder). These can be set per application, and can even be overridden per end device. Similar to The Things Network Stack V2 , CayenneLPP and Javascript functions are supported.

Migrating the The Things Network Stack V2 payload encoder and decoder to an uplink and downlink payload formatter should be straightforward, since they have the same format.

So, it might be better to be prepared, and combine ttn-payload-decoder.js and ttn-payload-converter.js into a single Decoder.

Better yet, maybe decoding should be done in the BEEP backend?

colony_size not saved for liebefelder inspection category

When adding/editing an inspection, the number of bees calculated via the Liebefelder method is shown as 'total colony size', but the value is not saved in the inspection.

Also the input field with name 'colony_size' is not shown, which is ok from the user perspective, but may be part of the issue.

Change serialization of "inside" property on sensor definition

The documentation states that the "inside" property on sensordefinition is a bool. The api accepts both a number, a string, or a boolean. The response type from list sensordefinitions returns a number.

Please unify the typing to boolean in the response e.g. (see inside property)

  {
    "id": 78,
    "name": null,
    "inside": true,
    "offset": null,
    "multiplier": null,
    "input_measurement_id": 78,
    "output_measurement_id": null,
    "device_id": 125
  }

Add proxy endpoints for TTN

Please add two endpoints that can be used for proxying to the TTN application manager:

  • A GET for TTN devices: http://eu.thethings.network:8084/applications/beep-digital-hive-monitoring/devices/<deviceId>
  • A POST for TTN devices: http://eu.thethings.network:8084/applications/beep-digital-hive-monitoring/devices/<deviceId>

The post receives the following payload:

{
  "dev_id": "<deviceId>",
  "lorawan_device": {
    "app_id": "beep-digital-hive-monitoring",
    "dev_eui": "<devEui>", 
    "dev_id": "<deviceId>", 
    "app_key": "<appKey>",
    "app_eui": "70B3D57ED0028D38" 
  }
}

PATCH operations do not patch only the passed properties

When calling PATCH /api/sensordefinition/{id} with body:

{"device_hardware_id":"<REDACTED>", "inside":true,"name":"My first temp sensor"}

The result nullifies the properties that are not present. In particular the input output measurement types.

This is not the expected result on a PATCH operation (but PUT, maybe). It should only patch the properties that are passed, and leave the omitted properties to their current values.

Cannot update devices

After creating a device, using POST https://test.beep.nl/api/devices/ I receive a JSON which contains the id of the new device.

The documentation mentions PUT/PATCH https://test.beep.nl/api/devices/<id>. When calling this endpoint with a json payload:

{"key":"<samekey>","name":"DifferentBaseName","hardware_id":"<samehardwareid>"}

, I get the error:

{
  "errors": {
    "key": [
      "The key has already been taken."
    ]
  }
}

When omitting the key, I get the error:

{
  "errors": {
    "key": [
      "The key field is required."
    ]
  }
}

Instructions - Installation server

Hey!

I'm impressed by the system which you developed and i would like to use it with my own server but i have problems with the installation of it.

Do you have instructions which works or even a Git container which works? For example the webapp directory is not existing in the public folder.
I used the master branch on a new Debian 9 machine.

Best Regards

Allow for deletion of devices

Add a DELETE /api/devices/id call which allows for deletion of devices. It is fine if this is only restricted to admins.

Error => ./run_actions.sh storage folder

root@localhost:/var/www/bee# ./run_actions.sh
Backup MySQL and Influx database (y/N)?
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Package jeremeamia/superclosure is abandoned, you should avoid using it. Use opis/closure instead.
Package phpoffice/phpexcel is abandoned, you should avoid using it. Use phpoffice/phpspreadsheet instead.
Generating optimized autoload files
Deprecation Notice: Class PHPExcel_Best_Fit located in ./vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/trend/bestFitClass.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class PHPExcel_Exponential_Best_Fit located in ./vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/trend/exponentialBestFitClass.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class PHPExcel_Power_Best_Fit located in ./vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/trend/powerBestFitClass.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class PHPExcel_Polynomial_Best_Fit located in ./vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/trend/polynomialBestFitClass.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class PHPExcel_Logarithmic_Best_Fit located in ./vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/trend/logarithmicBestFitClass.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class PHPExcel_Linear_Best_Fit located in ./vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/trend/linearBestFitClass.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Carbon 1 is deprecated, see how to migrate to Carbon 2.
https://carbon.nesbot.com/docs/#api-carbon-2
You can run './vendor/bin/upgrade-carbon' to get help in updating carbon and other frameworks and libraries that depend on it.

Illuminate\Foundation\ComposerScripts::postAutoloadDump
@php artisan package:discover --ansi
Discovered Package: appzcoder/crud-generator
Discovered Package: barryvdh/laravel-cors
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: fideloper/proxy
Discovered Package: intervention/image
Discovered Package: kalnoy/nestedset
Discovered Package: laravel/tinker
Discovered Package: laravelcollective/html
Discovered Package: lawnstarter/laravel-darksky
Discovered Package: maatwebsite/excel
Discovered Package: mcamara/laravel-localization
Discovered Package: mpociot/laravel-apidoc-generator
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: pdffiller/laravel-influx-provider
Package manifest generated successfully.
34 packages you are using are looking for funding.
Use the composer fund command to find out more!
Nothing to migrate.

ErrorException : symlink(): No such file or directory

at /var/www/bee/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:252
248| */
249| public function link($target, $link)
250| {
251| if (! windows_os()) {

252| return symlink($target, $link);
253| }
254|
255| $mode = $this->isDirectory($target) ? 'J' : 'H';
256|

Exception trace:

1 symlink("/var/www/bee/storage/app/public", "/var/www/bee/public/storage")
/var/www/bee/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:252

2 Illuminate\Filesystem\Filesystem::link("/var/www/bee/storage/app/public", "/var/www/bee/public/storage")
/var/www/bee/vendor/laravel/framework/src/Illuminate/Foundation/Console/StorageLinkCommand.php:35

Please use the argument -v to see more details.

Originally posted by @majo91 in #48 (comment)

Add expires_at to property to login response

The current response to POST /api/login returns the following body:

{
  "id": 16,
  "name": "redacted",
  "email": "[email protected]",
  "avatar": "default.jpg",
  "api_token": "redacted",
  "created_at": "2020-01-16 18:18:57",
  "updated_at": "2020-02-06 23:52:45",
  "last_login": "2020-02-06 23:52:45",
  "policy_accepted": "beep_terms_2018_05_25_avg_v1",
  "email_verified_at": "2020-01-16 18:19:14"
}

Please add an expires_at property that indicated the expiration date of the api token.
I also notice that the dates do not have a timezone included. I suggest switching to ISO8601 format with the timezone included: YYYY-MM-DDTHH:MM:SS+/-hh:mm -> 2020-01-16T20:34:22+01:00. Preferably all dates are UTC by default, unless requirements specify otherwise.

Duplicate keys in language files

289:3 error Duplicate key 'sensors' -> remove second key/value pair
376:3 error Duplicate key 'temperature' -> change second key to outsideTemperature
379:3 error Duplicate key 'humidity' -> remove second key/value pair
394:3 error Duplicate key 'year' -> change first key to years_old

Listing sensor definitions gives a server error.

When calling GET https://test.beep.nl/api/sensordefinition I receive a 500 server error.

I think I have no definitions (can't check ;) so it might be a null pointer.

First part of error:

<!DOCTYPE html><!--


ErrorException: Trying to get property of non-object in file /opt/bitnami/apps/test.beep.nl/app/Http/Controllers/Api/SensorDefinitionController.php on line 74
Stack trace:

Missing sensor constants in constants.js

For example device 257 (Kast 1 - BEEPBASE-TEST-0E93) (s_bin_480_532) and device 60 (Test 3 - BEEPBASE-EBE9) (s_bin_0_201 to 1807_2008).

SOUND:

    's_bin_480_532',
    's_bin_0_201',
    's_bin_201_402',
    's_bin_402_602',
    's_bin_602_803',
    's_bin_803_1004',
    's_bin_1004_1205',
    's_bin_1205_1406',
    's_bin_1406_1607',
    's_bin_1607_1807',
    's_bin_1807_2008',

SENSOR_NAMES:

  s_bin_480_532: '480-532Hz',
    s_bin_0_201: '0-201Hz', 
    s_bin_201_402: '201-402Hz',
    s_bin_402_602: '402-602Hz',
    s_bin_602_803: '602-803Hz',
    s_bin_803_1004: '803-1004Hz',
    s_bin_1004_1205: '1004-1205Hz',
    s_bin_1205_1406: '1205-1406Hz',
    s_bin_1406_1607: '1406-1607Hz',
    s_bin_1607_1807: '1607-1807Hz',
    s_bin_1807_2008: '1807-2008Hz',

SENSOR_UNITS:

    s_bin_480_532: '',
    s_bin_0_201: '',
    s_bin_201_402: '',
    s_bin_402_602: '',
    s_bin_602_803: '',
    s_bin_803_1004: '',
    s_bin_1004_1205: '',
    s_bin_1205_1406: '',
    s_bin_1406_1607: '',
    s_bin_1607_1807: '',
    s_bin_1807_2008: '',

Include hive_layers as an argument for creating hives when saving location

Issue: Creating a new apiary gives the error that only 14 out of 15 arguments are provided for the createHive call on line 293 of HiveFactory.php, inside createMultipleHives function. The 'hive_layers' argument (see end of line 15) is missing. (The result is that new location is created in the db, but without any hives or hive_layers)

Solution: Please update 'createMultipleHives' function (in HiveFactory.php, called in LocationController.php) to include hive_layers as an argument.

-in LocationController, please call the property 'layers' instead of 'hive_layers' (better for my code consistency)
-ignore 'brood_layers' and 'honey_layers' properties whenever 'layers' is not null? Or whenever 'brood_layers' and 'honey_layers' are null / undefined?

Standardize all error messages

Suggested format:

{
  "error": "some_immutable_error_enum_string_so_we_can_differentiate",
  "message": "This could contain some detail, and can be different for each invocation",
}

No need to add the http status code, since that's already in the response.

If you want to keep the possibility open for multiple errors, if applicable, you can decide to always return an array of errors such as:

[
  {
    "error": "some_error",
    "message": "some message",
  },
    "error": "some_other_error",
    "message": "some other message",
  },
]

But if you do, please always return errors an array for all calls, even if there is only one error.

Numerical Hive settings at apiary create are not limited to numbers

Problem: When creating a new apiary, you can choose several options at the hive settings ("Hive amount at this location", "brood layers", etc.) These probably should be limited to numerical values, but the user can actually type in any value, like characters or special symbols.

Handling email addresses with + characters

Dear @pvgennip,

just a quick note. When registering for an account with an email address like [email protected], we found that the form-prefill back on the login page you are redirected to after confirming the activation email would not honor plus characters (+) properly.

This yielded
image
to us.

Just a convenience thing, not really a stopper bug.

Cheers,
Andreas.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.