chan_sebi for asterisk-1.6

I’ve found the chan-sebi project, that is a very interesting way to create cellular client trunks. But it works only on Asterisk 1.4. Is there a port to 1.6 or any other solution for this other than chan_mobile?

Google says there’s a 1.6 port / patch here:

mycrofters.com/content/getti … d-chansebi

You will need to modify the source to make it work for 1.6. Below is the diff file which you can apply to existing code:

— chan_sebi.c.1.4 2009-08-25 16:34:25.000000000 +0100
+++ chan_sebi.c 2009-08-25 16:33:11.000000000 +0100
@@ -56,6 +56,7 @@
#include <asterisk/dsp.h>
#include <asterisk/app.h>
#include <asterisk/manager.h>
+#include <asterisk/paths.h>

#define MODEM_CONFIG “sebi.conf”
#define DEVICE_CONFIG “sebi_devices.conf”
@@ -80,6 +81,7 @@
MODEM_STATE_INIT5,
MODEM_STATE_INIT6,
MODEM_STATE_INIT7,

  • MODEM_STATE_INIT8,
    MODEM_STATE_INIT_VOICE,
    MODEM_STATE_INIT_VOICE1,
    MODEM_STATE_INIT_VOICE2,
    @@ -115,7 +117,7 @@
    char imei[16]; /* imei of modem /
    char csca[15]; /
    CSCA number (sms centre address) /
    char net_provider[6]; /
    Network Provider */
  • char net_name[20]; /* Network friendly name */
  • char net_name[50]; /* Network friendly name /
    int volume; /
    modem volume /
    char language[MAX_LANGUAGE];
    char context[AST_MAX_CONTEXT]; /
    the context for incoming calls */
    @@ -156,19 +158,18 @@
    static AST_RWLIST_HEAD_STATIC(devices, modem_pvt);

/* CLI stuff */
-static const char show_usage[] =
-“Usage: sebi show devices\n”
-" Shows the state of Modem devices.\n";

-static int handle_cli_modem_show_devices(int fd, int argc, char **argv);
+static char *handle_cli_modem_show_devices(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);

static int voice_write(int s, char *buf, int len);
static int voice_read(int s, char *buf, int len);

static struct ast_cli_entry modem_cli[] = {

  • {{“sebi”, “show”, “devices”, NULL}, handle_cli_modem_show_devices, “Show Modem devices”, show_usage},
  • AST_CLI_DEFINE(handle_cli_modem_show_devices, “Show sebi devices”),
    };

/* App stuff */
static char *app_sebistatus = “SebiStatus”;
static char *sebistatus_synopsis = “SebiStatus(Device,Variable)”;
@@ -220,7 +221,7 @@

/* CLI Commands implementation */

