# Using TR-069 standard cpe methods

**URL:** <https://forum.genieacs.com/t/using-tr-069-standard-cpe-methods/6487>\
**Category:** Uncategorized\
**Created:** [February 7, 2025, 11:42am UTC](https://forum.genieacs.com/t/using-tr-069-standard-cpe-methods/6487 "2025-02-07T11:42:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![KamithaVihanga](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/kamithavihanga/32/1640_2.png) [@KamithaVihanga](https://forum.genieacs.com/u/KamithaVihanga)\
**Post date:** [February 7, 2025, 11:42am UTC](https://forum.genieacs.com/t/using-tr-069-standard-cpe-methods/6487/1 "2025-02-07T11:42:09Z")

</div>

Hi GenieACS Community,

I am currently migrating from **LibreACS** to **GenieACS** and need guidance on adapting my existing LibreACS provisioning scripts to GenieACS. My current script handles various TR-069 methods like `GetParameterValues`, `SetParameterValues`, `Reboot`, `Download`, etc., and includes logic for handling events like `BOOTSTRAP`, `BOOT`, and `PERIODIC`.

Here’s a summary of my requirements:

1. **Event Handling** : In LibreACS, I use events like `BOOTSTRAP`, `BOOT`, and `PERIODIC` to trigger specific actions. How can I replicate this event-driven logic in GenieACS?
2. **Database Queries** : My script queries a database to fetch configuration data (e.g., WiFi settings, firmware URLs). Since GenieACS doesn’t support direct database queries in scripts, what’s the recommended approach?
3. **Task Scheduling** : I need to schedule tasks like `SetParameterValues`, `Reboot`, and `Download` based on conditions. How can I use `declare('task', {...})` effectively for this purpose?
4. **Firmware Upgrades** : My script initiates firmware upgrades using the `Download` method. How can I implement this in GenieACS?

I would appreciate any guidance or examples on how to:

- Translate event-driven logic into GenieACS scripts.
- Replace database queries with GenieACS features like tags or presets.
- Schedule and manage tasks like `SetParameterValues`, `Reboot`, and `Download`.

Thank you in advance for your support!

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [February 7, 2025, 6:34pm UTC](https://forum.genieacs.com/t/using-tr-069-standard-cpe-methods/6487/2 "2025-02-07T18:34:26Z")

</div>

1. Event logic should be the same.
2. Instead of direct DB queries inside of LibreACS, you would call an [extension](https://docs.genieacs.com/en/latest/extensions.html) script to do the data acquisition.
3. Use a preset with a cron schedule expression
4. Same way

---

<div class="post-metadata">

**Author:** ![KamithaVihanga](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/kamithavihanga/32/1640_2.png) [@KamithaVihanga](https://forum.genieacs.com/u/KamithaVihanga)\
**Post date:** [February 9, 2025, 5:34am UTC](https://forum.genieacs.com/t/using-tr-069-standard-cpe-methods/6487/3 "2025-02-09T05:34:49Z")

</div>

Thanks for your quick response. Please refer to the sample code from my existing script. What do you recommend for use? only the declare function? Apart from that, I have also used the AddObject and DeleteObject functions

```auto

if (sModel == "ZLT P11") {
	var PCILock = '';
	sig[0] = 'InternetGatewayDevice.WANDevice.1.X_CMCC_WANNetConfigInfo.RSSI';
	sig[1] = 'InternetGatewayDevice.WANDevice.1.X_CMCC_WANNetConfigInfo.RSRQ';
	sig[2] = 'InternetGatewayDevice.WANDevice.1.X_CMCC_WANNetConfigInfo.SignalQuality';
	sig[3] = 'InternetGatewayDevice.WANDevice.1.X_CMCC_WANNetConfigInfo.RSRP';
	sig[4] = 'InternetGatewayDevice.WANDevice.1.X_CMCC_WANNetConfigInfo.PCILock';
	sig[5] = 'InternetGatewayDevice.DeviceInfo.IMEI';
	try {
		r = cpe.GetParameterValues(sig);
		for (k = 0; k < r.length; k++) {
			if (r[k].name == 'InternetGatewayDevice.WANDevice.1.X_CMCC_WANNetConfigInfo.RSSI') rssi = r[k].value + 'dBm';
			if (r[k].name == 'InternetGatewayDevice.WANDevice.1.X_CMCC_WANNetConfigInfo.RSRQ') rsrq = r[k].value + 'dB';
			if (r[k].name == 'InternetGatewayDevice.WANDevice.1.X_CMCC_WANNetConfigInfo.RSRP') rsrp = r[k].value + 'dBm';
			if (r[k].name == 'InternetGatewayDevice.WANDevice.1.X_CMCC_WANNetConfigInfo.SignalQuality') sq = r[k].value;
			if (r[k].name == 'InternetGatewayDevice.DeviceInfo.IMEI') imei = r[k].value;
			if (r[k].name == 'InternetGatewayDevice.WANDevice.1.X_CMCC_WANNetConfigInfo.PCILock') PCILock = r[k].value;
		}
	}
	catch (er12) {
		logger(sn + " Model: " + sModel + " >>> Capturing signaling parameters failed");
	}
	logger(sn + " >>> P11 cell lock status : " + PCILock);
	try {
		db.Update("java:ACS", "INSERT INTO CellLockStatus (serialno,status) values ('" + sn + "','" + PCILock + "') ON DUPLICATE KEY UPDATE status='" + PCILock + "'");
	} catch (er4) {
		logger(sn + " >>> Cell Lock status update to database failed");
	}
} else if (sModel == "B312-926") {
	logger(sn + " >>> Capturing signaling parameters of model: " + sModel);
	sig[0] = 'InternetGatewayDevice.WANDevice.2.X_ATP_WANUMTSInterfaceConfig.RSSI';
	sig[1] = 'InternetGatewayDevice.WANDevice.2.X_ATP_WANUMTSInterfaceConfig.RSRQ';
	sig[2] = 'InternetGatewayDevice.WANDevice.2.X_ATP_WANUMTSInterfaceConfig.SignalQuality';
	sig[3] = 'InternetGatewayDevice.WANDevice.2.X_ATP_WANUMTSInterfaceConfig.RSRP';
	sig[4] = 'InternetGatewayDevice.WANDevice.2.X_ATP_WANUMTSInterfaceConfig.X_ATP_lmt_signal.cqi0';
	try {
		r = cpe.GetParameterValues(sig);
		for (k = 0; k < r.length; k++) {
			if (r[k].name == 'InternetGatewayDevice.WANDevice.2.X_ATP_WANUMTSInterfaceConfig.RSSI') rssi = r[k].value;
			if (r[k].name == 'InternetGatewayDevice.WANDevice.2.X_ATP_WANUMTSInterfaceConfig.RSRQ') rsrq = r[k].value;
			if (r[k].name == 'InternetGatewayDevice.WANDevice.2.X_ATP_WANUMTSInterfaceConfig.RSRP') rsrp = r[k].value;
			if (r[k].name == 'InternetGatewayDevice.WANDevice.2.X_ATP_WANUMTSInterfaceConfig.SignalQuality') sq = r[k].value;
			if (r[k].name == 'InternetGatewayDevice.WANDevice.2.X_ATP_WANUMTSInterfaceConfig.X_ATP_lmt_signal.cqi0') cqi = r[k].value;
		}
	}
	catch (er12) {
		logger(sn + " Model: " + sModel + " >>> Capturing signaling parameters failed");
	}
	try {
		var para6 = new Array();
		para6[0] = { name: 'InternetGatewayDevice.ManagementServer.PeriodicInformInterval', value: '43200', type: 'xsd:unsignedInt' };
		logger(sn + " Model: " + sModel + " >>> Trying to change periodic interval");
		cpe.SetParameterValues(para6, sCommandKey);
	}
	catch (er13) {
		logger(sn + " >>> Changing periodic interval failed");
	}
}	

```

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [February 10, 2025, 6:07pm UTC](https://forum.genieacs.com/t/using-tr-069-standard-cpe-methods/6487/4 "2025-02-10T18:07:47Z")

</div>

With provision scripts, you do you instances differently. Here is a piece of code to add port forward entries, but you get the idea of how it works:

```javascript
let keys = [
    'InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.PortMapping',
    'Device.NAT.PortMapping'
];

for (let basePath of keys) {
    // Tell GenieACS to remove any existing port mappings.
    // No work will actually be done at this stage.
    declare(basePath + '.[]', null, {path: 0});

    // Each entry of portForwards is a JSON object. The keys/values are used to
    // build the path expression for GenieACS
    for (let forward of portForwards) {
        const path = basePath + '.[' + Object.keys(forward).map(key => key + ':' + forward[key]).join(',') + ']';

        log(`\r\n\r\nPortForwards - Updating - ${path}\r\n\r\n`, forward);

        // Declare to GenieACS what the desired state is
        declare(path, {path: 1}, {path: 1});
    }
}

// When this script finishes executing is when the actual work of determining the
// delta and sending the necessary AddObject/DeleteObject/SPV/etc commands to the CP

```

---

<div class="post-metadata">

**Author:** ![KamithaVihanga](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/kamithavihanga/32/1640_2.png) [@KamithaVihanga](https://forum.genieacs.com/u/KamithaVihanga)\
**Post date:** [February 11, 2025, 3:18pm UTC](https://forum.genieacs.com/t/using-tr-069-standard-cpe-methods/6487/5 "2025-02-11T15:18:56Z")

</div>

Thank you very much. Can you suggest some references to follow?

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [February 11, 2025, 5:22pm UTC](https://forum.genieacs.com/t/using-tr-069-standard-cpe-methods/6487/6 "2025-02-11T17:22:42Z")

</div>

[docs.genieacs.com](http://docs.genieacs.com)
