Skip to content

Commit

Permalink
Merge branch 'v1.23' into 'master'
Browse files Browse the repository at this point in the history
Update baseline to 1.23

See merge request mer-core/ofono!247
  • Loading branch information
monich committed Feb 5, 2020
2 parents cf2d848 + 0122db0 commit 9b2c4bc
Show file tree
Hide file tree
Showing 19 changed files with 561 additions and 21 deletions.
264 changes: 264 additions & 0 deletions drivers/qmimodem/lte.c
@@ -0,0 +1,264 @@
/*
*
* oFono - Open Source Telephony
*
* Copyright (C) 2018 Jonas Bonn. All rights reserved.
* Copyright (C) 2018 Norrbonn AB. All rights reserved.
* Copyright (C) 2018 Data Respons ASA. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

#include <glib.h>

#include <ofono/modem.h>
#include <ofono/gprs-context.h>
#include <ofono/log.h>
#include <ofono/lte.h>

#include "qmi.h"
#include "wds.h"

#include "qmimodem.h"

struct lte_data {
struct qmi_service *wds;
uint8_t default_profile;
};

static void modify_profile_cb(struct qmi_result *result, void *user_data)
{
struct cb_data *cbd = user_data;
ofono_lte_cb_t cb = cbd->cb;
uint16_t error;

DBG("");

if (qmi_result_set_error(result, &error)) {
DBG("Failed to modify profile: %d", error);
CALLBACK_WITH_FAILURE(cb, cbd->data);
return;
}

CALLBACK_WITH_SUCCESS(cb, cbd->data);
}

static void qmimodem_lte_set_default_attach_info(const struct ofono_lte *lte,
const struct ofono_lte_default_attach_info *info,
ofono_lte_cb_t cb, void *data)
{
struct lte_data *ldd = ofono_lte_get_data(lte);
struct cb_data *cbd = cb_data_new(cb, data);
struct qmi_param* param;
struct {
uint8_t type;
uint8_t index;
} __attribute__((packed)) p = {
.type = 0, /* 3GPP */
};

DBG("");

p.index = ldd->default_profile;

param = qmi_param_new();
if (!param)
goto error;

/* Profile selector */
qmi_param_append(param, 0x01, sizeof(p), &p);

/* WDS APN Name */
qmi_param_append(param, QMI_WDS_PARAM_APN,
strlen(info->apn), info->apn);

/* Modify profile */
if (qmi_service_send(ldd->wds, 0x28, param,
modify_profile_cb, cbd, g_free) > 0)
return;

qmi_param_free(param);

error:
CALLBACK_WITH_FAILURE(cb, cbd->data);
}

static void reset_profile_cb(struct qmi_result *result, void *user_data)
{
struct ofono_lte *lte = user_data;
uint16_t error;

DBG("");

if (qmi_result_set_error(result, &error))
ofono_error("Reset profile error: %hd", error);

ofono_lte_register(lte);
}

static void get_default_profile_cb(struct qmi_result *result, void *user_data)
{
struct ofono_lte *lte = user_data;
struct lte_data *ldd = ofono_lte_get_data(lte);
uint16_t error;
uint8_t index;
struct qmi_param *param;
struct {
uint8_t type;
uint8_t index;
} __attribute__((packed)) p = {
.type = 0, /* 3GPP */
};

DBG("");

if (qmi_result_set_error(result, &error)) {
ofono_error("Get default profile error: %hd", error);
goto error;
}

/* Profile index */
if (!qmi_result_get_uint8(result, 0x01, &index)) {
ofono_error("Failed query default profile");
goto error;
}

DBG("Default profile index: %hhd", index);

ldd->default_profile = index;

p.index = index;

param = qmi_param_new();
if (!param)
goto error;

/* Profile selector */
qmi_param_append(param, 0x01, sizeof(p), &p);

/* Reset profile */
if (qmi_service_send(ldd->wds, 0x4b, param,
reset_profile_cb, lte, NULL) > 0)
return;

qmi_param_free(param);

error:
ofono_error("Failed to reset profile %hhd", index);
ofono_lte_remove(lte);
}

static void create_wds_cb(struct qmi_service *service, void *user_data)
{
struct ofono_lte *lte = user_data;
struct lte_data *ldd = ofono_lte_get_data(lte);
struct qmi_param *param;
struct {
uint8_t type;
uint8_t family;
} __attribute((packed)) p = {
.type = 0, /* 3GPP */
.family = 0, /* embedded */
};

DBG("");

if (!service) {
ofono_error("Failed to request WDS service");
ofono_lte_remove(lte);
return;
}

ldd->wds = qmi_service_ref(service);

/* Query the default profile */
param = qmi_param_new();
if (!param)
goto error;

/* Profile type */
qmi_param_append(param, 0x1, sizeof(p), &p);

/* Get default profile */
if (qmi_service_send(ldd->wds, 0x49, param,
get_default_profile_cb, lte, NULL) > 0)
return;

qmi_param_free(param);

error:
ofono_error("Failed to query default profile");
ofono_lte_register(lte);
}