-static int handle_cli_modem_show_devices(int fd, int argc, char **argv)
+static char *handle_cli_modem_show_devices(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct modem_pvt *pvt;

@@ -228,15 +229,25 @@

#define FORMAT1 “%-15.15s %-17.17s %-15.15s %-15.15s %-9.9s %-5.5s %-5.5s %-3.3s\n”

  • if (argc != 3)
  •   return RESULT_SHOWUSAGE;
    
  • switch (cmd) {
  •    case CLI_INIT:
    
  •    	e->command = "sebi show devices";
    
  •            e->usage = "Usage: sebi show devices\n"
    
  •                       "       Shows the state of the sebi devices.\n";
    
  •   return NULL;
    
  • case CLI_GENERATE:
  •    	return NULL;
    
  • }
  • if (a->argc != 3)
  •   return CLI_SHOWUSAGE;
    
  • ast_cli(fd, FORMAT1, “ID”, “IMEI”, “Group”, “Provider”, “Connected”, “State”, “Voice”, “SMS”);
  • ast_cli(a->fd, FORMAT1, “ID”, “IMEI”, “Group”, “Provider”, “Connected”, “State”, “Voice”, “SMS”);
    AST_RWLIST_RDLOCK(&devices);
    AST_RWLIST_TRAVERSE(&devices, pvt, entry) {

    snprintf(group, 5, "%d", pvt->group);
    
  •   ast_cli(fd, FORMAT1, pvt->id, pvt->imei, group, pvt->net_name, pvt->connected ? "Yes" : "No",
    
  •   ast_cli(a->fd, FORMAT1, pvt->id, pvt->imei, group, pvt->net_name, pvt->connected ? "Yes" : "No",
      	(pvt->state == MODEM_STATE_IDLE) ? "Free" : (pvt->state < MODEM_STATE_IDLE) ? "Init" : "Busy",
      	(pvt->has_voice) ? "Yes" : "No", (pvt->has_sms) ? "Yes" : "No");
    
    }
    @@ -244,7 +255,7 @@

#undef FORMAT1

  • return RESULT_SUCCESS;
  • return CLI_SUCCESS;
    }

/*
@@ -643,9 +654,9 @@
pvt->fr.mallocd = 0;
pvt->fr.delivery.tv_sec = 0;
pvt->fr.delivery.tv_usec = 0;

  • pvt->fr.data = pvt->io_buf + AST_FRIENDLY_OFFSET;
  • pvt->fr.data.ptr = pvt->io_buf + AST_FRIENDLY_OFFSET;
  • if ((r = read(pvt->io_pipe[0], pvt->fr.data, CHANNEL_FRAME_SIZE)) != CHANNEL_FRAME_SIZE) {
  • if ((r = read(pvt->io_pipe[0], pvt->fr.data.ptr, CHANNEL_FRAME_SIZE)) != CHANNEL_FRAME_SIZE) {
    if (r == -1) {
    ast_log(LOG_ERROR, “read error %d\n”, errno);
    return &ast_null_frame;
    @@ -697,7 +708,7 @@
    io_need = 0;
    if (pvt->io_save_len > 0) {
    io_need = DEVICE_FRAME_SIZE - pvt->io_save_len;
  •   memcpy(pvt->io_save_buf + pvt->io_save_len, frame->data, io_need);
    
  •   memcpy(pvt->io_save_buf + pvt->io_save_len, frame->data.ptr, io_need);
      r = voice_write(pvt->voice_socket, pvt->io_save_buf, DEVICE_FRAME_SIZE);
      if ((r = voice_read(pvt->voice_socket, buf, DEVICE_FRAME_SIZE))) {
      	if ((ast->_state == AST_STATE_UP) || (ast->_state == AST_STATE_DIALING))	// Dont queue the audio in the pipe if the call is not up yet. just toss it. 
    

@@ -706,7 +717,7 @@
}

num_frames = (frame->datalen - io_need) / DEVICE_FRAME_SIZE;
  • pfr = frame->data + io_need;
  • pfr = frame->data.ptr + io_need;

    for (i=0; i<num_frames; i++) {
    r = voice_write(pvt->voice_socket, pfr, DEVICE_FRAME_SIZE );
    @@ -1053,7 +1064,7 @@
    break;
    case MODEM_STATE_INIT5:
    if (strstr(buf, “+CREG: 0,1”)) { // Network OK

  •   			data_write(pvt, "AT+COPS=3,0\r");
    
  •   			data_write(pvt, "AT+COPS=3,2\r"); // was 3,0
      			pvt->state++;
      		}else if (strstr(buf, "+CREG: 0,2")) { // Not network - request again ...
      			pvt->state--;
    

@@ -1087,6 +1098,11 @@
}
}
break;

  •   	case MODEM_STATE_INIT8: 
    
  •   		snprintf(buf, sizeof(buf), "AT+CNUM\r"); // Debug print MSISDN
    
  •   		data_write(pvt, buf);
    
  •   		pvt->state++;
    
  •   		break;
      	case MODEM_STATE_INIT_VOICE: 
      		snprintf(buf, sizeof(buf), "AT+CLVL=%d\r", pvt->volume); // Adjust Volume
      		data_write(pvt, buf);
    

@@ -1653,6 +1669,7 @@
{
struct ast_config *cfg = NULL;
struct ast_config *devices_cfg = NULL;

  • struct ast_flags config_flags = { 0 };
    char *cat = NULL;
    char *device_cat = NULL;
    struct ast_variable *var;
    @@ -1665,11 +1682,11 @@
    char *dr;
    int res, res2, s;
  • devices_cfg = ast_config_load(DEVICE_CONFIG);
  • devices_cfg = ast_config_load(DEVICE_CONFIG, config_flags);
    if (!devices_cfg)
    return 0;
  • cfg = ast_config_load(MODEM_CONFIG);
  • cfg = ast_config_load(MODEM_CONFIG, config_flags);
    if (!cfg)
    return 0;

@@ -1752,7 +1769,7 @@
pvt->monitor_thread = AST_PTHREADT_NULL;
pvt->dsp = ast_dsp_new();

  •   		res= data_connect(pvt);  //Conect modem data port
    
  •   		res= data_connect(pvt);  //Connect modem data port
      		if (res < 0) {
      			ast_log(LOG_ERROR, "Unable to open data port %s. Not loading device %s.\n", pvt->data_port, pvt->id);
      			break;
    

@@ -1770,8 +1787,8 @@
}
}

  •   		ast_dsp_set_features(pvt->dsp, DSP_FEATURE_DTMF_DETECT);
    
  •   		ast_dsp_digitmode(pvt->dsp, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF);
    
  •   		ast_dsp_set_features(pvt->dsp, DSP_FEATURE_DIGIT_DETECT);
    

+// ast_dsp_digitmode(pvt->dsp, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF);
AST_RWLIST_WRLOCK(&devices);
AST_RWLIST_INSERT_HEAD(&devices, pvt, entry);
AST_RWLIST_UNLOCK(&devices);