Some LoRa-stuff
This commit is contained in:
		| @@ -15,6 +15,8 @@ typedef enum DTCNums_e | ||||
|   DTC_FLASHFS_ERROR, | ||||
|   DTC_FLASHFS_VERSION_ERROR, | ||||
|   DTC_EEPROM_CFG_SANITY, | ||||
|   DTC_NO_LORA_FOUND, | ||||
|   DTC_NO_BATMNON_FOUND, | ||||
|   DTC_LAST_DTC | ||||
| } DTCNums_t; | ||||
|  | ||||
|   | ||||
| @@ -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 printModuleInformation(struct ModuleInformation moduleInformation); | ||||
|  | ||||
| void InitLoRa(void (*MPinHelper)(int, int)) | ||||
| bool InitLoRa(void (*MPinHelper)(int, int)) | ||||
| { | ||||
|     bool returnval; | ||||
|  | ||||
|     e220ttl.setMPins = MPinHelper; | ||||
|     e220ttl.begin(); | ||||
|     returnval = e220ttl.begin(); | ||||
|  | ||||
|     ResponseStructContainer c; | ||||
|     c = e220ttl.getConfiguration(); | ||||
|     // It's important get configuration pointer before all other operation | ||||
|     Configuration configuration = *(Configuration *)c.data; | ||||
|     Serial.println(c.status.getResponseDescription()); | ||||
|     Serial.println(c.status.code); | ||||
|     if (returnval == true) | ||||
|     { | ||||
|         ResponseStructContainer c; | ||||
|         c = e220ttl.getConfiguration(); | ||||
|         // It's important get configuration pointer before all other operation | ||||
|         Configuration configuration = *(Configuration *)c.data; | ||||
|         Serial.println(c.status.getResponseDescription()); | ||||
|         Serial.println(c.status.code); | ||||
|  | ||||
|     ResponseStructContainer cMi; | ||||
|     cMi = e220ttl.getModuleInformation(); | ||||
|     // It's important get information pointer before all other operation | ||||
|     // ModuleInformation mi = *(ModuleInformation *)cMi.data; | ||||
|         ResponseStructContainer cMi; | ||||
|         cMi = e220ttl.getModuleInformation(); | ||||
|         // It's important get information pointer before all other operation | ||||
|         // ModuleInformation mi = *(ModuleInformation *)cMi.data; | ||||
|  | ||||
|     Serial.println(cMi.status.getResponseDescription()); | ||||
|     Serial.println(cMi.status.code); | ||||
|         Serial.println(cMi.status.getResponseDescription()); | ||||
|         Serial.println(cMi.status.code); | ||||
|  | ||||
|     //	----------------------- DEFAULT TRANSPARENT WITH RSSI ----------------------- | ||||
|     configuration.ADDL = 0x02; | ||||
|     configuration.ADDH = 0x00; | ||||
|         //	----------------------- DEFAULT TRANSPARENT WITH RSSI ----------------------- | ||||
|         configuration.ADDL = 0x02; | ||||
|         configuration.ADDH = 0x00; | ||||
|  | ||||
|     configuration.CHAN = 23; | ||||
|         configuration.CHAN = 23; | ||||
|  | ||||
|     configuration.SPED.uartBaudRate = UART_BPS_9600; | ||||
|     configuration.SPED.airDataRate = AIR_DATA_RATE_010_24; | ||||
|     configuration.SPED.uartParity = MODE_00_8N1; | ||||
|         configuration.SPED.uartBaudRate = UART_BPS_9600; | ||||
|         configuration.SPED.airDataRate = AIR_DATA_RATE_010_24; | ||||
|         configuration.SPED.uartParity = MODE_00_8N1; | ||||
|  | ||||
|     configuration.OPTION.subPacketSetting = SPS_200_00; | ||||
|     configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_ENABLED; | ||||
|     configuration.OPTION.transmissionPower = POWER_22; | ||||
|         configuration.OPTION.subPacketSetting = SPS_200_00; | ||||
|         configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_ENABLED; | ||||
|         configuration.OPTION.transmissionPower = POWER_22; | ||||
|  | ||||
|     configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED; | ||||
|     configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION; | ||||
|     configuration.TRANSMISSION_MODE.enableLBT = LBT_ENABLED; | ||||
|     configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011; | ||||
|         configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED; | ||||
|         configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION; | ||||
|         configuration.TRANSMISSION_MODE.enableLBT = LBT_ENABLED; | ||||
|         configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011; | ||||
|  | ||||
|     // Set configuration changed and set to not hold the configuration | ||||
|     ResponseStatus rs = e220ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE); | ||||
|     Serial.println(rs.getResponseDescription()); | ||||
|     Serial.println(rs.code); | ||||
|     c.close(); | ||||
|         // Set configuration changed and set to not hold the configuration | ||||
|         ResponseStatus rs = e220ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE); | ||||
|         Serial.println(rs.getResponseDescription()); | ||||
|         Serial.println(rs.code); | ||||
|         c.close(); | ||||
|  | ||||
|     printParameters(configuration); | ||||
|         printParameters(configuration); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         MaintainDTC(DTC_NO_LORA_FOUND, DTC_WARN, true); | ||||
|     } | ||||
|     return returnval; | ||||
| } | ||||
|  | ||||
| void LoRa_Process() | ||||
|   | ||||
| @@ -14,7 +14,7 @@ | ||||
|  | ||||
| #define FREQUENCY_868 | ||||
|  | ||||
| void InitLoRa(void (*MPinHelper)(int, int)); | ||||
| bool InitLoRa(void (*MPinHelper)(int, int)); | ||||
| void LoRa_Process(); | ||||
| void sendStatus_LoRa(); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user