apply clang-format

pull/7/head
lthiery 2020-02-18 12:07:28 -08:00
rodzic c5a2b266ac
commit 82b45efb81
2 zmienionych plików z 428 dodań i 431 usunięć

Wyświetl plik

@ -15,7 +15,6 @@
*
*******************************************************************************/
/*******************************************************************************
*
* For Helium developers, follow the Arduino Quickstart guide:
@ -27,34 +26,34 @@
*
*******************************************************************************/
#include <lmic.h>
#include <arduino_lmic_hal_configuration.h>
#include <Adafruit_GPS.h>
#include <SPI.h>
#include <arduino_lmic.h>
#include <arduino_lmic_hal_boards.h>
#include <arduino_lmic_hal_configuration.h>
#include <arduino_lmic_lorawan_compliance.h>
#include <arduino_lmic_user_configuration.h>
#include <arduino_lmic.h>
#include <hal/hal.h>
#include <SPI.h>
#include <Adafruit_GPS.h>
#include <lmic.h>
#define GPSSerial Serial1
// Connect to the GPS on the hardware port
Adafruit_GPS GPS(&GPSSerial);
// This is the "App EUI" in Helium. Make sure it is little-endian (lsb).
static const u1_t PROGMEM APPEUI[8]= { FILL_ME_IN };
void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);}
static const u1_t PROGMEM APPEUI[8] = {FILL_ME_IN};
void os_getArtEui(u1_t *buf) { memcpy_P(buf, APPEUI, 8); }
// This should also be in little endian format
// 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 };
void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);}
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); }
// This is the "App Key" in Helium. It is big-endian (msb).
static const u1_t PROGMEM APPKEY[16] = { FILL_ME_IN };
void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);}
static const u1_t PROGMEM APPKEY[16] = {FILL_ME_IN};
void os_getDevKey(u1_t *buf) { memcpy_P(buf, APPKEY, 16); }
static uint8_t mydata[] = "Hello, world!";
static osjob_t sendjob;
@ -84,13 +83,13 @@ const lmic_pinmap lmic_pins = {
#include "arduino_lmic_hal_boards.h"
const lmic_pinmap lmic_pins = *Arduino_LMIC::GetPinmap_Catena4610();
#else
# error "Unknown target"
#error "Unknown target"
#endif
void onEvent (ev_t ev) {
void onEvent(ev_t ev) {
Serial.print(os_getTime());
Serial.print(": ");
switch(ev) {
switch (ev) {
case EV_SCAN_TIMEOUT:
Serial.println(F("EV_SCAN_TIMEOUT"));
break;
@ -122,14 +121,14 @@ void onEvent (ev_t ev) {
Serial.print("devaddr: ");
Serial.println(devaddr, HEX);
Serial.print("artKey: ");
for (size_t i=0; i<sizeof(artKey); ++i) {
for (size_t i = 0; i < sizeof(artKey); ++i) {
if (i != 0)
Serial.print("-");
Serial.print(artKey[i], HEX);
}
Serial.println("");
Serial.print("nwkKey: ");
for (size_t i=0; i<sizeof(nwkKey); ++i) {
for (size_t i = 0; i < sizeof(nwkKey); ++i) {
if (i != 0)
Serial.print("-");
Serial.print(nwkKey[i], HEX);
@ -166,7 +165,8 @@ void onEvent (ev_t ev) {
Serial.println(F(" bytes of payload"));
}
// Schedule next transmission
os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(TX_INTERVAL),
do_send);
break;
case EV_LOST_TSYNC:
Serial.println(F("EV_LOST_TSYNC"));
@ -197,12 +197,12 @@ void onEvent (ev_t ev) {
break;
default:
Serial.print(F("Unknown event: "));
Serial.println((unsigned) ev);
Serial.println((unsigned)ev);
break;
}
}
void do_send(osjob_t* j){
void do_send(osjob_t *j) {
// Check if there is not a current TX/RX job running
if (LMIC.opmode & OP_TXRXPEND) {
Serial.println(F("OP_TXRXPEND, not sending"));
@ -238,37 +238,36 @@ void do_send(osjob_t* j){
payload[idx++] = data >> 8;
payload[idx++] = data;
} else {
for (idx=0; idx<12; idx++) {
for (idx = 0; idx < 12; idx++) {
payload[idx] = 0;
}
}
Serial.println(F("Packet queued"));
LMIC_setTxData2(1, payload, idx, 0);
}
}
void setup() {
delay(5000);
while (! Serial)
while (!Serial)
;
Serial.begin(9600);
Serial.println(F("Starting"));
#if defined(ARDUINO_DISCO_L072CZ_LRWAN1)
#if defined(ARDUINO_DISCO_L072CZ_LRWAN1)
SPI.setMOSI(RADIO_MOSI_PORT);
SPI.setMISO(RADIO_MISO_PORT);
SPI.setSCLK(RADIO_SCLK_PORT);
SPI.setSSEL(RADIO_NSS_PORT);
// SPI.begin();
#endif
// SPI.begin();
#endif
#ifdef VCC_ENABLE
#ifdef VCC_ENABLE
// For Pinoccio Scout boards
pinMode(VCC_ENABLE, OUTPUT);
digitalWrite(VCC_ENABLE, HIGH);
delay(1000);
#endif
#endif
// LMIC init
os_init();
@ -278,8 +277,9 @@ void setup() {
// 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-lmic/commit/42da75b56#diff-16d75524a9920f5d043fe731a27cf85aL633
// the X/1000 means an error rate of 0.1%; the above issue discusses using values up to 10%.
// so, values from 10 (10% error, the most lax) to 1000 (0.1% error, the most strict) can be used.
// the X/1000 means an error rate of 0.1%; the above issue discusses using
// 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_setLinkCheckMode(0);

Wyświetl plik

@ -15,7 +15,6 @@
*
*******************************************************************************/
/*******************************************************************************
*
* For Helium developers, follow the Arduino Quickstart guide:
@ -27,27 +26,28 @@
*
*******************************************************************************/
#include <lmic.h>
#include <arduino_lmic_hal_configuration.h>
#include <SPI.h>
#include <arduino_lmic.h>
#include <arduino_lmic_hal_boards.h>
#include <arduino_lmic_hal_configuration.h>
#include <arduino_lmic_lorawan_compliance.h>
#include <arduino_lmic_user_configuration.h>
#include <arduino_lmic.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).
static const u1_t PROGMEM APPEUI[8]= { FILL_ME_IN };
void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);}
static const u1_t PROGMEM APPEUI[8] = {FILL_ME_IN};
void os_getArtEui(u1_t *buf) { memcpy_P(buf, APPEUI, 8); }
// This should also be in little endian format
// 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 };
void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);}
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); }
// This is the "App Key" in Helium. It is big-endian (msb).
static const u1_t PROGMEM APPKEY[16] = { FILL_ME_IN };
void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);}
static const u1_t PROGMEM APPKEY[16] = {FILL_ME_IN};
void os_getDevKey(u1_t *buf) { memcpy_P(buf, APPKEY, 16); }
static uint8_t mydata[] = "Hello, world!";
static osjob_t sendjob;
@ -92,7 +92,9 @@ const lmic_pinmap lmic_pins = {
.nss = 7,
.rxtx = 29,
.rst = 8,
.dio = { 25, // DIO0 (IRQ) is D25
.dio =
{
25, // DIO0 (IRQ) is D25
26, // DIO1 is D26
27, // DIO2 is D27
},
@ -109,13 +111,13 @@ const HalPinmap_t GetPinmap_Disco_L072cz_Lrwan1();
}
const lmic_pinmap lmic_pins = Arduino_LMIC::GetPinmap_Disco_L072cz_Lrwan1();
#else
# error "Unknown target"
#error "Unknown target"
#endif
void onEvent (ev_t ev) {
void onEvent(ev_t ev) {
Serial.print(os_getTime());
Serial.print(": ");
switch(ev) {
switch (ev) {
case EV_SCAN_TIMEOUT:
Serial.println(F("EV_SCAN_TIMEOUT"));
break;
@ -147,14 +149,14 @@ void onEvent (ev_t ev) {
Serial.print("devaddr: ");
Serial.println(devaddr, HEX);
Serial.print("artKey: ");
for (size_t i=0; i<sizeof(artKey); ++i) {
for (size_t i = 0; i < sizeof(artKey); ++i) {
if (i != 0)
Serial.print("-");
Serial.print(artKey[i], HEX);
}
Serial.println("");
Serial.print("nwkKey: ");
for (size_t i=0; i<sizeof(nwkKey); ++i) {
for (size_t i = 0; i < sizeof(nwkKey); ++i) {
if (i != 0)
Serial.print("-");
Serial.print(nwkKey[i], HEX);
@ -191,7 +193,8 @@ void onEvent (ev_t ev) {
Serial.println(F(" bytes of payload"));
}
// Schedule next transmission
os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(TX_INTERVAL),
do_send);
break;
case EV_LOST_TSYNC:
Serial.println(F("EV_LOST_TSYNC"));
@ -222,18 +225,18 @@ void onEvent (ev_t ev) {
break;
default:
Serial.print(F("Unknown event: "));
Serial.println((unsigned) ev);
Serial.println((unsigned)ev);
break;
}
}
void do_send(osjob_t* j){
void do_send(osjob_t *j) {
// Check if there is not a current TX/RX job running
if (LMIC.opmode & OP_TXRXPEND) {
Serial.println(F("OP_TXRXPEND, not sending"));
} else {
// Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(1, mydata, sizeof(mydata)-1, 0);
LMIC_setTxData2(1, mydata, sizeof(mydata) - 1, 0);
Serial.println(F("Packet queued"));
}
// Next TX is scheduled after TX_COMPLETE event.
@ -241,25 +244,25 @@ void do_send(osjob_t* j){
void setup() {
delay(5000);
while (! Serial)
while (!Serial)
;
Serial.begin(9600);
Serial.println(F("Starting"));
#if defined(ARDUINO_DISCO_L072CZ_LRWAN1)
#if defined(ARDUINO_DISCO_L072CZ_LRWAN1)
SPI.setMOSI(RADIO_MOSI_PORT);
SPI.setMISO(RADIO_MISO_PORT);
SPI.setSCLK(RADIO_SCLK_PORT);
SPI.setSSEL(RADIO_NSS_PORT);
// SPI.begin();
#endif
// SPI.begin();
#endif
#ifdef VCC_ENABLE
#ifdef VCC_ENABLE
// For Pinoccio Scout boards
pinMode(VCC_ENABLE, OUTPUT);
digitalWrite(VCC_ENABLE, HIGH);
delay(1000);
#endif
#endif
// LMIC init
os_init();
@ -269,8 +272,9 @@ void setup() {
// 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-lmic/commit/42da75b56#diff-16d75524a9920f5d043fe731a27cf85aL633
// the X/1000 means an error rate of 0.1%; the above issue discusses using values up to 10%.
// so, values from 10 (10% error, the most lax) to 1000 (0.1% error, the most strict) can be used.
// the X/1000 means an error rate of 0.1%; the above issue discusses using
// 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_setLinkCheckMode(0);
@ -281,17 +285,13 @@ void setup() {
do_send(&sendjob);
}
void loop() {
os_runloop_once();
}
void loop() { os_runloop_once(); }
namespace Arduino_LMIC {
class HalConfiguration_Disco_L072cz_Lrwan1_t : public HalConfiguration_t
{
public:
enum DIGITAL_PINS : uint8_t
{
class HalConfiguration_Disco_L072cz_Lrwan1_t : public HalConfiguration_t {
public:
enum DIGITAL_PINS : uint8_t {
PIN_SX1276_NSS = 37,
PIN_SX1276_NRESET = 33,
PIN_SX1276_DIO0 = 38,
@ -301,29 +301,26 @@ namespace Arduino_LMIC {
};
virtual bool queryUsingTcxo(void) override { return false; };
};
// save some typing by bringing the pin numbers into scope
static HalConfiguration_Disco_L072cz_Lrwan1_t myConfig;
};
// save some typing by bringing the pin numbers into scope
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,
.rxtx = HalConfiguration_Disco_L072cz_Lrwan1_t::PIN_SX1276_RXTX,
.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_DIO2,
},
.rxtx_rx_active = 1,
.rssi_cal = 10,
.spi_freq = 8000000, /* 8MHz */
.pConfig = &myConfig
};
.pConfig = &myConfig};
const HalPinmap_t GetPinmap_Disco_L072cz_Lrwan1(void)
{
return myPinmap;
}
const HalPinmap_t GetPinmap_Disco_L072cz_Lrwan1(void) { return myPinmap; }
}; // end namespace Arduino_LMIC