Example #1
0
void notify_timeout_cb(guint time)
{
    time_t t = state_active_get_time_remain();

    if (t < g_config.notify_time && t > 0)
    {
        if(!s_notified)
        {
            static gchar time_str[PATH_MAX];
            struct tm* tm = localtime(&t);
            if(tm == NULL)
            {
                g_snprintf(time_str, sizeof(time_str), "%lu", (unsigned long)t);
            }
            else
            {
                strftime(time_str, sizeof(time_str), g_config.notify_format, tm);
            }

            notify_send(time_str, t);
        }
    }
    else
    {
        s_notified = FALSE;
        notify_close();
    }
}
Example #2
0
static int ln__gc(lua_State *L) {
	struct luanotify *N = luaL_checkudata(L, 1, CQS_NOTIFY);

	notify_close(N->notify);
	N->notify = 0;

	return 0;
} /* ln__gc() */
Example #3
0
void t4()
{
   int h, e, f, n, s, b, l, seq_ok, toggle_ok;
   gpioReport_t r;
   char p[32];

   printf("Pipe notification tests.\n");

   set_PWM_frequency(GPIO, 0);
   set_PWM_dutycycle(GPIO, 0);
   set_PWM_range(GPIO, 100);

   h = notify_open();
   e = notify_begin(h, (1<<4));
   CHECK(4, 1, e, 0, 0, "notify open/begin");

   time_sleep(1);

   sprintf(p, "/dev/pigpio%d", h);

   f = open(p, O_RDONLY);

   set_PWM_dutycycle(GPIO, 50);
   time_sleep(4);
   set_PWM_dutycycle(GPIO, 0);

   e = notify_pause(h);
   CHECK(4, 2, e, 0, 0, "notify pause");

   e = notify_close(h);
   CHECK(4, 3, e, 0, 0, "notify close");

   n = 0;
   s = 0;
   l = 0;
   seq_ok = 1;
   toggle_ok = 1;

   while (1)
   {
      b = read(f, &r, 12);
      if (b == 12)
      {
         if (s != r.seqno) seq_ok = 0;

         if (n) if (l != (r.level&(1<<4))) toggle_ok = 0;

         if (r.level&(1<<4)) l = 0;
         else                l = (1<<4);
           
         s++;
         n++;

         // printf("%d %d %d %X\n", r.seqno, r.flags, r.tick, r.level);
      }
      else break;
   }
   close(f);
 
   CHECK(4, 4, seq_ok, 1, 0, "sequence numbers ok");

   CHECK(4, 5, toggle_ok, 1, 0, "gpio toggled ok");

   CHECK(4, 6, n, 80, 10, "number of notifications");
}