Skip to content

Commit 8565992

Browse files
authored
Merge pull request #21 from Strooom/develop
several small improvements
2 parents 800496b + db1e90b commit 8565992

File tree

13 files changed

+47
-42
lines changed

13 files changed

+47
-42
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
![workflow](https://github.com/strooom/MuMo-v2-Node-SW/actions/workflows/testbuildrelease.yml/badge.svg)
22
[![codecov](https://codecov.io/gh/Strooom/MuMo-v2-Node-SW/graph/badge.svg?token=7KF1NA1ACQ)](https://codecov.io/gh/Strooom/MuMo-v2-Node-SW)
3-
[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=Strooom_MuMo-v2-Node-SW)](https://sonarcloud.io/summary/new_code?id=Strooom_MuMo-v2-Node-SW)
43
[![License: CC BY-NC-SA 4.0](https://img.shields.io/badge/License-CC_BY--NC--SA_4.0-lightgrey.svg)](https://creativecommons.org/licenses/by-nc-sa/4.0/)
4+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Strooom_MuMo-v2-Node-SW&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Strooom_MuMo-v2-Node-SW)
5+
56

67
# LoRaWAN development for STM32WLE using PlatformIO and STM32CubeIDE
78

lib/cli/cli.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void cli::run() {
3737
}
3838
}
3939

40-
uint32_t cli::countArguments(char* commandLine) {
40+
uint32_t cli::countArguments(const char* commandLine) {
4141
uint32_t count{0};
4242
uint32_t commandLineLength{0};
4343
commandLineLength = strnlen(commandLine, maxCommandLineLength);
@@ -52,7 +52,7 @@ uint32_t cli::countArguments(char* commandLine) {
5252
return count;
5353
}
5454

55-
int32_t cli::getSeparatorPosition(char* commandLine, uint32_t separatorIndex) {
55+
int32_t cli::getSeparatorPosition(const char* commandLine, const uint32_t separatorIndex) {
5656
uint32_t slashCount{0};
5757
uint32_t dataLength = strnlen(commandLine, maxCommandLineLength);
5858
for (uint32_t position = 0; position < dataLength; position++) {
@@ -66,7 +66,7 @@ int32_t cli::getSeparatorPosition(char* commandLine, uint32_t separatorIndex) {
6666
return -1;
6767
}
6868

69-
void cli::getSegment(char* destination, char* commandLine, uint32_t segmentIndex) {
69+
void cli::getSegment(char* destination, const char* commandLine, const uint32_t segmentIndex) {
7070
uint32_t startIndex;
7171
uint32_t endIndex;
7272
uint32_t nmbrOfArguments = countArguments(commandLine);
@@ -94,7 +94,7 @@ void cli::getSegment(char* destination, char* commandLine, uint32_t segmentIndex
9494
destination[endIndex - startIndex] = '\0';
9595
}
9696

97-
void cli::splitCommandLine(char* commandLine) {
97+
void cli::splitCommandLine(const char* commandLine) {
9898
nmbrOfArguments = countArguments(commandLine);
9999
getSegment(command, commandLine, 0);
100100
for (uint32_t argumentIndex = 0; argumentIndex < cliCommand::maxNmbrOfArguments; argumentIndex++) {
@@ -118,7 +118,7 @@ int32_t cli::findCommandIndex() {
118118
return -1;
119119
}
120120

121-
void cli::executeCommand(char* commandLine) {
121+
void cli::executeCommand(const char* commandLine) {
122122
splitCommandLine(commandLine);
123123
int32_t commandIndex = findCommandIndex();
124124
if (commandIndex >= 0) {

lib/cli/cli.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class cli {
2424
static char arguments[cliCommand::maxNmbrOfArguments][cliCommand::maxArgumentLength];
2525
static char error[maxCommandLineLength];
2626

27-
static void splitCommandLine(char* commandLine);
28-
static uint32_t countArguments(char* commandLine);
27+
static void splitCommandLine(const char* commandLine);
28+
static uint32_t countArguments(const char* commandLine);
2929
static int32_t findCommandIndex();
30-
static int32_t getSeparatorPosition(char* commandLine, uint32_t separatorIndex);
31-
static void getSegment(char* destination, char* commandLine, uint32_t segmentIndex);
32-
static void executeCommand(char* commandLine);
30+
static int32_t getSeparatorPosition(const char* commandLine, const uint32_t separatorIndex);
31+
static void getSegment(char* destination, const char* commandLine, const uint32_t segmentIndex);
32+
static void executeCommand(const char* commandLine);
3333
};

lib/float/float.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22
#include <inttypes.h>
33
#include <float.hpp>
44

5-
int32_t integerPart(float value, uint32_t decimals) {
5+
int32_t integerPart(const float value, const uint32_t decimals) {
66
return (static_cast<int>(round(value * factorFloat(decimals))) / factorInt(decimals));
77
}
88

9-
uint32_t fractionalPart(float value, uint32_t decimals) {
9+
uint32_t fractionalPart(const float value, const uint32_t decimals) {
1010
return static_cast<int>(round(value * factorFloat(decimals))) - (integerPart(value, decimals) * factorInt(decimals));
1111
}
1212

13-
float factorFloat(uint32_t decimals) {
13+
float factorFloat(const uint32_t decimals) {
1414
float result{1.0F};
1515
for (uint32_t n = 0; n < decimals; n++) {
1616
result *= 10.0F;
1717
}
1818
return result;
1919
}
2020

21-
uint32_t factorInt(uint32_t decimals) {
21+
uint32_t factorInt(const uint32_t decimals) {
2222
uint32_t result{1U};
2323
for (uint32_t n = 0; n < decimals; n++) {
2424
result *= 10;
2525
}
2626
return result;
2727
}
2828

29-
float bytesToFloat(uint8_t bytes[4]) {
29+
float bytesToFloat(const uint8_t bytes[4]) {
3030
static union {
3131
float asFloat;
3232
uint8_t asBytes[4];
@@ -38,7 +38,7 @@ float bytesToFloat(uint8_t bytes[4]) {
3838
return convertor.asFloat;
3939
}
4040

41-
uint8_t* floatToBytes(float value) {
41+
uint8_t* floatToBytes(const float value) {
4242
static union {
4343
float asFloat;
4444
uint8_t asBytes[4];

lib/float/float.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#pragma once
77
#include <stdint.h>
88

9-
int32_t integerPart(float value, uint32_t decimals);
10-
uint32_t fractionalPart(float value, uint32_t decimals);
11-
float factorFloat(uint32_t decimals);
12-
uint32_t factorInt(uint32_t decimals);
13-
uint8_t* floatToBytes(float value);
14-
float bytesToFloat(uint8_t bytes[4]);
9+
int32_t integerPart(const float value, const uint32_t decimals);
10+
uint32_t fractionalPart(const float value, const uint32_t decimals);
11+
float factorFloat(const uint32_t decimals);
12+
uint32_t factorInt(const uint32_t decimals);
13+
uint8_t* floatToBytes(const float value);
14+
float bytesToFloat(const uint8_t bytes[4]);

lib/linearbuffer/linearbuffer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class linearBuffer {
1515
public:
1616
static constexpr uint32_t length = toBeLength;
1717

18-
linearBuffer(){};
18+
linearBuffer() = default;
1919
void initialize() { level = 0; };
2020

2121
// ### Get the metadata of the buffer ###
@@ -127,6 +127,6 @@ class linearBuffer {
127127

128128
private:
129129
#endif
130-
uint32_t level{0}; // how many bytes are in the buffer
130+
uint32_t level{0}; // how many bytes are in the buffer
131131
uint8_t buffer[length]{}; // the array where the actual data is stored
132132
};

lib/lora/lorachannel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void loRaChannel::toBytes(uint8_t *bytes) {
1313
bytes[5] = minimumDataRateIndex;
1414
}
1515

16-
void loRaChannel::fromBytes(uint8_t *bytes) {
16+
void loRaChannel::fromBytes(const uint8_t *bytes) {
1717
frequencyInHz = bytesToBigEndianWord(bytes[0], bytes[1], bytes[2], bytes[3]);
1818
maximumDataRateIndex = bytes[4];
1919
minimumDataRateIndex = bytes[5];

lib/lora/lorachannel.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class loRaChannel {
1111
public:
1212
loRaChannel(uint32_t frequency, uint8_t minimumDataRateIndex, uint8_t maximumDataRateIndex);
1313
void toBytes(uint8_t *bytes);
14-
void fromBytes(uint8_t *bytes);
14+
void fromBytes(const uint8_t *bytes);
1515

1616
uint32_t frequencyInHz{0}; // NOTE : a frequency of 0 means the channel is not used
1717
uint8_t minimumDataRateIndex{0};

lib/lorawan/macheader.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#include <macheader.hpp>
77
#include <frametype.hpp>
88

9-
macHeader::macHeader(){};
10-
119
macHeader::macHeader(frameType theFrameType) : theFrameType{theFrameType} {};
1210

1311
void macHeader::set(frameType newFrameType) {

lib/lorawan/macheader.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class macHeader {
1212
public:
13-
macHeader(); //
13+
macHeader() = default; //
1414
explicit macHeader(frameType theFrameType); // construct a macHeader with the given frameType
1515
void set(frameType theFrameType); // set the macHeader with the given frameType
1616
uint8_t asUint8() const; // return the macHeader as a byte

0 commit comments

Comments
 (0)