1
0
mirror of https://github.com/peterantypas/maiana.git synced 2025-05-29 13:50:29 -07:00

Initial changes for OP

This commit is contained in:
Peter Antypas 2021-09-23 09:35:59 -07:00
parent 735e36acd1
commit 18e14fe4c7
4 changed files with 49 additions and 6 deletions

View File

@ -53,6 +53,8 @@ private:
bool erasePage(); bool erasePage();
bool writePage(); bool writePage();
uint32_t nextAvailableOTPSlot(); uint32_t nextAvailableOTPSlot();
const char *hwRev();
const char *serNum();
}; };
#endif /* CONFIGURATION_HPP_ */ #endif /* CONFIGURATION_HPP_ */

View File

@ -87,7 +87,7 @@
#define CLI_FLAG_MAGIC 0x209a388d #define CLI_FLAG_MAGIC 0x209a388d
#define CONFIGURATION_ADDRESS 0x0800F800 #define CONFIGURATION_ADDRESS 0x0800F800
#define OTP_DATA 0 #define OTP_DATA 1
#define FW_REV "3.1.0" #define FW_REV "3.1.0"

View File

@ -124,6 +124,10 @@ void CommandProcessor::processCommand(const char *buff)
{ {
Configuration::instance().reportStationData(); Configuration::instance().reportStationData();
} }
else if ( s.find("sys?") == 0 )
{
Configuration::instance().reportSystemData();
}
else if ( s.find("dfu") == 0 ) else if ( s.find("dfu") == 0 )
{ {
jumpToBootloader(); jumpToBootloader();
@ -137,6 +141,18 @@ void CommandProcessor::processCommand(const char *buff)
{ {
fireTestPacket(); fireTestPacket();
} }
else if ( s.find("tx on") == 0 )
{
// TODO
}
else if ( s.find("tx off") == 0 )
{
// TODO
}
else if ( s.find("tx?") == 0 )
{
// TODO
}
else if (s.find("reboot") == 0 ) else if (s.find("reboot") == 0 )
{ {
bsp_reboot(); bsp_reboot();
@ -194,14 +210,17 @@ void CommandProcessor::writeOTPData(const std::string &s)
vector<string> tokens; vector<string> tokens;
Utils::tokenize(params, ' ', tokens); Utils::tokenize(params, ' ', tokens);
if ( tokens.size() < 2 ) if ( tokens.size() < 1 )
return; return;
OTPData data; OTPData data;
memset(&data, 0, sizeof data);
data.magic = OTP_MAGIC; data.magic = OTP_MAGIC;
data.rev = OTP_REV; data.rev = OTP_REV;
strlcpy(data.serialnum, tokens[0].c_str(), sizeof data.serialnum); strlcpy(data.hwrev, tokens[0].c_str(), sizeof data.hwrev);
strlcpy(data.hwrev, tokens[1].c_str(), sizeof data.hwrev); if ( tokens.size() > 1 )
strlcpy(data.serialnum, tokens[1].c_str(), sizeof data.serialnum);
bool result = Configuration::instance().writeOTP(data); bool result = Configuration::instance().writeOTP(data);
if ( result ) if ( result )

View File

@ -68,13 +68,31 @@ void Configuration::init()
} }
} }
const char *Configuration::hwRev()
{
const OTPData *otp = readOTP();
if ( otp )
return otp->hwrev;
else
return BSP_HW_REV;
}
const char *Configuration::serNum()
{
const OTPData *otp = readOTP();
if ( otp )
return otp->serialnum;
else
return "";
}
void Configuration::reportSystemData() void Configuration::reportSystemData()
{ {
Event *e = EventPool::instance().newEvent(PROPR_NMEA_SENTENCE); Event *e = EventPool::instance().newEvent(PROPR_NMEA_SENTENCE);
if ( !e ) if ( !e )
return; return;
sprintf(e->nmeaBuffer.sentence, "$PAISYS,%s,%s,%s*", BSP_HW_REV, FW_REV, ""); sprintf(e->nmeaBuffer.sentence, "$PAISYS,%s,%s,%s*", hwRev(), FW_REV, serNum());
Utils::completeNMEA(e->nmeaBuffer.sentence); Utils::completeNMEA(e->nmeaBuffer.sentence);
EventQueue::instance().push(e); EventQueue::instance().push(e);
@ -123,9 +141,13 @@ void Configuration::reportOTPData()
{ {
sprintf(e->nmeaBuffer.sentence, "$PAIOTP,%s,%s*", data->serialnum, data->hwrev); sprintf(e->nmeaBuffer.sentence, "$PAIOTP,%s,%s*", data->serialnum, data->hwrev);
} }
else
{
strcpy(e->nmeaBuffer.sentence, "$PAIOTP,,*");
}
Utils::completeNMEA(e->nmeaBuffer.sentence); Utils::completeNMEA(e->nmeaBuffer.sentence);
EventQueue::instance().push(e); EventQueue::instance().push(e);
} }
#endif #endif