mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 15:02:58 +02:00
modification sendDateTime
This commit is contained in:
@@ -48,37 +48,40 @@ int eDVBCIDateTimeSession::doAction()
|
||||
case stateStarted:
|
||||
return 0;
|
||||
case stateSendDateTime:
|
||||
{
|
||||
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);
|
||||
sendDateTime();
|
||||
return 0;
|
||||
}
|
||||
case stateFinal:
|
||||
printf("stateFinal und action! kann doch garnicht sein ;)\n");
|
||||
default:
|
||||
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:
|
||||
eDVBCIDateTimeSession(eDVBCISlot *tslot);
|
||||
~eDVBCIDateTimeSession();
|
||||
void sendDateTime();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user