summaryrefslogtreecommitdiff
path: root/xpp/card_fxo.c
diff options
context:
space:
mode:
Diffstat (limited to 'xpp/card_fxo.c')
-rw-r--r--xpp/card_fxo.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/xpp/card_fxo.c b/xpp/card_fxo.c
index 70d6018..6348955 100644
--- a/xpp/card_fxo.c
+++ b/xpp/card_fxo.c
@@ -417,6 +417,23 @@ int FXO_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, zt_txsig_t txsig)
return 0;
}
+static int FXO_card_open(xpd_t *xpd, lineno_t chan)
+{
+ struct FXO_priv_data *priv;
+
+ BUG_ON(!xpd);
+ priv = xpd->priv;
+ /*
+ * We pretend to have battery. If this is really the case
+ * than next calls to update_battery_status() won't change it.
+ * If we don't have battery, than on the next calls to
+ * update_battery_status() a battery_debounce[] cycle would start.
+ * Than, if no-battery is persistent, asterisk would be notified.
+ */
+ BIT_SET(priv->battery, chan);
+ return 0;
+}
+
static void poll_battery(xbus_t *xbus, xpd_t *xpd)
{
int i;
@@ -634,13 +651,17 @@ static void update_battery_status(xpd_t *xpd, byte data_low, lineno_t chipsel)
if(IS_SET(priv->battery, chipsel) && priv->battery_debounce[chipsel]++ > BAT_DEBOUNCE) {
DBG("%s/%s/%d: BATTERY OFF voltage=%d\n", xpd->xbus->busname, xpd->xpdname, chipsel, bat);
BIT_CLR(priv->battery, chipsel);
- update_line_status(xpd, chipsel, 0);
+ if(SPAN_REGISTERED(xpd))
+ zt_qevent_lock(&xpd->chans[chipsel], ZT_EVENT_ALARM);
+
}
} else {
priv->battery_debounce[chipsel] = 0;
if(!IS_SET(priv->battery, chipsel)) {
DBG("%s/%s/%d: BATTERY ON voltage=%d\n", xpd->xbus->busname, xpd->xpdname, chipsel, bat);
BIT_SET(priv->battery, chipsel);
+ if(SPAN_REGISTERED(xpd))
+ zt_qevent_lock(&xpd->chans[chipsel], ZT_EVENT_NOALARM);
}
}
/*
@@ -757,12 +778,11 @@ xproto_table_t PROTO_TABLE(FXO) = {
.card_hooksig = FXO_card_hooksig,
.card_tick = FXO_card_tick,
.card_ioctl = FXO_card_ioctl,
+ .card_open = FXO_card_open,
.RING = XPROTO_CALLER(FXO, RING),
.RELAY_OUT = XPROTO_CALLER(FXO, RELAY_OUT),
.XPD_STATE = XPROTO_CALLER(FXO, XPD_STATE),
-
- .SYNC_SOURCE = XPROTO_CALLER(GLOBAL, SYNC_SOURCE),
},
.packet_is_valid = fxo_packet_is_valid,
.packet_dump = fxo_packet_dump,