]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_gsmopen: convert reported RSSI from AT+CSQ to dBm.
authorDušan Dragić <dragic.dusan@gmail.com>
Thu, 11 Sep 2014 21:29:21 +0000 (23:29 +0200)
committerDušan Dragić <dragic.dusan@gmail.com>
Sun, 21 Sep 2014 18:14:12 +0000 (20:14 +0200)
Add to gsmopen_dump and events.

src/mod/endpoints/mod_gsmopen/gsmopen.h
src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp
src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp

index 9b632f9654448d533c69875caed8d31d6daa8b8f..80bee58265a382070eac4f9a4b1061dc397ca8aa 100644 (file)
@@ -445,6 +445,7 @@ struct private_object {
        int roaming_registered;
        int not_registered;
        int got_signal;
+       int signal_strength;
        char imei[128];
        int requesting_imei;
        char imsi[128];
index 0880c6485435221c7225624309d3799a589c074c..4b68b0a786f0a15dbca92cde3b82d26d5058642b 100644 (file)
@@ -996,6 +996,12 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
                                                tech_pvt->got_signal = 2;
                                        }
 
+                                       if (signal_quality == 99) {
+                                               tech_pvt->signal_strength = 0;
+                                       } else {
+                                               tech_pvt->signal_strength = (signal_quality * 2) - 113; /* RSSI [dBm] = reported_value * 2 - 113dB */
+                                       }
+
                                }
 
                        }
index 4a8ed76c4f29413f0248c79eabdd5ac522829f0b..797f3399d1808eb9721421b9377eed45ff268ea8 100644 (file)
@@ -2420,6 +2420,8 @@ SWITCH_STANDARD_API(gsmopen_dump_function)
                                        }
                                        snprintf(value, sizeof(value) - 1, "%d", tech_pvt->got_signal);
                                        stream->write_function(stream, "got_signal = %s\n", value);
+                                       snprintf(value, sizeof(value) - 1, "%d", tech_pvt->signal_strength);
+                                       stream->write_function(stream, "signal_strength = %s\n", value);
                                        snprintf(value, sizeof(value) - 1, "%d", tech_pvt->running);
                                        stream->write_function(stream, "running = %s\n", value);
                                        stream->write_function(stream, "subscriber_number = %s\n", tech_pvt->subscriber_number);
@@ -2483,6 +2485,8 @@ SWITCH_STANDARD_API(gsmopen_dump_function)
                        }
                        snprintf(value, sizeof(value) - 1, "%d", tech_pvt->got_signal);
                        stream->write_function(stream, "got_signal = %s\n", value);
+                       snprintf(value, sizeof(value) - 1, "%d", tech_pvt->signal_strength);
+                       stream->write_function(stream, "signal_strength = %s\n", value);
                        snprintf(value, sizeof(value) - 1, "%d", tech_pvt->running);
                        stream->write_function(stream, "running = %s\n", value);
                        stream->write_function(stream, "subscriber_number = %s\n", tech_pvt->subscriber_number);
@@ -2817,6 +2821,8 @@ int dump_event_full(private_t *tech_pvt, int is_alarm, int alarm_code, const cha
                }
                snprintf(value, sizeof(value) - 1, "%d", tech_pvt->got_signal);
                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "got_signal", value);
+               snprintf(value, sizeof(value) - 1, "%d", tech_pvt->signal_strength);
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "signal_strength", value);
                snprintf(value, sizeof(value) - 1, "%d", tech_pvt->running);
                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "running", value);
                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subscriber_number", tech_pvt->subscriber_number);