Final version of the exercise on the Things Network
Dependencies: X_NUCLEO_IKS01A2
Revision 46:a124538e2891, committed 2019-01-10
- Comitter:
- mbed_official
- Date:
- Thu Jan 10 12:15:30 2019 +0000
- Parent:
- 45:7df71f7c950b
- Child:
- 47:b6d132f1079f
- Commit message:
- Docathon updates (#115)
Docathon updates
-Update mbed-lora-radio-drv
-Follow Mbed OS coding style
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-lorawan
Changed in this revision
--- a/DummySensor.h Thu Jan 03 15:30:32 2019 +0000
+++ b/DummySensor.h Thu Jan 10 12:15:30 2019 +0000
@@ -21,13 +21,19 @@
/*
* A dummy sensor for Mbed LoRa Test Application
*/
-class DS1820
-{
+class DS1820 {
public:
- DS1820(uint32_t) { value = 1.0f; };
- bool begin() { return true; };
+ DS1820(uint32_t)
+ {
+ value = 1.0f;
+ };
+ bool begin()
+ {
+ return true;
+ };
void startConversion() {};
- float read() {
+ float read()
+ {
value += 1.1f;
return value;
}
--- a/README.md Thu Jan 03 15:30:32 2019 +0000
+++ b/README.md Thu Jan 10 12:15:30 2019 +0000
@@ -25,7 +25,7 @@
If you are using an Mbed Enabled radio shield such as [Mbed SX1276 shield LoRa](https://os.mbed.com/components/SX1276MB1xAS/) or [Mbed SX1272 LoRa shield ](https://os.mbed.com/components/SX1272MB2xAS/) with any Mbed Enabled board, this part is relevant. You can use any Mbed Enabled board that comes with an arduino form factor.
-Please select your radio type by modifying the `lora-radio` field and providing a pin set if it is different from the default. For example:
+Please select your radio type by modifying the `lora-radio` field in `mbed_app.json` and providing a pin set if it is different from the default. For example:
```json
"lora-radio": {
--- a/lora_radio_helper.h Thu Jan 03 15:30:32 2019 +0000 +++ b/lora_radio_helper.h Thu Jan 10 12:15:30 2019 +0000 @@ -28,48 +28,48 @@ #if (MBED_CONF_APP_LORA_RADIO == SX1272) - SX1272_LoRaRadio radio(MBED_CONF_APP_LORA_SPI_MOSI, - MBED_CONF_APP_LORA_SPI_MISO, - MBED_CONF_APP_LORA_SPI_SCLK, - MBED_CONF_APP_LORA_CS, - MBED_CONF_APP_LORA_RESET, - MBED_CONF_APP_LORA_DIO0, - MBED_CONF_APP_LORA_DIO1, - MBED_CONF_APP_LORA_DIO2, - MBED_CONF_APP_LORA_DIO3, - MBED_CONF_APP_LORA_DIO4, - MBED_CONF_APP_LORA_DIO5, - MBED_CONF_APP_LORA_RF_SWITCH_CTL1, - MBED_CONF_APP_LORA_RF_SWITCH_CTL2, - MBED_CONF_APP_LORA_TXCTL, - MBED_CONF_APP_LORA_RXCTL, - MBED_CONF_APP_LORA_ANT_SWITCH, - MBED_CONF_APP_LORA_PWR_AMP_CTL, - MBED_CONF_APP_LORA_TCXO); +SX1272_LoRaRadio radio(MBED_CONF_APP_LORA_SPI_MOSI, + MBED_CONF_APP_LORA_SPI_MISO, + MBED_CONF_APP_LORA_SPI_SCLK, + MBED_CONF_APP_LORA_CS, + MBED_CONF_APP_LORA_RESET, + MBED_CONF_APP_LORA_DIO0, + MBED_CONF_APP_LORA_DIO1, + MBED_CONF_APP_LORA_DIO2, + MBED_CONF_APP_LORA_DIO3, + MBED_CONF_APP_LORA_DIO4, + MBED_CONF_APP_LORA_DIO5, + MBED_CONF_APP_LORA_RF_SWITCH_CTL1, + MBED_CONF_APP_LORA_RF_SWITCH_CTL2, + MBED_CONF_APP_LORA_TXCTL, + MBED_CONF_APP_LORA_RXCTL, + MBED_CONF_APP_LORA_ANT_SWITCH, + MBED_CONF_APP_LORA_PWR_AMP_CTL, + MBED_CONF_APP_LORA_TCXO); #elif (MBED_CONF_APP_LORA_RADIO == SX1276) - SX1276_LoRaRadio radio(MBED_CONF_APP_LORA_SPI_MOSI, - MBED_CONF_APP_LORA_SPI_MISO, - MBED_CONF_APP_LORA_SPI_SCLK, - MBED_CONF_APP_LORA_CS, - MBED_CONF_APP_LORA_RESET, - MBED_CONF_APP_LORA_DIO0, - MBED_CONF_APP_LORA_DIO1, - MBED_CONF_APP_LORA_DIO2, - MBED_CONF_APP_LORA_DIO3, - MBED_CONF_APP_LORA_DIO4, - MBED_CONF_APP_LORA_DIO5, - MBED_CONF_APP_LORA_RF_SWITCH_CTL1, - MBED_CONF_APP_LORA_RF_SWITCH_CTL2, - MBED_CONF_APP_LORA_TXCTL, - MBED_CONF_APP_LORA_RXCTL, - MBED_CONF_APP_LORA_ANT_SWITCH, - MBED_CONF_APP_LORA_PWR_AMP_CTL, - MBED_CONF_APP_LORA_TCXO); +SX1276_LoRaRadio radio(MBED_CONF_APP_LORA_SPI_MOSI, + MBED_CONF_APP_LORA_SPI_MISO, + MBED_CONF_APP_LORA_SPI_SCLK, + MBED_CONF_APP_LORA_CS, + MBED_CONF_APP_LORA_RESET, + MBED_CONF_APP_LORA_DIO0, + MBED_CONF_APP_LORA_DIO1, + MBED_CONF_APP_LORA_DIO2, + MBED_CONF_APP_LORA_DIO3, + MBED_CONF_APP_LORA_DIO4, + MBED_CONF_APP_LORA_DIO5, + MBED_CONF_APP_LORA_RF_SWITCH_CTL1, + MBED_CONF_APP_LORA_RF_SWITCH_CTL2, + MBED_CONF_APP_LORA_TXCTL, + MBED_CONF_APP_LORA_RXCTL, + MBED_CONF_APP_LORA_ANT_SWITCH, + MBED_CONF_APP_LORA_PWR_AMP_CTL, + MBED_CONF_APP_LORA_TCXO); #else - #error "Unknown LoRa radio specified (SX1272,SX1276 are valid)" +#error "Unknown LoRa radio specified (SX1272,SX1276 are valid)" #endif #endif /* APP_LORA_RADIO_HELPER_H_ */
--- a/main.cpp Thu Jan 03 15:30:32 2019 +0000
+++ b/main.cpp Thu Jan 10 12:15:30 2019 +0000
@@ -67,7 +67,7 @@
* providing an event queue to the stack that will be used for ISR deferment as
* well as application information event queuing.
*/
-static EventQueue ev_queue(MAX_NUMBER_OF_EVENTS * EVENTS_EVENT_SIZE);
+static EventQueue ev_queue(MAX_NUMBER_OF_EVENTS *EVENTS_EVENT_SIZE);
/**
* Event handler.
@@ -78,7 +78,7 @@
static void lora_event_handler(lorawan_event_t event);
/**
- * Constructing Mbed LoRaWANInterface and passing it down the radio object.
+ * Constructing Mbed LoRaWANInterface and passing it the radio object from lora_radio_helper.
*/
static LoRaWANInterface lorawan(radio);
@@ -90,7 +90,7 @@
/**
* Entry point for application
*/
-int main (void)
+int main(void)
{
// setup tracing
setup_trace();
@@ -112,7 +112,7 @@
// Set number of retries in case of CONFIRMED messages
if (lorawan.set_confirmed_msg_retries(CONFIRMED_MSG_RETRY_COUNTER)
- != LORAWAN_STATUS_OK) {
+ != LORAWAN_STATUS_OK) {
printf("\r\n set_confirmed_msg_retries failed! \r\n\r\n");
return -1;
}
@@ -131,7 +131,7 @@
retcode = lorawan.connect();
if (retcode == LORAWAN_STATUS_OK ||
- retcode == LORAWAN_STATUS_CONNECT_IN_PROGRESS) {
+ retcode == LORAWAN_STATUS_CONNECT_IN_PROGRESS) {
} else {
printf("\r\n Connection error, code = %d \r\n", retcode);
return -1;
@@ -164,15 +164,15 @@
return;
}
- packet_len = sprintf((char*) tx_buffer, "Dummy Sensor Value is %3.1f",
- sensor_value);
+ packet_len = sprintf((char *) tx_buffer, "Dummy Sensor Value is %3.1f",
+ sensor_value);
retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len,
MSG_CONFIRMED_FLAG);
if (retcode < 0) {
retcode == LORAWAN_STATUS_WOULD_BLOCK ? printf("send - WOULD BLOCK\r\n")
- : printf("\r\n send() - Error code %d \r\n", retcode);
+ : printf("\r\n send() - Error code %d \r\n", retcode);
if (retcode == LORAWAN_STATUS_WOULD_BLOCK) {
//retry in 3 seconds
@@ -195,7 +195,7 @@
int16_t retcode;
retcode = lorawan.receive(MBED_CONF_LORA_APP_PORT, rx_buffer,
sizeof(rx_buffer),
- MSG_CONFIRMED_FLAG|MSG_UNCONFIRMED_FLAG);
+ MSG_CONFIRMED_FLAG | MSG_UNCONFIRMED_FLAG);
if (retcode < 0) {
printf("\r\n receive() - Error code %d \r\n", retcode);
--- a/mbed-lora-radio-drv.lib Thu Jan 03 15:30:32 2019 +0000 +++ b/mbed-lora-radio-drv.lib Thu Jan 10 12:15:30 2019 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-semtech-lora-rf-drivers#0c7dce4ff9bd36cc37cfdcfdbffbfaba83864d2e +https://github.com/ARMmbed/mbed-semtech-lora-rf-drivers#16958f814d505cfbbedfa16d9bf8b9dff0e0442b