Skip to content

Commit 01f999c

Browse files
committed
argos sensor msg construction arribada#1
1 parent 2746581 commit 01f999c

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

core/services/argos_tx_service.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ void ArgosTxService::process_sensor_burst() {
231231
m_depth_pile_manager.retrieve_sensor_single((unsigned int)argos_config.depth_pile, ServiceIdentifier::PH_SENSOR),
232232
m_depth_pile_manager.retrieve_sensor_single((unsigned int)argos_config.depth_pile, ServiceIdentifier::PRESSURE_SENSOR),
233233
m_depth_pile_manager.retrieve_sensor_single((unsigned int)argos_config.depth_pile, ServiceIdentifier::SEA_TEMP_SENSOR),
234+
m_depth_pile_manager.retrieve_sensor_single((unsigned int)argos_config.depth_pile, ServiceIdentifier::BARO_SENSOR), //Tom
234235
argos_config.is_lb,
235236
argos_config.is_out_of_zone,
236237
size_bits);
@@ -602,6 +603,7 @@ ArticPacket ArgosPacketBuilder::build_sensor_packet(GPSLogEntry* gps_entry,
602603
ServiceSensorData *ph_sensor,
603604
ServiceSensorData *pressure_sensor,
604605
ServiceSensorData *sea_temp_sensor,
606+
ServiceSensorData *baro_sensor, //Tom
605607
bool is_out_of_zone, bool is_low_battery,
606608
unsigned int& size_bits) {
607609

@@ -679,6 +681,10 @@ ArticPacket ArgosPacketBuilder::build_sensor_packet(GPSLogEntry* gps_entry,
679681
DEBUG_TRACE("ArgosPacketBuilder::build_sensor_packet: sea_temp=%06X", (unsigned int)sea_temp_sensor->port[0]);
680682
PACK_BITS((unsigned int)sea_temp_sensor->port[0], packet, base_pos, 21);
681683
}
684+
if (baro_sensor != nullptr) {
685+
DEBUG_TRACE("ArgosPacketBuilder::build_sensor_packet: baro=%06X", (unsigned int)baro_sensor->port[0]);
686+
PACK_BITS((unsigned int)baro_sensor->port[0], packet, base_pos, 21); // Tom
687+
}
682688

683689
// Calculate CRC8
684690
unsigned char crc8 = CRC8::checksum(packet.substr(1), base_pos - 8);
@@ -1003,6 +1009,14 @@ void ArgosDepthPileManager::notify_peer_event(ServiceEvent& e) {
10031009
ServiceSensorData& entry = std::get<ServiceSensorData>(e.event_data);
10041010
m_sea_temp_cache.port[0] = (unsigned int)((entry.port[0] + 126.0) * 1000U);
10051011
m_sensor_tx_current |= (1 << (int)ServiceIdentifier::SEA_TEMP_SENSOR);
1012+
1013+
} else if (e.event_source == ServiceIdentifier::BARO_SENSOR && // Tom //
1014+
e.event_type == ServiceEventType::SERVICE_LOG_UPDATED) {
1015+
DEBUG_TRACE("ArgosDepthPileManager::notify_peer_event: BARO cache set");
1016+
ServiceSensorData& entry = std::get<ServiceSensorData>(e.event_data);
1017+
m_baro_cache.port[0] = (unsigned int)((entry.port[0] + 0) * 1000U);
1018+
m_sensor_tx_current |= (1 << (int)ServiceIdentifier::BARO_SENSOR); //Tom //
1019+
10061020
} else if (e.event_source == ServiceIdentifier::GNSS_SENSOR &&
10071021
e.event_type == ServiceEventType::SERVICE_INACTIVE) {
10081022

@@ -1029,6 +1043,12 @@ void ArgosDepthPileManager::notify_peer_event(ServiceEvent& e) {
10291043
m_sea_temp_cache.port[0] = 0xFFFFFFFF;
10301044
m_sensor_tx_current |= (1 << (int)ServiceIdentifier::SEA_TEMP_SENSOR);
10311045
}
1046+
1047+
else if (((1 << (int)ServiceIdentifier::BARO_SENSOR) & m_sensor_tx_enable) && //Tom
1048+
((1 << (int)ServiceIdentifier::BARO_SENSOR) & m_sensor_tx_current) == 0) {
1049+
m_baro_cache.port[0] = 0xFFFFFFFF;
1050+
m_sensor_tx_current |= (1 << (int)ServiceIdentifier::BARO_SENSOR);
1051+
}
10321052
update_depth_pile();
10331053
}, "DepthPileTimeout", Scheduler::DEFAULT_PRIORITY, 2000U);
10341054
}
@@ -1072,6 +1092,10 @@ void ArgosDepthPileManager::update_depth_pile() {
10721092
// Store the entry into the depth pile
10731093
m_sea_temp_depth_pile.store(m_sea_temp_cache, burst_counter);
10741094
}
1095+
if (m_sensor_tx_current & (1 << (int)ServiceIdentifier::BARO_SENSOR)) { // Tom
1096+
// Store the entry into the depth pile
1097+
m_baro_depth_pile.store(m_baro_cache, burst_counter);
1098+
}
10751099
m_sensor_tx_current = 0;
10761100
}
10771101
}

core/services/argos_tx_service.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ class ArgosPacketBuilder {
172172
ServiceSensorData *ph_sensor,
173173
ServiceSensorData *pressure_sensor,
174174
ServiceSensorData *sea_temp_sensor,
175+
ServiceSensorData *baro_sensor, // Tom
175176
bool is_out_of_zone, bool is_low_battery,
176177
unsigned int& size_bits
177178
);
@@ -233,6 +234,7 @@ class ArgosDepthPileManager {
233234
m_ph_depth_pile.clear();
234235
m_pressure_depth_pile.clear();
235236
m_sea_temp_depth_pile.clear();
237+
m_baro_temp_depth_pile.clear();
236238
}
237239
bool eligible() {
238240
return m_gps_depth_pile.eligible();
@@ -264,6 +266,8 @@ class ArgosDepthPileManager {
264266
return m_pressure_depth_pile.retrieve(depth_pile, 1).at(0);
265267
} else if (service == ServiceIdentifier::SEA_TEMP_SENSOR) {
266268
return m_sea_temp_depth_pile.retrieve(depth_pile, 1).at(0);
269+
} else if (service == ServiceIdentifier::BARO_SENSOR) {
270+
return m_baro_depth_pile.retrieve(depth_pile, 1).at(0);
267271
} else
268272
throw ErrorCode::RESOURCE_NOT_AVAILABLE;
269273
} catch (const std::out_of_range& e) {
@@ -285,6 +289,9 @@ class ArgosDepthPileManager {
285289
ServiceSensorData m_ph_cache;
286290
ArgosDepthPile<ServiceSensorData> m_sea_temp_depth_pile;
287291
ServiceSensorData m_sea_temp_cache;
292+
ArgosDepthPile<ServiceSensorData> m_baro_depth_pile;
293+
ServiceSensorData m_baro_cache;
294+
288295

289296
void update_depth_pile();
290297
};

0 commit comments

Comments
 (0)