Skip to content

Commit

Permalink
breaking: rename library to LualtekRAKRUI (#2)
Browse files Browse the repository at this point in the history
* breaking: rename library to rakrui

* chore: remove src.ino polluting file
  • Loading branch information
LasaleFamine authored Feb 12, 2024
1 parent 2f06872 commit 14d8035
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 71 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.vscode/ipch
build
.DS_Store
src/src.ino
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,63 @@
# LualtekRAK3172 Arduino Library
# LualtekRAKRUI Arduino Library

The LualtekRAK3172 library is an opinionated wrapper around the RUI3 API by RAKWireless. It simplifies the usage of the RAK3172 LoRa module in Arduino projects, providing a convenient interface for configuring and interacting with the module.
The LualtekRAKRUI library is an opinionated wrapper around the RUI3 API by RAKWireless. It simplifies the usage of the RAK RUI3 LoRa module in Arduino projects, providing a convenient interface for configuring and interacting with the module.

For more information about the RUI3 API, refer to the [RUI3 Documentation](https://docs.rakwireless.com/RUI3/#overview).

For more information about the RAK3172 module, refer to the [RAK3172 Documentation](https://docs.rakwireless.com/Product-Categories/WisDuo/RAK3172-Evaluation-Board/Overview/#product-description).

## Features

- Simplified setup and configuration of the RAK3172 LoRa module.
- Simplified setup and configuration of the RAK RUI3 LoRa module.
- Handling of downlink messages for changing duty cycle.
- Timer-based scheduling for uplink transmissions.
- Support for sending data packages to the LoRaWAN network.

## Installation

You can install the LualtekRAK3172 library through the Arduino Library Manager or manually as a ZIP file.
You can install the LualtekRAKRUI library through the Arduino Library Manager or manually as a ZIP file.

### Arduino Library Manager (Recommended)

1. Open the Arduino IDE.
2. Go to **Sketch** -> **Include Library** -> **Manage Libraries**.
3. In the Library Manager, search for "LualtekRAK3172".
4. Click on the LualtekRAK3172 library and click the **Install** button.
3. In the Library Manager, search for "LualtekRAKRUI".
4. Click on the LualtekRAKRUI library and click the **Install** button.

### Manual Installation

1. Download the LualtekRAK3172 library as a ZIP file from the [GitHub repository](https://github.com/username/repo).
1. Download the LualtekRAKRUI library as a ZIP file from the [GitHub repository](https://github.com/username/repo).
2. In the Arduino IDE, navigate to **Sketch** -> **Include Library** -> **Add .ZIP Library**.
3. Select the downloaded ZIP file of the library and click **Open**.

## Usage

### Prerequisites

- RAK3172 LoRa module.
- RAK with RUI3 LoRa module.
- Knowledge of the RUI3 API by RAKWireless.

### Library Initialization

To begin using the LualtekRAK3172 library, include the library header at the beginning of your sketch:
To begin using the LualtekRAKRUI library, include the library header at the beginning of your sketch:

```cpp
#include <LualtekRAK3172.h>
#include <LualtekRAKRUI.h>
```

Next, create an instance of the `LualtekRAK3172` class:
Next, create an instance of the `LualtekRAKRUI` class:

```cpp
const uint8_t appEui[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const uint8_t appKey[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
// With 20 minutes duty cycle
LualtekRAK3172 lualtek(appEui, appKey, MINUTES_20_COMMAND_INDEX);
LualtekRAKRUI lualtek(appEui, appKey, MINUTES_20_COMMAND_INDEX);
```
Replace `appEui` and `appKey` with your LoRaWAN application EUI and application key respectively.
### Configuration and Setup
To configure and set up the RAK3172 LoRa module, call the `setup()` method:
To configure and set up the RAK with RUI3 LoRa module, call the `setup()` method:
```cpp
bool success = lualtek.setup();
Expand Down Expand Up @@ -122,7 +121,7 @@ api.lorawan.registerRecvCallback(onDownlinkReceived);
#### Supported Downlink Commands
The LualtekRAK3172 library supports the following downlink commands:
The LualtekRAKRUI library supports the following downlink commands:
- **Change Duty Cycle**: To change the duty cycle, send a downlink message with `fPort` set to `DOWNLINK_ACTION_CHANGE_INTERVAL_PORT` (3) and the payload as follows:
Expand Down
12 changes: 6 additions & 6 deletions examples/BME280/BME280.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* NOTE: this example uses a custom IO expander that is powered on/off by WB_IO2: https://github.com/piecol/Wisblock_IO_extention_10x23
**/
#include "LualtekRAK3172.h"
#include "LualtekRAKRUI.h"
#include <Adafruit_Sensor.h>
#include <Tiny_BME280.h> // https://github.com/jasonacox/Tiny_BME280_Library

Expand All @@ -20,9 +20,9 @@ uint8_t APPKEY[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
#define debugSerial Serial

#if defined(CUSTOM_DEVEUI)
LualtekRAK3172 lltek(DEVEUI, APPEUI, APPKEY, MINUTES_20_COMMAND_INDEX, &debugSerial);
LualtekRAKRUI lltek(DEVEUI, APPEUI, APPKEY, MINUTES_20_COMMAND_INDEX, &debugSerial);
#else
LualtekRAK3172 lltek(APPEUI, APPKEY, MINUTES_20_COMMAND_INDEX, &debugSerial);
LualtekRAKRUI lltek(APPEUI, APPKEY, MINUTES_20_COMMAND_INDEX, &debugSerial);
#endif

#define POWER_UP_SENSOR_PIN (WB_IO2)
Expand Down Expand Up @@ -75,13 +75,13 @@ void setup()

if (!lltek.setup())
{
debugSerial.println("RAK3172 setup failed!");
debugSerial.println("Lualtek RAKRUI setup failed!");
return;
}

if (!lltek.join())
{
debugSerial.println("RAK3172 join failed!");
debugSerial.println("Lualtek RAKRUI join failed!");
return;
}

Expand All @@ -90,7 +90,7 @@ void setup()

if (!lltek.setupTimers(*uplinkRoutine))
{
debugSerial.println("RAK3172 setup timers failed!");
debugSerial.println("Lualtek RAKRUI setup timers failed!");
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LualtekRAK3172 KEYWORD1
LualtekRAKRUI KEYWORD1
getBatteryVoltage KEYWORD2
getUplinkInterval KEYWORD2
handleChangeDutyCycle KEYWORD2
Expand Down
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "lualtek-rak3172",
"name": "lualtek-rakrui",
"version": "0.2.0",
"description": "An opinionated wrapper around RUI3 APIs",
"repository": {
"type": "git",
"url": "https://github.com/lualtek/lualtek-rak3172.git"
"url": "https://github.com/lualtek/lualtek-rakrui.git"
},
"authors": [
{
Expand Down
8 changes: 4 additions & 4 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name=LualtekRAK3172
name=LualtekRAKRUI
version=0.2.0
author=Lualtek
maintainer=Lualtek <[email protected]>
sentence=Library for the Lualtek RAK3172 based board.
sentence=Library for the Lualtek RAK RUI3 based board.
paragraph=An opinionated wrapper around RUI3 APIs
category=Communication
url=https://github.com/lualtek/lualtek-rak3172
url=https://github.com/lualtek/lualtek-rakrui
architectures=*
includes=LualtekRAK3172.h
includes=LualtekRAKRUI.h
26 changes: 13 additions & 13 deletions src/LualtekRAK3172.cpp → src/LualtekRAKRUI.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "LualtekRAK3172.h"
#include "LualtekRAKRUI.h"

// LUT1_EV_Full Li-ION/LiPo scale up to 4.3v, 10 loops of sampling
const int adcValues[] = {1583, 1626, 1668, 1709, 1750, 1791, 1832, 1872, 1911, 1950, 1989, 2027, 2065, 2103, 2140, 2177, 2214, 2252, 2285}; // ADC readings
Expand Down Expand Up @@ -38,7 +38,7 @@ bool isKeyEmpty(const uint8_t *array, size_t size)
return true;
}

LualtekRAK3172::LualtekRAK3172(
LualtekRAKRUI::LualtekRAKRUI(
const uint8_t appEui[8],
const uint8_t appKey[16],
lualtek_dowlink_command_dutycycle_index_t dutyCycleIndex,
Expand All @@ -49,7 +49,7 @@ LualtekRAK3172::LualtekRAK3172(
memcpy(this->appKey, appKey, 16);
}

LualtekRAK3172::LualtekRAK3172(
LualtekRAKRUI::LualtekRAKRUI(
const uint8_t devEui[8],
const uint8_t appEui[8],
const uint8_t appKey[16],
Expand All @@ -62,12 +62,12 @@ LualtekRAK3172::LualtekRAK3172(
memcpy(this->appKey, appKey, 16);
}

void LualtekRAK3172::handleChangeDutyCycle(int commandIndex)
void LualtekRAKRUI::handleChangeDutyCycle(int commandIndex)
{
dutyCycleHandler.changeDutyCycle(commandIndex);
}

void LualtekRAK3172::onDownlinkReceived(SERVICE_LORA_RECEIVE_T *payload)
void LualtekRAKRUI::onDownlinkReceived(SERVICE_LORA_RECEIVE_T *payload)
{
switch (payload->Port)
{
Expand All @@ -89,10 +89,10 @@ void LualtekRAK3172::onDownlinkReceived(SERVICE_LORA_RECEIVE_T *payload)
}
}

bool LualtekRAK3172::setup()
bool LualtekRAKRUI::setup()
{
delay(1500);
debugStream->println(F("Lualtek RAK3172 Setup"));
debugStream->println(F("Lualtek RAKRUI Setup"));
debugStream->println(F("------------------------"));
// Setup duty cycle from EEPROM if available or use default
uint8_t uplinkIntervalFlash[1];
Expand Down Expand Up @@ -157,7 +157,7 @@ bool LualtekRAK3172::setup()
return true;
}

bool LualtekRAK3172::join()
bool LualtekRAKRUI::join()
{
// TODO: remove when RAK implments nbtrials
// Set the data rate to 0 (SF12, BW125KHz) for joining
Expand Down Expand Up @@ -206,7 +206,7 @@ bool LualtekRAK3172::join()
return true;
}

bool LualtekRAK3172::setClass(RAK_LORA_CLASS classType)
bool LualtekRAKRUI::setClass(RAK_LORA_CLASS classType)
{
if (!api.lorawan.deviceClass.set(classType))
{
Expand All @@ -217,7 +217,7 @@ bool LualtekRAK3172::setClass(RAK_LORA_CLASS classType)
return true;
}

bool LualtekRAK3172::setupTimers(void (*callback)())
bool LualtekRAKRUI::setupTimers(void (*callback)())
{
if (api.system.timer.create(RAK_TIMER_0, (RAK_TIMER_HANDLER)callback, RAK_TIMER_PERIODIC) != true)
{
Expand All @@ -234,7 +234,7 @@ bool LualtekRAK3172::setupTimers(void (*callback)())
return true;
}

bool LualtekRAK3172::send(uint8_t size, uint8_t *data, uint8_t fPort)
bool LualtekRAKRUI::send(uint8_t size, uint8_t *data, uint8_t fPort)
{
if (api.lorawan.send(size, data, fPort, false))
{
Expand All @@ -246,12 +246,12 @@ bool LualtekRAK3172::send(uint8_t size, uint8_t *data, uint8_t fPort)
return false;
}

int LualtekRAK3172::getUplinkInterval()
int LualtekRAKRUI::getUplinkInterval()
{
return dutyCycleHandler.uplinkInterval;
}

int LualtekRAK3172::getBatteryVoltage()
int LualtekRAKRUI::getBatteryVoltage()
{
analogReadResolution(12);
int adc_value = analogRead(WB_A0);
Expand Down
16 changes: 8 additions & 8 deletions src/LualtekRAK3172.h → src/LualtekRAKRUI.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _LUALTEKRAK3172_H_
#define _LUALTEKRAK3172_H_
#ifndef _LualtekRAKRUI_H_
#define _LualtekRAKRUI_H_

#include <Arduino.h>
#include "DutyCycleHandler.h"
Expand All @@ -13,33 +13,33 @@ enum lualtek_downlink_command_ports_t
};

/**
* @brief Represents the Lualtek RAK3172 LoRaWAN module for Arduino.
* @brief Represents the LualtekRAKRUI LoRaWAN module for Arduino.
*/
class LualtekRAK3172
class LualtekRAKRUI
{
public:
/**
* @brief Creates an instance of LualtekRAK3172.
* @brief Creates an instance of LualtekRAKRUI.
* @param appEui The application EUI.
* @param appKey The application key.
* @param dutyCycleIndex The duty cycle index.
* @param debugStream Debug stream.
*/
LualtekRAK3172(
LualtekRAKRUI(
const uint8_t appEui[8],
const uint8_t appKey[16],
lualtek_dowlink_command_dutycycle_index_t dutyCycleIndex,
Stream *debugStream);

/**
* @brief Creates an instance of LualtekRAK3172 with a specified device EUI.
* @brief Creates an instance of LualtekRAKRUI with a specified device EUI.
* @param devEui The device EUI.
* @param appEui The application EUI.
* @param appKey The application key.
* @param dutyCycleIndex The duty cycle index.
* @param debugStream Debug stream.
*/
LualtekRAK3172(
LualtekRAKRUI(
const uint8_t devEui[8],
const uint8_t appEui[8],
const uint8_t appKey[16],
Expand Down
22 changes: 0 additions & 22 deletions src/src.ino

This file was deleted.

0 comments on commit 14d8035

Please sign in to comment.