linuxÏÂcÓïÑԹػú³ÌÐò
/* Offtimer.c.For auto halt. */
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
#define DELAY 60/* Time of sleeping */
int main()
{
time_t now;
struct tm *p;
while(1)
{
now = time(NULL);
sleep(DELAY);/* To reduce cpu occupation */
p = localtime(&now);
if ((p->tm_hour = 14) && (p->tm_min >= 30))/ *This means the system will halt after 14:30 or 14:31 */
system("poweroff"); / *'poweroff' is the command in Red Flag Linux
Desktop 5.0 to turn off the computer.To do this you should be root. */
}
return 0;
}
ÒýÓÃgcc±àÒ룬ÁíÍâÐèÒªÓÐrootÓû§µÄȨÀû²ÅÄÜÐС£
Ïà¹ØÎĵµ£º
Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖÐÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀÐÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......
1.ÔÚc³ÌÐòµ÷ÓÃc³ÌÐòºÍc++³ÌÐòµ÷ÓÃc++³ÌÐòʱ£¬²»Éæ¼°¡£
2.ÔÚc³ÌÐòµ÷ÓÃc++³ÌÐòʱ£¬C++µÄÍ·ÎļþÐèÌí¼Óextern "C"£¬µ«ÊÇÔÚCÓïÑÔÖв»ÄÜÖ±½ÓÒýÓÃÉùÃ÷ÁËextern "C"µÄ¸ÃÍ·Îļþ£¬Ó¦¸Ã½ö½«CÎļþÖн«C++Öж¨ÒåµÄextern "C"º¯ÊýÉùÃ÷ΪexternÀàÐÍ¡£
3.ÔÚc++³ÌÐòµ÷ÓÃc³ÌÐòʱ£¬ÔÚ°üº¬CÓïÑÔÍ·Îļþ£¨¼ÙÉèΪcExample.h£©Ê±£¬Ðè½øÐÐÏÂÁд¦Àí£ ......
±àÒ룬±àÒë³ÌÐò¶ÁȡԴ³ÌÐò£¨×Ö·ûÁ÷£©£¬¶ÔÖ®½øÐдʷ¨ºÍÓï·¨µÄ·ÖÎö£¬½«¸ß¼¶ÓïÑÔÖ¸Áîת»»Îª¹¦ÄܵÈЧµÄ»ã±à´úÂ룬ÔÙÓÉ»ã±à³ÌÐòת»»Îª»úÆ÷ÓïÑÔ£¬²¢ÇÒ°´ÕÕ²Ù×÷ϵͳ¶Ô¿ÉÖ´ÐÐÎļþ¸ñʽµÄÒªÇóÁ´½ÓÉú³É¿ÉÖ´ÐгÌÐò¡£
CÔ´³ÌÐòÍ·Îļþ££>Ô¤±àÒë´¦Àí(cpp)££>±àÒë³ÌÐò±¾Éí££>ÓÅ»¯³ÌÐò££>»ã±à³ÌÐò££>Á´½Ó³ÌÐò--> ......