Skip to content

Commit

Permalink
Merge pull request #198 from AEFeinstein/flight-sim-fix-for-portal
Browse files Browse the repository at this point in the history
Fix flight sim for portal
  • Loading branch information
AEFeinstein authored Jan 16, 2024
2 parents 0c48d20 + 693c414 commit ba86ec4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions main/modes/flight/flight.c
Original file line number Diff line number Diff line change
Expand Up @@ -2661,7 +2661,8 @@ static void FlightNetworkFrameCall(flight_t* tflight, uint32_t now, modelRangePa
bitct += WriteUEQ(&contents, 0);
bitct += WriteUEQ(&contents, 1);
bitct += WriteUEQ(&contents, NumActiveBoolets);
bitct += WriteUEQ(&contents, 23);
bitct += WriteUEQ(&contents, 0); // This is poisoned because of an oopsies with the Original Super 2024 Firmware. Do not use.
bitct += WriteUEQ(&contents, 0); // The number of chars to display (first char is color)
FinalizeUEQ(&contents, bitct);
*((uint32_t*)pp) = contents;
pp += 4;
Expand Down Expand Up @@ -2708,9 +2709,6 @@ static void FlightNetworkFrameCall(flight_t* tflight, uint32_t now, modelRangePa
pp += sizeof(b->flags);
}

memcpy(pp, "Xabcdefghijklmnopqrstuv", 23);
pp += 23;

int len = pp - espnow_buffer;
espNowSend((char*)espnow_buffer, len); // Don't enable yet.
// uprintf( "ESPNow Send: %d n", len );
Expand All @@ -2735,6 +2733,8 @@ static void FlightfnEspNowRecvCb(const esp_now_recv_info_t* esp_now_info, const
int i;
flight_t* flt = flight;

if (!flt) return;

if (flt->nNetworkMode == 0)
return;

Expand Down Expand Up @@ -2825,6 +2825,7 @@ static void FlightfnEspNowRecvCb(const esp_now_recv_info_t* esp_now_info, const
int modelCount = ReadUEQ(&assetCounts);
int shipCount = ReadUEQ(&assetCounts);
int booletCount = ReadUEQ(&assetCounts);
ReadUEQ(&assetCounts); // DO NOT USE, poisoned from 2024 Firmware
int textLength = ReadUEQ(&assetCounts);
// If we get a server packet, switch to server mode for a while.
if (!isPeer)
Expand Down Expand Up @@ -2994,7 +2995,7 @@ static void FlightfnEspNowRecvCb(const esp_now_recv_info_t* esp_now_info, const
if (textLength)
{
// NOTE: First char is color.
if (textLength < sizeof(flt->nettext) && data + textLength <= dataend)
if (textLength < sizeof(flt->nettext) && data + textLength <= dataend && textLength > 0)
{
memcpy(flt->nettext, data, textLength);
flt->nettext[textLength] = 0;
Expand Down
2 changes: 1 addition & 1 deletion main/modes/mainMenu/mainMenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void addSecretsMenu(void);
//==============================================================================

// It's good practice to declare immutable strings as const so they get placed in ROM, not RAM
const char mainMenuName[] = "Main Menu";
const char mainMenuName[] = "Main Menu 1.1";
static const char mainMenuShowSecretsMenuName[] = "ShowOnMenu: ";
static const char factoryResetName[] = "Factory Reset";
static const char confirmResetName[] = "! Confirm Reset !";
Expand Down

0 comments on commit ba86ec4

Please sign in to comment.