python-sagemcom-api icon indicating copy to clipboard operation
python-sagemcom-api copied to clipboard

Request in/outcoming calls

Open blowk opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like Possible to see when there are in/outcoming calls.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

[enhancement]

blowk avatar Jun 08 '24 12:06 blowk

@blowk what kind of calls? Are you able to see these details via the official router interface? Can you capture the XHR request?

iMicknl avatar Jun 08 '24 18:06 iMicknl

When you access the router and click 'phone' (192.168.1.1/modals/device-phone-global.lp?ip=&mydevMac=Phone1&mydevIP=). You get all in/outcomming calls.

blowk avatar Jun 10 '24 18:06 blowk

@blowk are you able to capture the XHR request via your browser? What is the exact request and response.

iMicknl avatar Jun 10 '24 18:06 iMicknl

I'm not familiar with XHR. Could you help how to extract XHR request? request url: http://192.168.1.1/modals/device-phone-global.lp?ip=&mydevMac=Phone1&mydevIP= response:

<script type="text/javascript">
function getDuration(endTime, connectTime){
  var reggie = /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/;
  var dateArray = reggie.exec(connectTime);
  var dateObject = new Date(
    (+dateArray[1]),
    (+dateArray[2])-1,
    (+dateArray[3]),
    (+dateArray[4]),
    (+dateArray[5]),
    (+dateArray[6])
  );
  var reggie1 = /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/;
  var dateArray1 = reggie1.exec(endTime);
  var dateObject1 = new Date(
    (+dateArray1[1]),
    (+dateArray1[2])-1,
    (+dateArray1[3]),
    (+dateArray1[4]),
    (+dateArray1[5]),
    (+dateArray1[6])
  );
  var timeStart = new Date(dateObject).getTime();
  var timeEnd = new Date(dateObject1).getTime();
  var hourDiff = timeEnd - timeStart;
  var hDiff = Math.floor(hourDiff /( 3600 * 1000 )); //in hours
  hourDiff = Math.floor(hourDiff % (3600 *1000));
  var minDiff = Math.floor(hourDiff / 60000); //in minutes
  hourDiff = Math.floor(hourDiff % 60000);
  var secDiff = Math.floor(hourDiff / 1000); //in seconds
  if(hDiff > 0 || minDiff > 0 || secDiff > 0){
    if(hDiff < 10) {hDiff = "0" + hDiff;}
    if(minDiff < 10) {minDiff = "0" + minDiff;}
    if(secDiff < 10) {secDiff = "0" + secDiff;}
    return (hDiff) + ":" + (minDiff) + ":" +(secDiff);
  }else{
    return "--";
  }
}

    var duration = "--";
    
    var start_Time = "";
    
       start_Time = "2024-06-10 17:55:02";
    
    $('#call-history').append('<tr><td>0456123456</td><td><span class="badge badge-success"> Incoming</span></td><td>'+start_Time+'</td><td>'+duration+'</td></tr>');
....

blowk avatar Jun 10 '24 19:06 blowk

See https://www.youtube.com/watch?v=oeSNa1cHB3o for more information on how to debug an XHR request. You should see an request to /cgi/json-req, this is the API that we based this integration on.

iMicknl avatar Aug 09 '24 19:08 iMicknl

Sorry for my late reply and tthank you for the information. I didn't get the request through /cgi/json-req.

The modem is a bbox3. Isn't it based on Sagem?

If I fetch I get

fetch("http://192.168.1.1/devices.lp", { "headers": { "accept": "*/*", "accept-language": "nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7", "x-requested-with": "XMLHttpRequest" }, "referrer": "http://192.168.1.1/", "referrerPolicy": "strict-origin-when-cross-origin", "body": null, "method": "GET", "mode": "cors", "credentials": "include" });

fetch("http://192.168.1.1/modals/device-phone-global.lp?ip=&mydevMac=Phone1&mydevIP=", { "headers": { "accept": "text/html, */*; q=0.01", "accept-language": "nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7", "x-requested-with": "XMLHttpRequest" }, "referrer": "http://192.168.1.1/", "referrerPolicy": "strict-origin-when-cross-origin", "body": null, "method": "GET", "mode": "cors", "credentials": "include" });

If it isn't possible, no problem. I will look to fetch the data from 192.168.1.1/modals/device-phone-global.lp?ip=&mydevMac=Phone1&mydevIP=

blowk avatar Aug 12 '24 08:08 blowk

These API endpoints aren't based on the same API that this package supports unfortunately.. You should be able to write code to extract the details via these endpoints, but this will be out of scope for this package.

iMicknl avatar Aug 12 '24 09:08 iMicknl