OpenVox Document Center OpenVox Document Center
  • Home 
  • Products 
  • Solutions 
  • Resources 
    • Document Center 
    • Datasheets 
    • Firmwares 
    • Videos 
  • Partners 
  • Blog 
  • Company 
OpenVox Document Center OpenVox Document Center
OpenVox Document Center
  • Home 
  • Products 
  • Solutions 
  • Resources 
    • Document Center 
    • Datasheets 
    • Firmwares 
    • Videos 
  • Partners 
  • Blog 
  • Company 

Wireless Gateway

  • folder icon closed folder iconUser Manual
    • SWG-2016/32 User Manual
    • VoxStack Series Wireless Gateway
    • SWG-3008/3016/32 User Manual
    • SWG-3016/32-4S User Manual
    • SWG-M20X User Manual
  • folder icon closed folder iconFunctions Guide
    • Interaction docking Guide
      • Wireless Gateway connects with 3CX
      • Wireless Gateway connects with asterisk16.15.1
      • Wireless Gateway FAQ connect with UC
      • Wireless Gateway connects with Freepbx15
      • Wireless Gateway connects with FreeSwitch1.10.5
  • folder icon closed folder iconApplication Notes
    • GSM Gateways APP Note
      • Expand Callback Function
      • APP Note_AMI
      • How to Bind the GSM Gateway Ports with PBX Sip Extension
      • OpenVox GSM Gateway HTTP Interface
      • How to Integrate the Analog Gateway and the GSM Gateway in One OpenVox Box
      • OpenVox GSM Gateway Function User Manual
      • Openvox HTTP SMS API Demo
      • OpenVox Wireless Gateway Connect with playSMS Manual
      • Remote Server Get CDR from GSM Gateway by AMI
      • VoxStack GSM Gateway API 1.0.0
      • VoxStack GSM Gateway Connect with iCallDrid Manual
      • VoxStack GSM Module Upgrading Guide
    • how to use smpp via diafaan ?
  • folder icon closed folder iconFAQ
    • Default IP and login information of various Gateways
    • SWG30XX-4S card position switching
  • folder icon closed folder iconfunction
    • Cloud Management – How to Connect to Cloud Management
    • Balance Inquiry – How to check the balance of your card on your device
    • Modify secondary dialing voice prompts
    • USSD API Sending – How to send USSD via API
    • Secondary Dialing – How to set up secondary dialing for outbound routing
    • Card switching strategy – how to make the sim card switch according to your expectations
    • Number lookup – How to look up the number of the card on the device and display it
    • Inbound routing, outbound routing
    • Call Forwarding – How to set up call forwarding
    • Call Waiting – How to set up call waiting
    • How to upgrade the system of the gateway
    • How to translate the language of a web page into the language you want
    • How to upload and download gateway configurations
    • How to restore factory settings via web or RST button
    • Turn on call logging and AT logging – How to turn on call logging and AT logging
    • Module Upgrade – How to Upgrade Module System
    • SMS API Delivery – How to send SMS through API and set up SMS server to receive it
    • SMS Restrictions – How to set SMS restrictions
    • Gateway connection vpn – if connecting to vpn
loading
Popular Searches
  • VoIP
  • Gateway
  • IPPBX
  1. Home
  2. Docs
  3. Wireless Gateway
  4. Application Notes
  5. GSM Gateways APP Note
  6. Remote Server Get CDR from GSM Gateway by AMI
Updated on March 29, 2022

