---
title: ptp
slug: develop/ptp
docTags: 
createdAt: 2025-03-26T14:48:25.183Z
---

ptp allows you to retrieve information about the network PTP state of the player.

**ptp IDL**

```javascript
interface PtpEvent {
    attribute String type;
};

callback PtpEventCallback = void (PtpEvent event);

interface Ptp {
    Promise<PtpStatus> getStatus();
    void addEventListener(String type, PtpEventCallback callback);
    void removeEventListener(String type, PtpEventCallback callback);
};

interface PtpStatus {
    attribute long timestamp;
    attribute String state;
};                                                                                                           
```

## Object Creation

To create a *ptp* object, load the *@brightsign/ptp* module using the `require()` method. 

```javascript
var ptpclass = require('@brightsign/ptp');
var ptp = new ptpclass();                                                                                 
```

## Ptp

**getStatus()&#x20;**

```javascript
Promise<PtpStatus> getStatus()                                                                                             
```

Gets the status of a PTP network for a player.

## PtpEvent

This event object is generated by the *roPtp* object whenever the PTP status of the player changes.

- `type` <font color="#6554c0">string</font>: The name of the event ( which will always be PtpEvent).

## PtpStatus

- `timestamp`<font color="#6554c0"> long</font>:  The number of seconds since the PTP state was last changed. This value can be compared against the total uptime of the player, which is retrieved by calling `UpTime(0)`.
- `state` <font color="#6554c0">string</font>: Indicates the current PTP state of the player.  Values can be Master, Slave, or Uncalibrated.

## Example

```javascript
// code placeholder
var ptpclass = require('@brightsign/ptp');  
var ptp = new ptpclass();
function main() {    
    console.log("Starting PTP javascript API...");    
    // ptp status test    
    // Two examples of result from getStatus() for Master & Slave player    
    // {"state":"MASTER","timestamp":20}     
    // {"state":"SLAVE","timestamp":24}     
    var status = ptp.getStatus();    
    status.then( function(result) {              
       console.log(JSON.stringify(result)); })    
     .catch( function(err){     
       console.log(JSON.stringify(err)); 
    });

    // add event test 
    if(ptp.addEventListener){ 
       console.log("adding test event"); 
       ptp.addEventListener("ptpevent", EventHandler);     
    }
    // remove event test    
    // set 5 sec timeout for the purpose of testing removeEventListener     
    setTimeout(function (){      
       console.log("removing test event");        
       ptp.removeEventListener("ptpevent", EventHandler) }, 5000);
}
function EventHandler(event){   
    console.log(JSON.stringify(event));  
}                                                                                      
```

As of BrightSignOS 8.3.20, to get the current data set: 

```javascript
var ptpclass = require('@brightsign/ptp');
 var ptp = new ptpclass();
var ds = ptp.getCurrentDataSet();
ds
 .then( function(result) {
   console.log(JSON.stringify(result));
 })
 .catch( function(err){
   console.log(JSON.stringify(err)); }
 );

```

This will return a promise that, when successful, resolves to type: 

```javascript
type CurrentDataSet
{
 stepsRemoved: number;
 offsetFromMaster: number;
 meanPathDelay: number;
}
```

