dear all …
I just start playing with tr-069 and genieacs.
I use GitHub - genieacs/genieacs-sim: TR-069 client simulator for GenieACS to make first test.
I start it and got
bino@corobalap ~/Documents/aku/genieacs-sim master ./genieacs-sim -u http://192.168.56.102:7547
Simulator 000000 started
Simulator 000000 listening for connection requests on http://192.168.56.1:53345/
When I open 192.168.56.102:3000/#!/devices/202BC1-BM632w-000000
I got
actualy, I plan to integrate this Genieacs to my application that take care of Radius.
so I read Passing Arguments to an external script
my ext script looks like:
const API_URL = process.env.API_URL || 'http://192.168.56.1:8080';
const url = require("url");
const http = require(API_URL.split(":", 1)[0]);
function resetPppoe(args, callback) {
console.log('args');
let params = JSON.parse(args[0]);
const uri = API_URL + "/ResetPPPoECreds?serial=" + params.serial + '&productClass=' + params.productClass + '&oui=' + params.oui;
console.log({ uri: uri, serial: params.serial });
let options = url.parse(uri);
options.headers = {
accept: 'application/json',
"content-type": 'application/json'
};
let request = http.get(options, function (response) {
if (response.statusCode == 404) {
return callback(null, null);
}
if (response.statusCode >= 400) {
return callback(new Error("Unexpected error resetting PPPoE credentials. Response Code: " +
response.statusCode + '. Status Message: ' + response.statusMessage + '. t: ' + typeof response.statusCode));
}
let data = "";
response.on("data", function (d) {
data = data + d.toString();
});
response.on("end", function () {
let result = JSON.parse(data);
console.log('Returning credentials to client', result);
return callback(null, result);
});
});
request.on("error", function (err) {
console.log(arguments);
callback(err);
});
}
exports.resetPppoe = resetPppoe;
My provision looks like
const serial = declare('DeviceID.SerialNumber', {value: 1}).value[0];
const productClass = declare('DeviceID.ProductClass', {value: 1}).value[0];
const oui = declare('DeviceID.OUI', {value: 1}).value[0];
const deviceId = declare('DeviceID.ID', {value: 1}).value[0];
const params = {serial, productClass, oui, deviceId};
let config = ext('resetpppoe', 'resetPppoe', JSON.stringify(params));
log(JSON.stringify(config));
my preset :
name : bino_boot_01
channel : bootstrap
weight: 0
Events: 0 BOOTSTRAP
provision: bino01
a simple python http server that will receive request from genieacs like:
from http.server import BaseHTTPRequestHandler, HTTPServer
import time
hostName = "192.168.56.1"
serverPort = 8080
class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
print(f'path:{self.path}')
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write(bytes("<html><head><title>https://pythonbasics.org</title></head>", "utf-8"))
self.wfile.write(bytes("<p>Request: %s</p>" % self.path, "utf-8"))
self.wfile.write(bytes("<body>", "utf-8"))
self.wfile.write(bytes("<p>This is an example web server.</p>", "utf-8"))
self.wfile.write(bytes("</body></html>", "utf-8"))
if __name__ == "__main__":
webServer = HTTPServer((hostName, serverPort), MyServer)
print("Server started http://%s:%s" % (hostName, serverPort))
try:
webServer.serve_forever()
except KeyboardInterrupt:
pass
webServer.server_close()
print("Server stopped.")
That http server run from my terminal
I restart that GenieAcs-Simulator, but my python http server did not receive any request
Kindly please tell me what todo to fix this problem