|
|
@@ -5,52 +5,62 @@ LoRa_E220 e220ttl(GPIO_LORA_TX, GPIO_LORA_RX, GPIO_LORA_AUX, 3, 4); // Arduino R
|
|
|
|
void printParameters(struct Configuration configuration);
|
|
|
|
void printParameters(struct Configuration configuration);
|
|
|
|
void printModuleInformation(struct ModuleInformation moduleInformation);
|
|
|
|
void printModuleInformation(struct ModuleInformation moduleInformation);
|
|
|
|
|
|
|
|
|
|
|
|
void InitLoRa(void (*MPinHelper)(int, int))
|
|
|
|
bool InitLoRa(void (*MPinHelper)(int, int))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
bool returnval;
|
|
|
|
|
|
|
|
|
|
|
|
e220ttl.setMPins = MPinHelper;
|
|
|
|
e220ttl.setMPins = MPinHelper;
|
|
|
|
e220ttl.begin();
|
|
|
|
returnval = e220ttl.begin();
|
|
|
|
|
|
|
|
|
|
|
|
ResponseStructContainer c;
|
|
|
|
if (returnval == true)
|
|
|
|
c = e220ttl.getConfiguration();
|
|
|
|
{
|
|
|
|
// It's important get configuration pointer before all other operation
|
|
|
|
ResponseStructContainer c;
|
|
|
|
Configuration configuration = *(Configuration *)c.data;
|
|
|
|
c = e220ttl.getConfiguration();
|
|
|
|
Serial.println(c.status.getResponseDescription());
|
|
|
|
// It's important get configuration pointer before all other operation
|
|
|
|
Serial.println(c.status.code);
|
|
|
|
Configuration configuration = *(Configuration *)c.data;
|
|
|
|
|
|
|
|
Serial.println(c.status.getResponseDescription());
|
|
|
|
|
|
|
|
Serial.println(c.status.code);
|
|
|
|
|
|
|
|
|
|
|
|
ResponseStructContainer cMi;
|
|
|
|
ResponseStructContainer cMi;
|
|
|
|
cMi = e220ttl.getModuleInformation();
|
|
|
|
cMi = e220ttl.getModuleInformation();
|
|
|
|
// It's important get information pointer before all other operation
|
|
|
|
// It's important get information pointer before all other operation
|
|
|
|
// ModuleInformation mi = *(ModuleInformation *)cMi.data;
|
|
|
|
// ModuleInformation mi = *(ModuleInformation *)cMi.data;
|
|
|
|
|
|
|
|
|
|
|
|
Serial.println(cMi.status.getResponseDescription());
|
|
|
|
Serial.println(cMi.status.getResponseDescription());
|
|
|
|
Serial.println(cMi.status.code);
|
|
|
|
Serial.println(cMi.status.code);
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------- DEFAULT TRANSPARENT WITH RSSI -----------------------
|
|
|
|
// ----------------------- DEFAULT TRANSPARENT WITH RSSI -----------------------
|
|
|
|
configuration.ADDL = 0x02;
|
|
|
|
configuration.ADDL = 0x02;
|
|
|
|
configuration.ADDH = 0x00;
|
|
|
|
configuration.ADDH = 0x00;
|
|
|
|
|
|
|
|
|
|
|
|
configuration.CHAN = 23;
|
|
|
|
configuration.CHAN = 23;
|
|
|
|
|
|
|
|
|
|
|
|
configuration.SPED.uartBaudRate = UART_BPS_9600;
|
|
|
|
configuration.SPED.uartBaudRate = UART_BPS_9600;
|
|
|
|
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
|
|
|
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
|
|
|
configuration.SPED.uartParity = MODE_00_8N1;
|
|
|
|
configuration.SPED.uartParity = MODE_00_8N1;
|
|
|
|
|
|
|
|
|
|
|
|
configuration.OPTION.subPacketSetting = SPS_200_00;
|
|
|
|
configuration.OPTION.subPacketSetting = SPS_200_00;
|
|
|
|
configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_ENABLED;
|
|
|
|
configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_ENABLED;
|
|
|
|
configuration.OPTION.transmissionPower = POWER_22;
|
|
|
|
configuration.OPTION.transmissionPower = POWER_22;
|
|
|
|
|
|
|
|
|
|
|
|
configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
|
|
|
configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
|
|
|
configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
|
|
|
configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
|
|
|
configuration.TRANSMISSION_MODE.enableLBT = LBT_ENABLED;
|
|
|
|
configuration.TRANSMISSION_MODE.enableLBT = LBT_ENABLED;
|
|
|
|
configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
|
|
|
configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
|
|
|
|
|
|
|
|
|
|
|
// Set configuration changed and set to not hold the configuration
|
|
|
|
// Set configuration changed and set to not hold the configuration
|
|
|
|
ResponseStatus rs = e220ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE);
|
|
|
|
ResponseStatus rs = e220ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE);
|
|
|
|
Serial.println(rs.getResponseDescription());
|
|
|
|
Serial.println(rs.getResponseDescription());
|
|
|
|
Serial.println(rs.code);
|
|
|
|
Serial.println(rs.code);
|
|
|
|
c.close();
|
|
|
|
c.close();
|
|
|
|
|
|
|
|
|
|
|
|
printParameters(configuration);
|
|
|
|
printParameters(configuration);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MaintainDTC(DTC_NO_LORA_FOUND, DTC_WARN, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return returnval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LoRa_Process()
|
|
|
|
void LoRa_Process()
|
|
|
|