Wireless Gateway

  • folder icon closed folder iconUser Manual
    • SWG-2016/32 User Manual
    • VoxStack Series Wireless Gateway
    • SWG-3008/3016/32 User Manual
    • SWG-3016/32-4S User Manual
    • SWG-M20X User Manual
  • folder icon closed folder iconFunctions Guide
    • Interaction docking Guide
      • Wireless Gateway connects with 3CX
      • Wireless Gateway connects with asterisk16.15.1
      • Wireless Gateway FAQ connect with UC
      • Wireless Gateway connects with Freepbx15
      • Wireless Gateway connects with FreeSwitch1.10.5
  • folder icon closed folder iconApplication Notes
    • GSM Gateways APP Note
      • Expand Callback Function
      • APP Note_AMI
      • How to Bind the GSM Gateway Ports with PBX Sip Extension
      • OpenVox GSM Gateway HTTP Interface
      • How to Integrate the Analog Gateway and the GSM Gateway in One OpenVox Box
      • OpenVox GSM Gateway Function User Manual
      • Openvox HTTP SMS API Demo
      • OpenVox Wireless Gateway Connect with playSMS Manual
      • Remote Server Get CDR from GSM Gateway by AMI
      • VoxStack GSM Gateway API 1.0.0
      • VoxStack GSM Gateway Connect with iCallDrid Manual
      • VoxStack GSM Module Upgrading Guide
    • how to use smpp via diafaan ?
  • folder icon closed folder iconFAQ
    • Default IP and login information of various Gateways
    • SWG30XX-4S card position switching
  • folder icon closed folder iconfunction
    • Cloud Management – How to Connect to Cloud Management
    • Balance Inquiry – How to check the balance of your card on your device
    • Modify secondary dialing voice prompts
    • USSD API Sending – How to send USSD via API
    • Secondary Dialing – How to set up secondary dialing for outbound routing
    • Card switching strategy – how to make the sim card switch according to your expectations
    • Number lookup – How to look up the number of the card on the device and display it
    • Inbound routing, outbound routing
    • Call Forwarding – How to set up call forwarding
    • Call Waiting – How to set up call waiting
    • How to upgrade the system of the gateway
    • How to translate the language of a web page into the language you want
    • How to upload and download gateway configurations
    • How to restore factory settings via web or RST button
    • Turn on call logging and AT logging – How to turn on call logging and AT logging
    • Module Upgrade – How to Upgrade Module System
    • SMS API Delivery – How to send SMS through API and set up SMS server to receive it
    • SMS Restrictions – How to set SMS restrictions
    • Gateway connection vpn – if connecting to vpn

Remote Server Get CDR from GSM Gateway by AMI

Estimated reading: 4 minutes 68 views

Introduction:

