#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
static char *runStatusFile = "/syscfg/etc/runStatusFile";
//static char *runStatusFile = "runStatusFile";
FILE *pFile = NULL;
char runCountStr[10]={0};
unsigned runCountInt = 0;
char runTimeStr[15]={0};
unsigned runTimeInt = 0;
void doTask()
{
pFile = fopen(runStatusFile, "r+");
/*
if(NULL == pFile)
{
pFile = fopen(runStatusFile,"w+");
fseek (pFile, 0L, SEEK_SET);
fwrite("0", sizeof(char), 1, pFile);
fseek (pFile, 6L, SEEK_SET);
fwrite("0", sizeof(char), 1, pFile);
}
*/
fseek (pFile, 11L, SEEK_SET);
fread (runTimeStr, sizeof(char), 10, pFile);
runTimeInt = atoi(runTimeStr);
runTimeInt += 30;
fseek (pFile, 11L, SEEK_SET);
sprintf(runTimeStr,"%d",runTimeInt);
fwrite(runTimeStr, sizeof(char),10, pFile);
/*
fseek (pFile, 11L, SEEK_SET);
fread (runTimeStr, sizeof(char), 10, pFile);
printf("runTimeStr = %s\n",runTimeStr);
*/
fclose(pFile);
}
// ½¨Á¢ÐźŴ¦Àí»úÖÆ
void init_sigaction(void)
{
struct sigaction tact; /*Ðźŵ½ÁËÒªÖ´ÐеÄÈÎÎñ´¦Àíº¯ÊýΪdoTask*/
tact.sa_handler = doTask;
tact.sa_flags = 0; /*³õʼ»¯Ðźż¯*/
sigemptyset(&tact.sa_mask); /*½¨Á¢ÐźŴ¦Àí»úÖÆ*/
sigaction(SIGALRM, &tact, NULL);
}
void init_time()
{
struct itimerval value; /*É趨ִÐÐÈÎÎñµÄʱ¼ä¼ä¸ôΪ30Ãë0΢Ãë*/
value.it_value.tv_sec = 30;
value.it_value.tv_usec = 0; /*É趨³õʼʱ¼ä¼ÆÊýҲΪ30Ãë0΢Ãë*/
value.it_interval = value.it_value; /*ÉèÖüÆʱÆ÷ITIMER_REAL*/
setitimer(ITIMER_REAL, &value, NULL);
}
int main()
{
pFile = fopen(runStatusFile, "r+");
if(pFile == NULL)
{
Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖÐÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀÐÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......
Linux ϵͳ´¦ÓÚÕý³£×´Ì¬Ê±£¬·þÎñÆ÷Ö÷»ú¿ª»ú£¨»òÖØÐÂÆô¶¯£©ºó£¬Äܹ»ÓÉϵͳÒýµ¼Æ÷³ÌÐò×Ô¶¯Òýµ¼ Linux ϵͳÆô¶¯µ½¶àÓû§Ä£Ê½£¬²¢ÌṩÕý³£µÄÍøÂç·þÎñ¡£Èç¹ûϵͳ¹ÜÀíÔ±ÐèÒª½øÐÐϵͳά»¤»òϵͳ³öÏÖÆô¶¯Ò쳣ʱ£¬¾ÍÐèÒª½øÈëµ¥Óû§Ä£Ê½»òÐÞ¸´Ä£Ê½¶Ôϵͳ½øÐйÜÀíÁË¡£Ê¹Óõ¥Óû§Ä£Ê½ÓÐÒ»¸öÇ°Ìᣬ¾ÍÊÇÄúµÄϵͳÒýµ¼Æ÷£¨grub£©ÄÜÕý³£¹¤×÷£ ......