static int qmimodem_lte_probe(struct ofono_lte *lte, void *data)
{
struct qmi_device *device = data;
struct lte_data *ldd;

DBG("qmimodem lte probe");

ldd = g_try_new0(struct lte_data, 1);
if (!ldd)
return -ENOMEM;

ofono_lte_set_data(lte, ldd);

qmi_service_create_shared(device, QMI_SERVICE_WDS,
create_wds_cb, lte, NULL);

return 0;
}

static void qmimodem_lte_remove(struct ofono_lte *lte)
{
struct lte_data *ldd = ofono_lte_get_data(lte);

DBG("");

ofono_lte_set_data(lte, NULL);

qmi_service_unregister_all(ldd->wds);

qmi_service_unref(ldd->wds);

g_free(ldd);
}

static struct ofono_lte_driver driver = {
.name = "qmimodem",
.probe = qmimodem_lte_probe,
.remove = qmimodem_lte_remove,
.set_default_attach_info = qmimodem_lte_set_default_attach_info,
};

void qmi_lte_init(void)
{
ofono_lte_driver_register(&driver);
}

void qmi_lte_exit(void)
{
ofono_lte_driver_unregister(&driver);
}
5 changes: 5 additions & 0 deletions ofono/ChangeLog
@@ -1,3 +1,8 @@
ver 1.23:
Fix issue with handling SIM AID sessions.
Add support for QMI LTE bearer handling.
Add support for memory location dialing.

ver 1.22:
Fix issue with GPIO handling and Nokia modems.
Fix issue with SIM state callback and AT modems.
Expand Down
1 change: 1 addition & 0 deletions ofono/Makefile.am
Expand Up @@ -305,6 +305,7 @@ builtin_sources += $(qmi_sources) \
drivers/qmimodem/ussd.c \
drivers/qmimodem/gprs.c \
drivers/qmimodem/gprs-context.c \
drivers/qmimodem/lte.c \
drivers/qmimodem/radio-settings.c \
drivers/qmimodem/location-reporting.c \
drivers/qmimodem/netmon.c
Expand Down
2 changes: 1 addition & 1 deletion ofono/configure.ac
@@ -1,5 +1,5 @@
AC_PREREQ(2.60)
AC_INIT(ofono, 1.22)
AC_INIT(ofono, 1.23)

AM_INIT_AUTOMAKE([foreign subdir-objects color-tests])
AC_CONFIG_HEADERS(config.h)
Expand Down
7 changes: 7 additions & 0 deletions ofono/doc/modem-api.txt
Expand Up @@ -95,6 +95,13 @@ Properties boolean Powered [readwrite]
String representing the software version number of the
modem device.

string SystemPath [readonly, optional]

String representing the system path for the modem
device.
For modems detected by udev events, this corresponds to
the modem sysfs path.

array{string} Features [readonly]

List of currently enabled features. It uses simple
Expand Down
11 changes: 11 additions & 0 deletions ofono/doc/voicecallmanager-api.txt
Expand Up @@ -69,6 +69,17 @@ Methods dict GetProperties()
[service].Error.NotImplemented
[service].Error.Failed

object DialMemory(string memory position, string hide_callerid)

Initiates a new outgoing call to the number in the given memory
position/favourite. For callerid see the Dial method.

Possible Errors: [service].Error.InProgress
[service].Error.InvalidArguments
[service].Error.InvalidFormat
[service].Error.NotImplemented
[service].Error.Failed

void Transfer()

Joins the currently Active (or Outgoing, depending
Expand Down
23 changes: 23 additions & 0 deletions ofono/drivers/hfpmodem/voicecall.c
Expand Up @@ -422,6 +422,28 @@ static void hfp_dial_last(struct ofono_voicecall *vc, ofono_voicecall_cb_t cb,
CALLBACK_WITH_FAILURE(cb, data);

}

static void hfp_dial_memory(struct ofono_voicecall *vc,
unsigned int memory_location,
ofono_voicecall_cb_t cb, void *data)
{
struct voicecall_data *vd = ofono_voicecall_get_data(vc);
struct cb_data *cbd = cb_data_new(cb, data);
char buf[256];

cbd->user = vc;
DBG("Calling memory location %d\n", memory_location);
snprintf(buf, sizeof(buf), "ATD>%d;", memory_location);

if (g_at_chat_send(vd->chat, buf, none_prefix,
atd_cb, cbd, g_free) > 0)
return;

g_free(cbd);
DBG("at_chat_failed");
CALLBACK_WITH_FAILURE(cb, data);
}

static void hfp_template(const char *cmd, struct ofono_voicecall *vc,
GAtResultFunc result_cb, unsigned int affected_types,
ofono_voicecall_cb_t cb, void *data)
Expand Down Expand Up @@ -1287,6 +1309,7 @@ static struct ofono_voicecall_driver driver = {
.remove = hfp_voicecall_remove,
.dial = hfp_dial,
.dial_last = hfp_dial_last,
.dial_memory = hfp_dial_memory,
.answer = hfp_answer,
.hangup_active = hfp_hangup,
.hold_all_active = hfp_hold_all_active,
Expand Down

0 comments on commit 9b2c4bc

Please sign in to comment.