OpenVox GSM Gateway can support AMI(Asterisk Manager Interface,if you want to get the CDR from remote server,you can use the AMI to do it!

 

Step 1:

Set the AMI in OpenVox GSM Gateway,follows:

word image 1030 word image 1032

 

Step 2:Write a Program to get the CDR like follows:

#include<stdio.h>

#include<string.h>

#include<stdlib.h>

#include<sys/socket.h>

#include<netinet/in.h>

#include<unistd.h>

//Login

void login_fun(int sock_fd)

{

char username[20];

char secret[20];

int login_len=0;

int secret_len=0;

int res = 0;

char receive_buf[4096];

char login_buf[40];

memset(username,’\0′,20);

memset(secret,’\0′,20);

printf(“please input your username\n”);

scanf(“%s”,username);

fflush(stdin);

printf(“please input your secret\n”);

scanf(“%s”,secret);

fflush(stdin);

memset(login_buf,’\0′,40);

sprintf(login_buf,”action:Login\r\nusername:%s\r\nsecret:%s\r\n\r\n”,username,secret);

login_len = strlen(login_buf);

if(res = write(sock_fd,login_buf,login_len) == login_len)

{

sleep(1);

memset(receive_buf,’\0′,4096);

if(res = read(sock_fd,receive_buf,sizeof(receive_buf))<0)

{

perror(“login failed\n”);

return;

}

printf(“%s\n”,receive_buf);

if(NULL != strstr(receive_buf,”Authentication accepted”))

{

printf(“login success\n”);

}

}

}

void read_cdr(int sock_fd)

{

char receive_buf[4096];

int res=0;

char *receive_Data;

char temp_buf[1024];

char *temp = NULL;

struct CDR

{

char CallerID[512];

char CalleeID[512];

char From[512];

char To[512];

char StartTime[512];

char Duration[512];

char Result[512];

};

struct CDR cdr_buff;

int i =0;

int j =0;

while(1)

{

memset(receive_buf,’\0′,4096);

memset(cdr_buff.CallerID,’\0′,512);

memset(cdr_buff.CalleeID,’\0′,512);

memset(cdr_buff.From,’\0′,512);

memset(cdr_buff.To,’\0′,512);

memset(cdr_buff.StartTime,’\0′,512);

memset(cdr_buff.Duration,’\0′,512);

memset(cdr_buff.Result,’\0′,512);

 

if(res = read(sock_fd,receive_buf,sizeof(receive_buf))<0)

{

perror(“read failed\n”);

}

else

{

//memset(receive_buf,’\0′,4096);

if((receive_Data = strstr(receive_buf,”Application: WriteCDR”))!=NULL)

{

 

//printf(“111111111111111111111111111111111111111111111%s\n”,receive_Data);

i=0;

j=0;

if((temp=strstr(receive_Data,”AppData:”))!=NULL)

{

for(i=0;i<strlen(temp);i++)

{

if(temp[i]!=’:’)

{

j++;

}

else

{

break;

}

}

temp=temp+j+2;

for(i=0;i<strlen(temp);i++)

{

if(temp[i]!=’,’)

{

cdr_buff.CallerID[i]=temp[i];

}

else

{

break;

}

}

temp=temp+i+1;

for(i=0;i<strlen(temp);i++)

{

if(temp[i]!=’,’)

{

cdr_buff.CalleeID[i]=temp[i];

}

else

{

break;

}

}

temp=temp+i+1;

for(i=0;i<strlen(temp);i++)

{

if(temp[i]!=’,’)

{

cdr_buff.From[i]=temp[i];

}

else

{

break;

}

}

temp=temp+i+1;

for(i=0;i<strlen(temp);i++)

{

if(temp[i]!=’,’)

{

cdr_buff.To[i]=temp[i];

}

else

{

break;

}

}

temp=temp+i+1;

for(i=0;i<strlen(temp);i++)

{

if(temp[i]!=’,’)

{

cdr_buff.StartTime[i]=temp[i];

}

else

{

break;

}

}

temp=temp+i+1;

for(i=0;i<strlen(temp);i++)

{

if(temp[i]!=’,’)

{

cdr_buff.Duration[i]=temp[i];

}

else

{

break;

}

}

temp=temp+i+1;

for(i=0;i<strlen(temp);i++)

{

if(temp[i]!=’\n’)

{

cdr_buff.Result[i]=temp[i];

}

else

{

break;

}

}

printf(“Callerid==============%s\n”,cdr_buff.CallerID);

printf(“Calleeid==============%s\n”,cdr_buff.CalleeID);

printf(“From==============%s\n”,cdr_buff.From);

printf(“To==============%s\n”,cdr_buff.To);

printf(“StartTime==============%s\n”,cdr_buff.StartTime);

printf(“Duration==============%s\n”,cdr_buff.Duration);

printf(“Result==============%s\n”,cdr_buff.Result);

// break;

}

}

}

}

}

int main(void)

{

int client_socket;

struct sockaddr_in client_addr;

char ServerIp[20];

memset(ServerIp,’\0′,20);

printf(“Please input your server ip address\n”);

scanf(“%s”,ServerIp);

fflush(stdin);

client_socket = socket(AF_INET,SOCK_STREAM,0);

if(client_socket < 0)

{

perror(“create socket error\n”);

return -1;

}

client_addr.sin_family = AF_INET;

client_addr.sin_port = htons(5038);

client_addr.sin_addr.s_addr = inet_addr(ServerIp);

//connect

if(connect(client_socket,(struct sockaddr *)&client_addr,sizeof(client_addr))<0)

{

perror(“connect error\n”);

return -1;

}

else

{

printf(“connect to %s success\n”,ServerIp);

}

login_fun(client_socket);

read_cdr(client_socket);

return 0;

}

 

Step 3:compile and run the app

word image 1034 word image 1036

Notice: This just a test program,just use for refer it!

Thanks!

 

 

 

 

 

Still stuck? How can we help?

Was this page helpful? Yes No

How can we help?

A premium WordPress theme with integrated Knowledge Base,
providing 24/7 community based support.

Leave a Comment Cancel reply

CONTENTS

Copyright © 2002-2022 OpenVox all rights reserved.