mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 15:02:43 +02:00
test c**
Origin commit data
------------------
Branch: master
Commit: 0bbcfaf171
Author: max_10 <max_10@gmx.de>
Date: 2015-11-10 (Tue, 10 Nov 2015)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
/* DVB CI DateTime Manager */
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "dvbci_datetimemgr.h"
|
||||
|
||||
static const char * FILENAME = "[dvbci_datetimemgr]";
|
||||
|
||||
eDVBCIDateTimeSession::eDVBCIDateTimeSession(tSlot *tslot)
|
||||
{
|
||||
slot = tslot;
|
||||
@@ -46,8 +51,30 @@ int eDVBCIDateTimeSession::doAction()
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user