diff --git a/.travis.yml b/.travis.yml index 761b9be2..0c5279ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,27 +48,52 @@ script: - arduino --verify --board $(_samdopts '' us915) $PWD/examples/raw-feather/raw-feather.ino - arduino --verify --board $(_samdopts '' eu868) $PWD/examples/raw-feather/raw-feather.ino # V1.1.0 of the samd bsp doesn't support au921 correctly -- test with projcfg -# - arduino --verify --board $(_samdopts '' au921) $PWD/examples/raw-feather/raw-feather.ino +#- arduino --verify --board $(_samdopts '' au921) $PWD/examples/raw-feather/raw-feather.ino - arduino --verify --board $(_samdopts '' as923) $PWD/examples/raw-feather/raw-feather.ino - arduino --verify --board $(_samdopts '' as923jp) $PWD/examples/raw-feather/raw-feather.ino - arduino --verify --board $(_samdopts '' in866) $PWD/examples/raw-feather/raw-feather.ino # -# some tests using the projcfg file that should pass - - _projcfg COMPILE_REGRESSION_TEST CFG_us915 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino - - _projcfg COMPILE_REGRESSION_TEST CFG_us915 CFG_sx1272_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino +# some tests using the projcfg file that should pass - test the examples +# +# test ttn-otaa-feather in all relevant regions with sx1276 + - _projcfg COMPILE_REGRESSION_TEST CFG_us915 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino +#- _projcfg COMPILE_REGRESSION_TEST CFG_eu868 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino + - _projcfg COMPILE_REGRESSION_TEST CFG_au921 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino +#- _projcfg COMPILE_REGRESSION_TEST CFG_as923 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino +#- _projcfg COMPILE_REGRESSION_TEST CFG_as923jp CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino +#- _projcfg COMPILE_REGRESSION_TEST CFG_in866 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino +# +# test raw feather with au921 - _projcfg CFG_au921 CFG_sx1276_radio && arduino --verify --board $(_samdopts '' projcfg) $PWD/examples/raw-feather/raw-feather.ino +# +# test ttn-otaa with all regions + - _projcfg COMPILE_REGRESSION_TEST CFG_us915 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa/ttn-otaa.ino + - _projcfg COMPILE_REGRESSION_TEST CFG_eu868 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa/ttn-otaa.ino + - _projcfg COMPILE_REGRESSION_TEST CFG_au921 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa/ttn-otaa.ino + - _projcfg COMPILE_REGRESSION_TEST CFG_as923 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa/ttn-otaa.ino + - _projcfg COMPILE_REGRESSION_TEST CFG_as923jp CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa/ttn-otaa.ino + - _projcfg COMPILE_REGRESSION_TEST CFG_in866 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa/ttn-otaa.ino +# +# test ttn-abp with all regions + - _projcfg COMPILE_REGRESSION_TEST CFG_us915 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-abp/ttn-abp.ino + - _projcfg COMPILE_REGRESSION_TEST CFG_eu868 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-abp/ttn-abp.ino + - _projcfg COMPILE_REGRESSION_TEST CFG_au921 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-abp/ttn-abp.ino + - _projcfg COMPILE_REGRESSION_TEST CFG_as923 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-abp/ttn-abp.ino + - _projcfg COMPILE_REGRESSION_TEST CFG_as923jp CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-abp/ttn-abp.ino + - _projcfg COMPILE_REGRESSION_TEST CFG_in866 CFG_sx1276_radio && arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-abp/ttn-abp.ino # # some tests that should generate build failures. # -# COMPILE_REGRESSION_TEST must be defined for ttn-otaa-feather-us915 +# COMPILE_REGRESSION_TEST must be defined for ttn-otaa-feather-us915, ttn-otaa, ttn-abp - _projcfg CFG_us915 CFG_sx1272_radio && { arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino ; _expect_failure; } + - _projcfg CFG_us915 CFG_sx1276_radio && { arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa/ttn-otaa.ino ; _expect_failure; } + - _projcfg CFG_us915 CFG_sx1276_radio && { arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-abp/ttn-abp.ino ; _expect_failure; } # # Only one radio may be defined - _projcfg COMPILE_REGRESSION_TEST CFG_us915 CFG_sx1272_radio CFG_sx1276_radio && { arduino --verify --board mcci:samd:mcci_catena_4450:lorawan_region=projcfg $PWD/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino ; _expect_failure; } - # # *** TESTS FOR STM32L0 / Catena 4551 **** # make sure you install the BSP above. @@ -79,6 +104,7 @@ script: - _projcfg CFG_as923 CFG_sx1276_radio && arduino --verify --board $(_stm32l0opts) $PWD/examples/raw-feather/raw-feather.ino - _projcfg CFG_in866 CFG_sx1276_radio && arduino --verify --board $(_stm32l0opts) $PWD/examples/raw-feather/raw-feather.ino - _projcfg COMPILE_REGRESSION_TEST CFG_us915 CFG_sx1276_radio && arduino --verify --board $(_stm32l0opts) $PWD/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino - - _projcfg COMPILE_REGRESSION_TEST CFG_us915 CFG_sx1272_radio && arduino --verify --board $(_stm32l0opts) $PWD/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino + - _projcfg COMPILE_REGRESSION_TEST CFG_us915 CFG_sx1276_radio && arduino --verify --board $(_stm32l0opts) $PWD/examples/ttn-otaa/ttn-otaa.ino + - _projcfg COMPILE_REGRESSION_TEST CFG_us915 CFG_sx1276_radio && arduino --verify --board $(_stm32l0opts) $PWD/examples/ttn-abp/ttn-abp.ino ### end of file ### \ No newline at end of file diff --git a/examples/ttn-abp/ttn-abp.ino b/examples/ttn-abp/ttn-abp.ino index d27dcd4e..bedd2c7a 100644 --- a/examples/ttn-abp/ttn-abp.ino +++ b/examples/ttn-abp/ttn-abp.ino @@ -1,5 +1,6 @@ /******************************************************************************* * Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman + * Copyright (c) 2018 Terry Moore, MCCI * * Permission is hereby granted, free of charge, to anyone * obtaining a copy of this document and accompanying files, @@ -36,19 +37,30 @@ #include #include +// +// For normal use, we require that you edit the sketch to replace FILLMEIN +// with values assigned by the TTN console. However, for regression tests, +// we want to be able to compile these scripts. The regression tests define +// COMPILE_REGRESSION_TEST, and in that case we define FILLMEIN to a non- +// working but innocuous value. +// +#ifdef COMPILE_REGRESSION_TEST +# define FILLMEIN 0 +#else +# warning "You must replace the values marked FILLMEIN with real values from the TTN control panel!" +# define FILLMEIN (#dont edit this, edit the lines that use FILLMEIN) +#endif + // LoRaWAN NwkSKey, network session key -// This is the default Semtech key, which is used by the early prototype TTN -// network. -static const PROGMEM u1_t NWKSKEY[16] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C }; +static const PROGMEM u1_t NWKSKEY[16] = { FILLMEIN }; // LoRaWAN AppSKey, application session key -// This is the default Semtech key, which is used by the early prototype TTN -// network. -static const u1_t PROGMEM APPSKEY[16] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C }; +static const u1_t PROGMEM APPSKEY[16] = { FILLMEIN }; // LoRaWAN end-device address (DevAddr) // See http://thethingsnetwork.org/wiki/AddressSpace -static const u4_t DEVADDR = 0x03FF0001 ; // <-- Change this address for every node! +// The library converts the address to network byte order as needed. +static const u4_t DEVADDR = FILLMEIN ; // <-- Change this address for every node! // These callbacks are only used in over-the-air activation, so they are // left empty here (we cannot leave them out completely unless @@ -97,9 +109,14 @@ void onEvent (ev_t ev) { case EV_JOINED: Serial.println(F("EV_JOINED")); break; - case EV_RFU1: - Serial.println(F("EV_RFU1")); - break; + /* + || This event is defined but not used in the code. No + || point in wasting codespace on it. + || + || case EV_RFU1: + || Serial.println(F("EV_RFU1")); + || break; + */ case EV_JOIN_FAILED: Serial.println(F("EV_JOIN_FAILED")); break; @@ -134,8 +151,20 @@ void onEvent (ev_t ev) { case EV_LINK_ALIVE: Serial.println(F("EV_LINK_ALIVE")); break; - default: - Serial.println(F("Unknown event")); + /* + || This event is defined but not used in the code. No + || point in wasting codespace on it. + || + || case EV_SCAN_FOUND: + || Serial.println(F("EV_SCAN_FOUND")); + || break; + */ + case EV_TXSTART: + Serial.println(F("EV_TXSTART")); + break; + default: + Serial.print(F("Unknown event: ")); + Serial.println((unsigned) ev); break; } } diff --git a/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino b/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino index abf12384..2d62c26b 100644 --- a/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino +++ b/examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino @@ -1,5 +1,6 @@ /******************************************************************************* * Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman + * Copyright (c) 2018 Terry Moore, MCCI * * Permission is hereby granted, free of charge, to anyone * obtaining a copy of this document and accompanying files, @@ -9,7 +10,8 @@ * * This example sends a valid LoRaWAN packet with payload "Hello, * world!", using frequency and encryption settings matching those of - * the The Things Network. + * the The Things Network. It's pre-configured for the Adafruit + * Feather M0 LoRa. * * This uses OTAA (Over-the-air activation), where where a DevEUI and * application key is configured, which are used in an over-the-air @@ -33,11 +35,18 @@ #include #include - +// +// For normal use, we require that you edit the sketch to replace FILLMEIN +// with values assigned by the TTN console. However, for regression tests, +// we want to be able to compile these scripts. The regression tests define +// COMPILE_REGRESSION_TEST, and in that case we define FILLMEIN to a non- +// working but innocuous value. +// #ifdef COMPILE_REGRESSION_TEST # define FILLMEIN 0 #else -# error "You must replace the values marked FILLMEIN with real values from the TTN control panel!" +# warning "You must replace the values marked FILLMEIN with real values from the TTN control panel!" +# define FILLMEIN (#dont edit this, edit the lines that use FILLMEIN) #endif // This EUI must be in little-endian format, so least-significant-byte @@ -65,12 +74,34 @@ static osjob_t sendjob; const unsigned TX_INTERVAL = 60; // Pin mapping +#if defined(ARDUINO_SAMD_FEATHER_M0) +// Pin mapping for Adafruit Feather M0 LoRa, etc. const lmic_pinmap lmic_pins = { .nss = 8, .rxtx = LMIC_UNUSED_PIN, .rst = 4, - .dio = { 3, 6, LMIC_UNUSED_PIN }, + .dio = {3, 6, LMIC_UNUSED_PIN}, + .rxtx_rx_active = 0, + .rssi_cal = 8, // LBT cal for the Adafruit Feather M0 LoRa, in dB + .spi_freq = 8000000, +}; +#elif defined(ARDUINO_CATENA_4551) +// Pin mapping for Murata module / Catena 4551 +const lmic_pinmap lmic_pins = { + .nss = 7, + .rxtx = 29, + .rst = 8, + .dio = { 25, // DIO0 (IRQ) is D25 + 26, // DIO1 is D26 + 27, // DIO2 is D27 + }, + .rxtx_rx_active = 1, + .rssi_cal = 10, + .spi_freq = 8000000 // 8MHz }; +#else +# error "Unknown target" +#endif void onEvent (ev_t ev) { Serial.print(os_getTime()); @@ -123,9 +154,14 @@ void onEvent (ev_t ev) { // size, we don't use it in this example. LMIC_setLinkCheckMode(0); break; - case EV_RFU1: - Serial.println(F("EV_RFU1")); - break; + /* + || This event is defined but not used in the code. No + || point in wasting codespace on it. + || + || case EV_RFU1: + || Serial.println(F("EV_RFU1")); + || break; + */ case EV_JOIN_FAILED: Serial.println(F("EV_JOIN_FAILED")); break; @@ -161,8 +197,20 @@ void onEvent (ev_t ev) { case EV_LINK_ALIVE: Serial.println(F("EV_LINK_ALIVE")); break; - default: - Serial.println(F("Unknown event")); + /* + || This event is defined but not used in the code. No + || point in wasting codespace on it. + || + || case EV_SCAN_FOUND: + || Serial.println(F("EV_SCAN_FOUND")); + || break; + */ + case EV_TXSTART: + Serial.println(F("EV_TXSTART")); + break; + default: + Serial.print(F("Unknown event: ")); + Serial.println((unsigned) ev); break; } } diff --git a/examples/ttn-otaa/ttn-otaa.ino b/examples/ttn-otaa/ttn-otaa.ino index 28790e0a..acf3f4ed 100644 --- a/examples/ttn-otaa/ttn-otaa.ino +++ b/examples/ttn-otaa/ttn-otaa.ino @@ -1,5 +1,6 @@ /******************************************************************************* * Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman + * Copyright (c) 2018 Terry Moore, MCCI * * Permission is hereby granted, free of charge, to anyone * obtaining a copy of this document and accompanying files, @@ -33,22 +34,35 @@ #include #include +// +// For normal use, we require that you edit the sketch to replace FILLMEIN +// with values assigned by the TTN console. However, for regression tests, +// we want to be able to compile these scripts. The regression tests define +// COMPILE_REGRESSION_TEST, and in that case we define FILLMEIN to a non- +// working but innocuous value. +// +#ifdef COMPILE_REGRESSION_TEST +# define FILLMEIN 0 +#else +# warning "You must replace the values marked FILLMEIN with real values from the TTN control panel!" +# define FILLMEIN (#dont edit this, edit the lines that use FILLMEIN) +#endif + // This EUI must be in little-endian format, so least-significant-byte // first. When copying an EUI from ttnctl output, this means to reverse // the bytes. For TTN issued EUIs the last bytes should be 0xD5, 0xB3, // 0x70. -static const u1_t PROGMEM APPEUI[8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const u1_t PROGMEM APPEUI[8]={ FILLMEIN }; void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);} // This should also be in little endian format, see above. -static const u1_t PROGMEM DEVEUI[8]={ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const u1_t PROGMEM DEVEUI[8]={ FILLMEIN }; void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);} // This key should be in big endian format (or, since it is not really a // number but a block of memory, endianness does not really apply). In // practice, a key taken from ttnctl can be copied as-is. -// The key shown here is the semtech default key. -static const u1_t PROGMEM APPKEY[16] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C }; +static const u1_t PROGMEM APPKEY[16] = { FILLMEIN }; void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);} static uint8_t mydata[] = "Hello, world!"; @@ -113,9 +127,14 @@ void onEvent (ev_t ev) { // size, we don't use it in this example. LMIC_setLinkCheckMode(0); break; - case EV_RFU1: - Serial.println(F("EV_RFU1")); - break; + /* + || This event is defined but not used in the code. No + || point in wasting codespace on it. + || + || case EV_RFU1: + || Serial.println(F("EV_RFU1")); + || break; + */ case EV_JOIN_FAILED: Serial.println(F("EV_JOIN_FAILED")); break; @@ -151,8 +170,20 @@ void onEvent (ev_t ev) { case EV_LINK_ALIVE: Serial.println(F("EV_LINK_ALIVE")); break; - default: - Serial.println(F("Unknown event")); + /* + || This event is defined but not used in the code. No + || point in wasting codespace on it. + || + || case EV_SCAN_FOUND: + || Serial.println(F("EV_SCAN_FOUND")); + || break; + */ + case EV_TXSTART: + Serial.println(F("EV_TXSTART")); + break; + default: + Serial.print(F("Unknown event: ")); + Serial.println((unsigned) ev); break; } }