mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 23:12:44 +02:00
modification sendDateTime
Origin commit data
------------------
Branch: master
Commit: c41f0ea13d
Author: max_10 <max_10@gmx.de>
Date: 2017-10-23 (Mon, 23 Oct 2017)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -48,37 +48,40 @@ int eDVBCIDateTimeSession::doAction()
|
|||||||
case stateStarted:
|
case stateStarted:
|
||||||
return 0;
|
return 0;
|
||||||
case stateSendDateTime:
|
case stateSendDateTime:
|
||||||
{
|
sendDateTime();
|
||||||
struct tm tm_gmt;
|
|
||||||
struct tm tm_loc;
|
|
||||||
unsigned char tag[3] = {0x9f, 0x84, 0x41}; // date_time_response
|
|
||||||
unsigned char msg[7] = {0, 0, 0, 0, 0, 0, 0};
|
|
||||||
printf("%s -> %s\n", FILENAME, __FUNCTION__);
|
|
||||||
time_t t = time(NULL);
|
|
||||||
if ( gmtime_r(&t, &tm_gmt) && localtime_r(&t, &tm_loc) )
|
|
||||||
{
|
|
||||||
int Y = tm_gmt.tm_year;
|
|
||||||
int M = tm_gmt.tm_mon + 1;
|
|
||||||
int D = tm_gmt.tm_mday;
|
|
||||||
int L = (M == 1 || M == 2) ? 1 : 0;
|
|
||||||
int MJD = 14956 + D + (int)((Y - L) * 365.25) + (int)((M + 1 + L * 12) * 30.6001);
|
|
||||||
|
|
||||||
#define DEC2BCD(d) (((d / 10) << 4) + (d % 10))
|
|
||||||
|
|
||||||
msg[0] = htons(MJD) >> 8;
|
|
||||||
msg[1] = htons(MJD) & 0xff;
|
|
||||||
msg[2] = DEC2BCD(tm_gmt.tm_hour);
|
|
||||||
msg[3] = DEC2BCD(tm_gmt.tm_min);
|
|
||||||
msg[4] = DEC2BCD(tm_gmt.tm_sec);
|
|
||||||
msg[5] = htons(tm_loc.tm_gmtoff / 60) >> 8;
|
|
||||||
msg[6] = htons(tm_loc.tm_gmtoff / 60) & 0xff;
|
|
||||||
}
|
|
||||||
sendAPDU(tag, msg, 7);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
case stateFinal:
|
case stateFinal:
|
||||||
printf("stateFinal und action! kann doch garnicht sein ;)\n");
|
printf("stateFinal und action! kann doch garnicht sein ;)\n");
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void eDVBCIDateTimeSession::sendDateTime()
|
||||||
|
{
|
||||||
|
struct tm tm_gmt;
|
||||||
|
struct tm tm_loc;
|
||||||
|
unsigned char tag[3] = {0x9f, 0x84, 0x41}; // date_time_response
|
||||||
|
unsigned char msg[7] = {0, 0, 0, 0, 0, 0, 0};
|
||||||
|
printf("%s -> %s\n", FILENAME, __FUNCTION__);
|
||||||
|
time_t t = time(NULL);
|
||||||
|
if ( gmtime_r(&t, &tm_gmt) && localtime_r(&t, &tm_loc) )
|
||||||
|
{
|
||||||
|
int Y = tm_gmt.tm_year;
|
||||||
|
int M = tm_gmt.tm_mon + 1;
|
||||||
|
int D = tm_gmt.tm_mday;
|
||||||
|
int L = (M == 1 || M == 2) ? 1 : 0;
|
||||||
|
int MJD = 14956 + D + (int)((Y - L) * 365.25) + (int)((M + 1 + L * 12) * 30.6001);
|
||||||
|
|
||||||
|
#define DEC2BCD(d) (((d / 10) << 4) + (d % 10))
|
||||||
|
|
||||||
|
msg[0] = htons(MJD) >> 8;
|
||||||
|
msg[1] = htons(MJD) & 0xff;
|
||||||
|
msg[2] = DEC2BCD(tm_gmt.tm_hour);
|
||||||
|
msg[3] = DEC2BCD(tm_gmt.tm_min);
|
||||||
|
msg[4] = DEC2BCD(tm_gmt.tm_sec);
|
||||||
|
msg[5] = htons(tm_loc.tm_gmtoff / 60) >> 8;
|
||||||
|
msg[6] = htons(tm_loc.tm_gmtoff / 60) & 0xff;
|
||||||
|
}
|
||||||
|
sendAPDU(tag, msg, 7);
|
||||||
|
}
|
||||||
|
@@ -13,6 +13,7 @@ class eDVBCIDateTimeSession: public eDVBCISession
|
|||||||
public:
|
public:
|
||||||
eDVBCIDateTimeSession(eDVBCISlot *tslot);
|
eDVBCIDateTimeSession(eDVBCISlot *tslot);
|
||||||
~eDVBCIDateTimeSession();
|
~eDVBCIDateTimeSession();
|
||||||
|
void sendDateTime();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user