Skip to content

Commit

Permalink
imp
Browse files Browse the repository at this point in the history
  • Loading branch information
htotoo committed Nov 18, 2024
1 parent 71c1986 commit 19a9954
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
8 changes: 6 additions & 2 deletions Source/data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,11 @@ <h1>ESP32 PP v0.14</h1>
//need a download progressbar?
if (expectedFileSize > 0) {
var gotlines = respLines.length - 1;
var byteperline = (respLastLine.length - 2) / 2;
gotbytes = gotlines * byteperline;
gotbytes = 0;
for (let j = 0; j < gotlines; j++) {
var byteperline = (respLines[j].length - 2) / 2;
gotbytes += byteperline;
}
var progress = gotbytes / expectedFileSize * 100;
if (progress > 100) progress = 100;
setProgress(progress);
Expand Down Expand Up @@ -559,6 +562,7 @@ <h1>ESP32 PP v0.14</h1>
enadisaControls(false);
var tosend = "fread " + expectedFileSize.toString() + "\r\n";
respWaiting = PROMPT;//?!
await new Promise(r => setTimeout(r, 100));
await sendAndWait(tosend);
//check if i downloaded it or not
if (gotbytes < expectedFileSize) {
Expand Down
16 changes: 10 additions & 6 deletions Source/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ float temperature = 0.0;
float humidity = 0.0;
float pressure = 0.0;
uint16_t light = 0;
ppgpssmall_t gpsdata;
ppgpssmall_t gpsdata{200, 200, 0, 0, 0, 0, {}, {}};
bool gotAnyGps = false;
bool downloadedTLE = false;
uint16_t lastReportedMxS = 0; // gps last reported gps time mix to see if it is changed. if not changes, it stuck (bad signal, no update), so won't update PP based on it
Expand Down Expand Up @@ -266,6 +266,10 @@ esp_err_t http_event_handler(esp_http_client_event_t* evt) {
}

esp_err_t load_satellite_tle(const std::string& sat_to_track) {
if (sat_to_track.empty()) {
ESP_LOGE(TAG, "Satellite name is empty.");
return ESP_FAIL;
}
std::string l1, l2;
// Open the TLE file from SPIFFS
std::ifstream file("/spiffs/mini.tle");
Expand Down Expand Up @@ -481,7 +485,7 @@ void app_main(void) {

PPHandler::add_custom_command(PPCMD_SATTRACK_SETSAT, [](pp_command_data_t data) {
std::string str;
for(int i = 0; i < data.data->size(); i++)
for(size_t i = 0; i < data.data->size(); ++i)
{
if (data.data->at(i) == 0) break;
str += (char)data.data->at(i);
Expand Down Expand Up @@ -563,7 +567,7 @@ void app_main(void) {
// REPORT SENSOR DATA TO PP. EACH HAS OWN TIMER!
char gotusb[300];
if (PPShellComm::getAnyConnected() == 1 && !PPShellComm::getInCommand() && (time_millis - last_millis[TimerEntry_REPORTPPGPS] > timer_millis[TimerEntry_REPORTPPGPS])) {
if (gpsdata.latitude != 0 || gpsdata.longitude != 0) {
if (gpsdata.latitude != 200 || gpsdata.longitude != 200) {
snprintf(gotusb, 290, "gotgps %.06f %.06f %.02f %.01f %d\r\n", gpsdata.latitude, gpsdata.longitude, gpsdata.altitude, gpsdata.speed, gpsdata.sats_in_use);
ESP_LOGI(TAG, "%s", gotusb);
if (PPShellComm::wait_till_sending(1)) {
Expand Down Expand Up @@ -613,22 +617,22 @@ void app_main(void) {
}

if (time_millis - last_millis[TimerEntry_REPORTRGB] > timer_millis[TimerEntry_REPORTRGB]) {
LedFeedback::rgb_set_by_status(PPShellComm::getAnyConnected() | i2p_pp_conn_state, WifiM::getWifiStaStatus(), WifiM::getWifiApClientNum() > 0, gpsdata.latitude != 0 && gpsdata.longitude != 0 && gpsdata.sats_in_use > 2);
LedFeedback::rgb_set_by_status(PPShellComm::getAnyConnected() | i2p_pp_conn_state, WifiM::getWifiStaStatus(), WifiM::getWifiApClientNum() > 0, gpsdata.latitude != 200 && gpsdata.longitude != 200 && gpsdata.sats_in_use > 2);
last_millis[TimerEntry_REPORTRGB] = time_millis;
}

if (time_millis - last_millis[TimerEntry_SATTRACK] > timer_millis[TimerEntry_SATTRACK]) {
// check for new gps data
// ESP_LOGI(TAG, "qgps: %f %f", sattrackdata.lat, sattrackdata.lon);
if (sat_data_loaded) {
if (gpsdata.latitude != 0 || gpsdata.longitude != 0) {
if (gpsdata.latitude != 200 || gpsdata.longitude != 200) {
sattrackdata.lat = gpsdata.latitude;
sattrackdata.lon = gpsdata.longitude;
}
// if only old, or etc use that nvm
if (sattrackdata.lat != 0 || sattrackdata.lon != 0) {
struct tm timeinfo;
sat.site(gpsdata.latitude, gpsdata.longitude, gpsdata.altitude);
sat.site(sattrackdata.lat, sattrackdata.lon, gpsdata.altitude);
double jd = 0;
if (gpsdata.date.year < 44 && gpsdata.date.year >= 23) // has valid gps time
{
Expand Down

0 comments on commit 19a9954

Please sign in to comment.