kopia lustrzana https://github.com/helium/longfi-arduino
Add formatting (#7)
* commit default clang-format * apply clang-format * add formatting guidelinespull/9/head
rodzic
95b9865313
commit
063710e94a
|
@ -0,0 +1,121 @@
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
# BasedOnStyle: LLVM
|
||||||
|
AccessModifierOffset: -2
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: true
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: MultiLine
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: false
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeInheritanceComma: false
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 80
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||||
|
Priority: 2
|
||||||
|
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||||
|
Priority: 3
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 1
|
||||||
|
IncludeIsMainRegex: '(Test)?$'
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentWidth: 2
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBinPackProtocolList: Auto
|
||||||
|
ObjCBlockIndentWidth: 2
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
PointerAlignment: Right
|
||||||
|
ReflowComments: true
|
||||||
|
SortIncludes: true
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Cpp11
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
TabWidth: 8
|
||||||
|
UseTab: Never
|
||||||
|
...
|
||||||
|
|
|
@ -9,6 +9,10 @@ our way or a bug to report:
|
||||||
repo](https://github.com/helium/longfi-arduino). Include a
|
repo](https://github.com/helium/longfi-arduino). Include a
|
||||||
write up of the PR with details on what it does.
|
write up of the PR with details on what it does.
|
||||||
|
|
||||||
|
* **Formatting Code**: Please apply clang-format to any PRs. From the
|
||||||
|
root of the repository:
|
||||||
|
`find . -regex '.*\.\(cpp\|hpp\|cu\|c\|h\|ino\)' -exec clang-format -i {} \;`
|
||||||
|
|
||||||
* **Reporting Bugs**: Open an issue [against this
|
* **Reporting Bugs**: Open an issue [against this
|
||||||
repo](https://github.com/helium/longfi-arduino/issues) with as much
|
repo](https://github.com/helium/longfi-arduino/issues) with as much
|
||||||
detail as you can. At the very least you'll include steps to
|
detail as you can. At the very least you'll include steps to
|
||||||
|
|
24
GPS/GPS.ino
24
GPS/GPS.ino
|
@ -15,7 +15,6 @@
|
||||||
*
|
*
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
*
|
*
|
||||||
* For Helium developers, follow the Arduino Quickstart guide:
|
* For Helium developers, follow the Arduino Quickstart guide:
|
||||||
|
@ -27,29 +26,29 @@
|
||||||
*
|
*
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <lmic.h>
|
#include <Adafruit_GPS.h>
|
||||||
#include <arduino_lmic_hal_configuration.h>
|
#include <SPI.h>
|
||||||
|
#include <arduino_lmic.h>
|
||||||
#include <arduino_lmic_hal_boards.h>
|
#include <arduino_lmic_hal_boards.h>
|
||||||
|
#include <arduino_lmic_hal_configuration.h>
|
||||||
#include <arduino_lmic_lorawan_compliance.h>
|
#include <arduino_lmic_lorawan_compliance.h>
|
||||||
#include <arduino_lmic_user_configuration.h>
|
#include <arduino_lmic_user_configuration.h>
|
||||||
#include <arduino_lmic.h>
|
|
||||||
#include <hal/hal.h>
|
#include <hal/hal.h>
|
||||||
#include <SPI.h>
|
#include <lmic.h>
|
||||||
#include <Adafruit_GPS.h>
|
|
||||||
|
|
||||||
#define GPSSerial Serial1
|
#define GPSSerial Serial1
|
||||||
|
|
||||||
// Connect to the GPS on the hardware port
|
// Connect to the GPS on the hardware port
|
||||||
Adafruit_GPS GPS(&GPSSerial);
|
Adafruit_GPS GPS(&GPSSerial);
|
||||||
|
|
||||||
|
|
||||||
// This is the "App EUI" in Helium. Make sure it is little-endian (lsb).
|
// This is the "App EUI" in Helium. Make sure it is little-endian (lsb).
|
||||||
static const u1_t PROGMEM APPEUI[8] = {FILL_ME_IN};
|
static const u1_t PROGMEM APPEUI[8] = {FILL_ME_IN};
|
||||||
void os_getArtEui(u1_t *buf) { memcpy_P(buf, APPEUI, 8); }
|
void os_getArtEui(u1_t *buf) { memcpy_P(buf, APPEUI, 8); }
|
||||||
|
|
||||||
// This should also be in little endian format
|
// This should also be in little endian format
|
||||||
// These are user configurable values and Helium console permits anything
|
// These are user configurable values and Helium console permits anything
|
||||||
static const u1_t PROGMEM DEVEUI[8]= { 0x48, 0x65, 0x6c, 0x69, 0x75, 0x6d, 0x20, 0x20 };
|
static const u1_t PROGMEM DEVEUI[8] = {0x48, 0x65, 0x6c, 0x69,
|
||||||
|
0x75, 0x6d, 0x20, 0x20};
|
||||||
void os_getDevEui(u1_t *buf) { memcpy_P(buf, DEVEUI, 8); }
|
void os_getDevEui(u1_t *buf) { memcpy_P(buf, DEVEUI, 8); }
|
||||||
|
|
||||||
// This is the "App Key" in Helium. It is big-endian (msb).
|
// This is the "App Key" in Helium. It is big-endian (msb).
|
||||||
|
@ -166,7 +165,8 @@ void onEvent (ev_t ev) {
|
||||||
Serial.println(F(" bytes of payload"));
|
Serial.println(F(" bytes of payload"));
|
||||||
}
|
}
|
||||||
// Schedule next transmission
|
// Schedule next transmission
|
||||||
os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
|
os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(TX_INTERVAL),
|
||||||
|
do_send);
|
||||||
break;
|
break;
|
||||||
case EV_LOST_TSYNC:
|
case EV_LOST_TSYNC:
|
||||||
Serial.println(F("EV_LOST_TSYNC"));
|
Serial.println(F("EV_LOST_TSYNC"));
|
||||||
|
@ -245,7 +245,6 @@ void do_send(osjob_t* j){
|
||||||
Serial.println(F("Packet queued"));
|
Serial.println(F("Packet queued"));
|
||||||
LMIC_setTxData2(1, payload, idx, 0);
|
LMIC_setTxData2(1, payload, idx, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
@ -278,8 +277,9 @@ void setup() {
|
||||||
// allow much more clock error than the X/1000 default. See:
|
// allow much more clock error than the X/1000 default. See:
|
||||||
// https://github.com/mcci-catena/arduino-lorawan/issues/74#issuecomment-462171974
|
// https://github.com/mcci-catena/arduino-lorawan/issues/74#issuecomment-462171974
|
||||||
// https://github.com/mcci-catena/arduino-lmic/commit/42da75b56#diff-16d75524a9920f5d043fe731a27cf85aL633
|
// https://github.com/mcci-catena/arduino-lmic/commit/42da75b56#diff-16d75524a9920f5d043fe731a27cf85aL633
|
||||||
// the X/1000 means an error rate of 0.1%; the above issue discusses using values up to 10%.
|
// the X/1000 means an error rate of 0.1%; the above issue discusses using
|
||||||
// so, values from 10 (10% error, the most lax) to 1000 (0.1% error, the most strict) can be used.
|
// values up to 10%. so, values from 10 (10% error, the most lax) to 1000
|
||||||
|
// (0.1% error, the most strict) can be used.
|
||||||
LMIC_setClockError(1 * MAX_CLOCK_ERROR / 40);
|
LMIC_setClockError(1 * MAX_CLOCK_ERROR / 40);
|
||||||
|
|
||||||
LMIC_setLinkCheckMode(0);
|
LMIC_setLinkCheckMode(0);
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
*
|
*
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
*
|
*
|
||||||
* For Helium developers, follow the Arduino Quickstart guide:
|
* For Helium developers, follow the Arduino Quickstart guide:
|
||||||
|
@ -27,14 +26,14 @@
|
||||||
*
|
*
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <lmic.h>
|
#include <SPI.h>
|
||||||
#include <arduino_lmic_hal_configuration.h>
|
#include <arduino_lmic.h>
|
||||||
#include <arduino_lmic_hal_boards.h>
|
#include <arduino_lmic_hal_boards.h>
|
||||||
|
#include <arduino_lmic_hal_configuration.h>
|
||||||
#include <arduino_lmic_lorawan_compliance.h>
|
#include <arduino_lmic_lorawan_compliance.h>
|
||||||
#include <arduino_lmic_user_configuration.h>
|
#include <arduino_lmic_user_configuration.h>
|
||||||
#include <arduino_lmic.h>
|
|
||||||
#include <hal/hal.h>
|
#include <hal/hal.h>
|
||||||
#include <SPI.h>
|
#include <lmic.h>
|
||||||
|
|
||||||
// This is the "App EUI" in Helium. Make sure it is little-endian (lsb).
|
// This is the "App EUI" in Helium. Make sure it is little-endian (lsb).
|
||||||
static const u1_t PROGMEM APPEUI[8] = {FILL_ME_IN};
|
static const u1_t PROGMEM APPEUI[8] = {FILL_ME_IN};
|
||||||
|
@ -42,7 +41,8 @@ void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);}
|
||||||
|
|
||||||
// This should also be in little endian format
|
// This should also be in little endian format
|
||||||
// These are user configurable values and Helium console permits anything
|
// These are user configurable values and Helium console permits anything
|
||||||
static const u1_t PROGMEM DEVEUI[8]= { 0x48, 0x65, 0x6c, 0x69, 0x75, 0x6d, 0x20, 0x20 };
|
static const u1_t PROGMEM DEVEUI[8] = {0x48, 0x65, 0x6c, 0x69,
|
||||||
|
0x75, 0x6d, 0x20, 0x20};
|
||||||
void os_getDevEui(u1_t *buf) { memcpy_P(buf, DEVEUI, 8); }
|
void os_getDevEui(u1_t *buf) { memcpy_P(buf, DEVEUI, 8); }
|
||||||
|
|
||||||
// This is the "App Key" in Helium. It is big-endian (msb).
|
// This is the "App Key" in Helium. It is big-endian (msb).
|
||||||
|
@ -92,7 +92,9 @@ const lmic_pinmap lmic_pins = {
|
||||||
.nss = 7,
|
.nss = 7,
|
||||||
.rxtx = 29,
|
.rxtx = 29,
|
||||||
.rst = 8,
|
.rst = 8,
|
||||||
.dio = { 25, // DIO0 (IRQ) is D25
|
.dio =
|
||||||
|
{
|
||||||
|
25, // DIO0 (IRQ) is D25
|
||||||
26, // DIO1 is D26
|
26, // DIO1 is D26
|
||||||
27, // DIO2 is D27
|
27, // DIO2 is D27
|
||||||
},
|
},
|
||||||
|
@ -191,7 +193,8 @@ void onEvent (ev_t ev) {
|
||||||
Serial.println(F(" bytes of payload"));
|
Serial.println(F(" bytes of payload"));
|
||||||
}
|
}
|
||||||
// Schedule next transmission
|
// Schedule next transmission
|
||||||
os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
|
os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(TX_INTERVAL),
|
||||||
|
do_send);
|
||||||
break;
|
break;
|
||||||
case EV_LOST_TSYNC:
|
case EV_LOST_TSYNC:
|
||||||
Serial.println(F("EV_LOST_TSYNC"));
|
Serial.println(F("EV_LOST_TSYNC"));
|
||||||
|
@ -269,8 +272,9 @@ void setup() {
|
||||||
// allow much more clock error than the X/1000 default. See:
|
// allow much more clock error than the X/1000 default. See:
|
||||||
// https://github.com/mcci-catena/arduino-lorawan/issues/74#issuecomment-462171974
|
// https://github.com/mcci-catena/arduino-lorawan/issues/74#issuecomment-462171974
|
||||||
// https://github.com/mcci-catena/arduino-lmic/commit/42da75b56#diff-16d75524a9920f5d043fe731a27cf85aL633
|
// https://github.com/mcci-catena/arduino-lmic/commit/42da75b56#diff-16d75524a9920f5d043fe731a27cf85aL633
|
||||||
// the X/1000 means an error rate of 0.1%; the above issue discusses using values up to 10%.
|
// the X/1000 means an error rate of 0.1%; the above issue discusses using
|
||||||
// so, values from 10 (10% error, the most lax) to 1000 (0.1% error, the most strict) can be used.
|
// values up to 10%. so, values from 10 (10% error, the most lax) to 1000
|
||||||
|
// (0.1% error, the most strict) can be used.
|
||||||
LMIC_setClockError(1 * MAX_CLOCK_ERROR / 40);
|
LMIC_setClockError(1 * MAX_CLOCK_ERROR / 40);
|
||||||
|
|
||||||
LMIC_setLinkCheckMode(0);
|
LMIC_setLinkCheckMode(0);
|
||||||
|
@ -281,17 +285,13 @@ void setup() {
|
||||||
do_send(&sendjob);
|
do_send(&sendjob);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() { os_runloop_once(); }
|
||||||
os_runloop_once();
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Arduino_LMIC {
|
namespace Arduino_LMIC {
|
||||||
|
|
||||||
class HalConfiguration_Disco_L072cz_Lrwan1_t : public HalConfiguration_t
|
class HalConfiguration_Disco_L072cz_Lrwan1_t : public HalConfiguration_t {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
enum DIGITAL_PINS : uint8_t
|
enum DIGITAL_PINS : uint8_t {
|
||||||
{
|
|
||||||
PIN_SX1276_NSS = 37,
|
PIN_SX1276_NSS = 37,
|
||||||
PIN_SX1276_NRESET = 33,
|
PIN_SX1276_NRESET = 33,
|
||||||
PIN_SX1276_DIO0 = 38,
|
PIN_SX1276_DIO0 = 38,
|
||||||
|
@ -305,25 +305,22 @@ namespace Arduino_LMIC {
|
||||||
// save some typing by bringing the pin numbers into scope
|
// save some typing by bringing the pin numbers into scope
|
||||||
static HalConfiguration_Disco_L072cz_Lrwan1_t myConfig;
|
static HalConfiguration_Disco_L072cz_Lrwan1_t myConfig;
|
||||||
|
|
||||||
static const HalPinmap_t myPinmap =
|
static const HalPinmap_t myPinmap = {
|
||||||
{
|
|
||||||
.nss = HalConfiguration_Disco_L072cz_Lrwan1_t::PIN_SX1276_NSS,
|
.nss = HalConfiguration_Disco_L072cz_Lrwan1_t::PIN_SX1276_NSS,
|
||||||
.rxtx = HalConfiguration_Disco_L072cz_Lrwan1_t::PIN_SX1276_RXTX,
|
.rxtx = HalConfiguration_Disco_L072cz_Lrwan1_t::PIN_SX1276_RXTX,
|
||||||
.rst = HalConfiguration_Disco_L072cz_Lrwan1_t::PIN_SX1276_NRESET,
|
.rst = HalConfiguration_Disco_L072cz_Lrwan1_t::PIN_SX1276_NRESET,
|
||||||
|
|
||||||
.dio = {HalConfiguration_Disco_L072cz_Lrwan1_t::PIN_SX1276_DIO0,
|
.dio =
|
||||||
|
{
|
||||||
|
HalConfiguration_Disco_L072cz_Lrwan1_t::PIN_SX1276_DIO0,
|
||||||
HalConfiguration_Disco_L072cz_Lrwan1_t::PIN_SX1276_DIO1,
|
HalConfiguration_Disco_L072cz_Lrwan1_t::PIN_SX1276_DIO1,
|
||||||
HalConfiguration_Disco_L072cz_Lrwan1_t::PIN_SX1276_DIO2,
|
HalConfiguration_Disco_L072cz_Lrwan1_t::PIN_SX1276_DIO2,
|
||||||
},
|
},
|
||||||
.rxtx_rx_active = 1,
|
.rxtx_rx_active = 1,
|
||||||
.rssi_cal = 10,
|
.rssi_cal = 10,
|
||||||
.spi_freq = 8000000, /* 8MHz */
|
.spi_freq = 8000000, /* 8MHz */
|
||||||
.pConfig = &myConfig
|
.pConfig = &myConfig};
|
||||||
};
|
|
||||||
|
|
||||||
const HalPinmap_t GetPinmap_Disco_L072cz_Lrwan1(void)
|
const HalPinmap_t GetPinmap_Disco_L072cz_Lrwan1(void) { return myPinmap; }
|
||||||
{
|
|
||||||
return myPinmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // end namespace Arduino_LMIC
|
}; // end namespace Arduino_LMIC
|
||||||
|
|
Ładowanie…
Reference in New Issue