Timer API Usage

This document describes new usages of Samsung Product Timer API for Tizen 6.5 and higher, and differences with SSSP B2BControl API.


Related Info


Generals

  • Privilege: http://developer.samsung.com/privilege/devicetimer
  • Privilege level: Partner

API Usages

webapis.timer.getVersion

This interface provides methods to get timer module version.

  • SSSP API sample code:

    var Version = null; 
    
    try {
      Version = b2bapis.b2bcontrol.getVersion(); 
    } catch (e) {
      console.log("[getVersion] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    if (null !== Version) {
      console.log("[getVersion] call syncFunction type: " + Version); 
    }
    
  • Samsung Product API sample code:

    var Version = null; 
    
    try {
      Version = webapis.timer.getVersion(); 
    } catch (e) {
      console.log("[getVersion] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    if (null !== Version) {
      console.log("[getVersion] call syncFunction type: " + Version); 
    }
    

webapis.timer.setCurrentTime

This interface provides a method to set the current time to device.

  • SSSP API sample code:

    var onSuccess = function(val) {
      console.log("[setCurrentTime] success : " + val ); 
      };
    var onError = function(error) {
      console.log("[setCurrentTime] code :" + error.code + " error name: " + error.name + " message " + error.message);
      };
    
    //2015->year; 12->month; 25->day; 15->hour; 56->minute; 4->second
    b2bapis.b2bcontrol.setCurrentTime("2015:12:25:15:56:40", onSuccess, onError);
    
  • Samsung Product API sample code:

    var current_time = {
      "year"     : 2022, 
      "month"    : 12, 
      "dayofweek": "MON", 
      "hour"     : 8,
      "minute"   : 55, "second"   : 43
      }; 
    
    try {
      webapis.timer.setCurrentTime(current_time); 
    } catch (e) {
      console.log("[setCurrentTime] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    

webapis.timer.getCurrentTime

This interface provides a method to get the current time.

  • SSSP API sample code:

    var CurrentTime = null; 
    
    try {
      CurrentTime = b2bapis.b2bcontrol.getCurrentTime(); 
    } catch (e) {
      console.log("[getCurrentTime] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    if (null !== CurrentTime) {
      console.log("[getCurrentTime] call syncFunction type: " + CurrentTime); 
    }
    
  • Samsung Product API sample code:

    var CurrentTime = null; 
    
    try {
      CurrentTime = webapis.timer.getCurrentTime(); 
    } catch (e) {
      console.log("[getCurrentTime] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    if (null !== CurrentTime) {
      console.log("[getCurrentTime] call syncFunction type: " + CurrentTime); 
    }
    

webapis.timer.setOnTimer

This interface provides a method to set the OnTimer of the device.

  • SSSP API sample code:

    var onSuccess = function(val) {
      console.log("[setOnTimer] success : " + val); 
      };
    var onError = function(error) {
      console.log("[setOnTimer] code :" + error.code + " error name: " + error.name + " message " + error.message);
      };
    
    b2bapis.b2bcontrol.setOnTimer("TIMER1","21:30", onSuccess, onError); 
    // or
    b2bapis.b2bcontrol.setOnTimerRepeat("TIMER2","19:50","TIMER_MANUAL","SUN:WED", onSuccess, onError);
    
  • Samsung Product API sample code:

    var timer_profile1 = {
      "timerID"     : "TIMER1", 
      "time"        : "19:50",
      "setup"       : "TIMER_ONCE", 
      "volume"      :  10
      };
    var timer_profile2 = {
      "timerID"     : "TIMER2",
      "time"        : "19:50",
      "setup"       : "TIMER_MANUAL", 
      "volume"      :  10,
      "manual"      : ["SUN", "WED"] 
      };
    
    try {
      webapis.timer.setOnTimer(timer_profile1); 
    } catch (e) {
      console.log("[setOnTimer] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    

webapis.timer.getOnTimer

This interface provides a method to get the value set in the specified OnTimer.

  • SSSP API sample code:

    var OnTimer = null; 
    
    try {
      OnTimer = b2bapis.b2bcontrol.getOnTimer("TIMER1"); 
      // or 
      OnTimer = b2bapis.b2bcontrol.getOnTimerRepeat("TIMER2"); 
    } catch (e) {
      console.log("[getOnTimer] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    if (null !== OnTimer) {
      console.log("[getOnTimer] call syncFunction type: " + OnTimer); 
    }
    
  • Samsung Product API sample code:

    var OnTimer = null; 
    
    try {
      OnTimer = webapis.timer.getOnTimer("TIMER1"); 
    } catch (e) {
      console.log("[getOnTimer] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    if (null !== OnTimer) {
      console.log("[getOnTimer] call syncFunction Timer : " + OnTimer); 
    }
    

webapis.timer.setOffTimer

This interface provides a method to set the OffTimer of the device.

  • SSSP API sample code:

    var onSuccess = function(val) {
      console.log("[setOffTimer] success : " + val); 
      };
    var onError = function(error) {
      console.log("[setOffTimer] code :" + error.code + " error name: " + error.name + " message " + error.message);
      };
    
    console.log("[setOffTimer] ");
    b2bapis.b2bcontrol.setOffTimer("TIMER1","21:30", onSuccess, onError); 
    // or
    b2bapis.b2bcontrol.setOffTimerRepeat("TIMER2","19:50","TIMER_MANUAL","SUN:WED", onSuccess, onError);
    
  • Samsung Product API sample code:

    var timer_profile = {
      "timerID"     : "TIMER1", 
      "time"        : "19:50",
      "setup"       : "TIMER_ONCE" 
      };
    var timer_profile2 = {
      "timerID"     : "TIMER2",
      "time"        : "19:50",
      "setup" : "TIMER_MANUAL", 
      "manual" : ["SUN", "WED"]
      }; 
    
    try {
      webapis.timer.setOffTimer(timer_profile); 
    } catch (e) {
      console.log("[setOffTimer] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    

webapis.timer.getOffTimer

This interface provides a method to get the value set in the specified
OffTimer.

  • SSSP API sample code:

    var OffTimer = null; 
    
    try {
      OffTimer = b2bapis.b2bcontrol.getOffTimer("TIMER1");
      // or 
      OffTimer = b2bapis.b2bcontrol.getOffTimerRepeat("TIMER2"); 
    } catch (e) {
      console.log("[getOffTimer] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    if (null !== OffTimer) {
      console.log("[getOffTimer] call syncFunction type: " + OffTimer); 
    }
    
  • Samsung Product API sample code:

    var OffTimer = null; 
    
    try {
      OffTimer = webapis.timer.getOffTimer("TIMER1"); 
    } catch (e) {
      console.log("[getOffTimer] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    if (null !== OnTimer) {
      console.log("[getOffTimer] call syncFunction Timer : " + OnTimer); 
    }
    

webapis.timer.addHoliday

This interface provides a method to add a holiday. It can be set for up to 15 days.

  • SSSP API sample code:

    var onSuccess = function(val) {
      console.log("[setHolidayList] success : " + val); 
      };
    var onError = function(error) {
      console.log("[setHolidayList] code :" + error.code + " error name: " + error.name + " message " + error.message);
      };
    
    b2bapis.b2bcontrol.setHolidayList("ADD","8","15","10","18",onSuccess, onError);
    
  • Samsung Product API sample code:

    var ADD_Holiday_profile = { 
      "startMonth" :  8, 
      "startDay"   :  15, 
      "endMonth"   :  10, 
      "endDay"    :  18
      }; 
    
    try {
      webapis.timer.addHoliday(ADD_Holiday_profile); 
    } catch (e) {
      console.log("[addHoliday] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    

webapis.timer.deleteHoliday

This interface provides a method to remove a holiday.

  • SSSP API sample code:

    var onSuccess = function(val) {
      console.log("[setHolidayList] success : " + val); 
      };
    var onError = function(error) {
      console.log("[setHolidayList] code :" + error.code + " error name: " + error.name + " message " + error.message);
      };
    
    b2bapis.b2bcontrol.setHolidayList("DELETE","8","15","10","18",onSuccess, onError);
    
  • Samsung Product API sample code:

    var DEL_Holiday_profile = { 
      "startMonth" :  8, 
      "startDay"   :  15, 
      "endMonth"   :  10, 
      "endDay"    :  18
      }; 
    
    try {
      webapis.timer.deleteHoliday(DEL_Holiday_profile); 
    } catch (e) {
      console.log("[deleteHoliday] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    

webapis.timer.applyTimerHoliday

This interface provides a method to apply a holiday to a Timer.

  • SSSP API sample code:

    var onSuccess = function(val) {
      console.log("[setHolidayToTimer] success : " + val); 
      };
    var onError = function(error) {
      console.log("[setHolidayToTimer] code :" + error.code + " error name: " + error.name + " message " + error.message);
      };
    
    b2bapis.b2bcontrol.setHolidayToTimer("OFF_TIMER", "TIMER1", "HOLIDAY_OFF", onSuccess, onError);
    
  • Samsung Product API sample code:

    var timer_profile = {
      "type" :  "OnTimer", 
      "timerID" :  "TIMER1", 
      "timerOnOff" :  "ON"
      }; 
    
    try {
      webapis.timer.applyTimerHoliday(timer_profile); 
    } catch (e) {
      console.log("[deleteHoliday] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    

webapis.timer.getTimerHoliday

This interface provides a method to get the list of holidays for a device.

  • SSSP API sample code:

    var HolidayList = null; 
    
    try {
      HolidayList = b2bapis.b2bcontrol.getHolidayList(); 
    } catch (e) {
      console.log("[getHolidayList] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    if (null !== HolidayList) {
      console.log("[getHolidayList] call syncFunction type: " + HolidayList);   
    }
    
  • Samsung Product API sample code:

    var Holiday = null;
    
    var timer_profile = {
      "type"     :  "OnTimer", 
      "timerID"  :  "TIMER1"
      }; 
    
    try {
      Holiday = webapis.timer.getTimerHoliday(timer_profile); 
    } catch (e) {
      console.log("[getHoliday] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    if (null !== Holiday) {
      console.log("[getHoliday] call syncFunction type: " + Holiday); 
    }
    

webapis.timer.setNTP

This interface provides a method to set the NTP info of the device.

  • SSSP API sample code:

    var onSuccess = function(val) {
      console.log("[setNTPServerAddress] success : " + val); 
      };
    var onError = function(error) {
      console.log("[setNTPServerAddress] code :" + error.code + " error name: " + error.name + " message " + error.message);
      };
    
    b2bapis.b2bcontrol.setNTPUse("USE", onSuccess, onError);
    b2bapis.b2bcontrol.setNTPServerAddress("pool.ntp.org", onSuccess, onError); 
    b2bapis.b2bcontrol.setCurrentTimeZone("Asia/Seoul", onSuccess, onError);
    
  • Samsung Product API sample code:

    var ntpinfo = {
      "use"       : "ON",
      "address"   : "pool.ntp.org", 
      "timezone"  : "Asia/Seoul"
      }; 
    
    try {
      webapis.timer.setNTP(ntpinfo); 
    } catch (e) {
      console.log("[setNTP] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    

webapis.timer.getNTP

This interface provides a method to get the NTP Use status of the device.

  • SSSP API sample code:

    var NTPUse = null;
    var NTPServerAddress = null;
    var TimeZone = null; 
    
    try {
      NTPUse = b2bapis.b2bcontrol.getNTPUse();
      NTPServerAddress = b2bapis.b2bcontrol.getNTPServerAddress();     
      TimeZone = b2bapis.b2bcontrol.getCurrentTimeZone();
    } catch (e) {
      console.log("[getNTPUse] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    console.log("[getNTPUse] call syncFunction type: " + NTPUse + " : " + NTPServerAddress + " : " + TimeZone);
    
  • Samsung Product API sample code:

    var ntpinfo= null; 
    
    try {
      ntpinfo = webapis.timer.getNTP(); 
    } catch (e) {
      console.log("[getNTP] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    console.log("[getNTP] call syncFunction type: " + ntpinfo);
    

webapis.timer.setDST

This interface provides a method to set the DST mode of the device.

  • SSSP API sample code:

  • Samsung Product API sample code:

    var DSTInfo = {
      "mode"    :  "ON",
      "start"   :  {
        "month"      :  10, 
        "week"       :  3, 
        "dayofweek" : "MON", "hour"       :  8, 
        "minute"     :  22 
        },
      "end"     : {
        "month"      :  11, 
        "week"       :  9, 
        "dayofweek" : "MON", 
        "hour"       :  13, 
        "minute"     :  58 
        },
      "offset":  "+1" 
      };
    
    try {
      webapis.timer.setDST(DSTInfo); 
    } catch (e) {
        console.log("[setDST] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    

webapis.timer.getDST

This interface provides a method to get the DST mode of the device.

  • SSSP API sample code:

  • Samsung Product API sample code:

    var DSTMode = null; 
    
    try {
      DSTMode = webapis.timer.getDST(); 
    } catch (e) {
      console.log("[getDST] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    if (null !== DSTMode) {
      console.log("[getDST] call syncFunction type: " + DSTMode); 
    }
    

webapis.timer.setSystemTimeSyncTimeout

This interface provides a method to set the time sync timeout for the device. If connection to the Samsung server cannot be made within the chose time period, the System/Kernel time is set to same as menu time.

  • SSSP API sample code:

  • Samsung Product API sample code:

    var timeout = "30SEC"; 
    
    try {
      webapis.timer.setSystemTimeSyncTimeout(timeout); 
    } catch (e) {
      console.log("[setSystemTimeSyncTimeout] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    

webapis.timer.getSystemTimeSyncTimeout

This interface provides a method to get the time sync timeout. If connection to the Samsung server cannot be made within the chose time period, the System/Kernel time is set to same as menu time.

  • SSSP API sample code:

  • Samsung Product API sample code:

    var TIMEOUT = null; 
    
    try {
      TIMEOUT = webapis.timer.getSystemTimeSyncTimeout(); 
    } catch (e) {
      console.log("[getSystemTimeSyncTimeout] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    if (null !== TIMEOUT) {
    console.log("[getSystemTimeSyncTimeout] call syncFunction type: " + TIMEOUT);
    }