annotate src/cs/services/buzm/buzm_api.c @ 303:f76436d19a7a default tip

!GPRS config: fix long-standing AT+COPS chance hanging bug There has been a long-standing bug in FreeCalypso going back years: sometimes in the AT command bring-up sequence of an ACI-only MS, the AT+COPS command would produce only a power scan followed by cessation of protocol stack activity (only L1 ADC traces), instead of the expected network search sequence. This behaviour was seen in different FC firmware versions going back to Citrine, and seemed to follow some law of chance, not reliably repeatable. This bug has been tracked down and found to be specific to !GPRS configuration, stemming from our TCS2/TCS3 hybrid and reconstruction of !GPRS support that was bitrotten in TCS3.2/LoCosto version. ACI module psa_mms.c, needed only for !GPRS, was missing in the TCS3 version and had to be pulled from TCS2 - but as it turns out, there is a new field in the MMR_REG_REQ primitive that needs to be set correctly, and that psa_mms.c module is the place where this initialization needed to be added.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 08 Jun 2023 08:23:37 +0000
parents 8dfdf88d632f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
297
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * The implementation of our external API functions lives here.
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include "buzm/buzm_api.h"
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "buzm/buzm_env.h"
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "buzm/buzm_messages_i.h"
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "rv/rv_general.h"
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "rvf/rvf_api.h"
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "rvm/rvm_use_id_list.h"
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "ffs/ffs_api.h"
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 T_RV_RET buzm_play_melody(const char *pathname, UINT8 volume, BOOL loop)
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 {
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 struct buzm_start_msg *msg;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 T_FFS_FD fd;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (!buzm_env)
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 return RV_NOT_READY;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 if (volume < BUZM_VOLUME_MIN || volume > BUZM_VOLUME_MAX)
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 return RV_INVALID_PARAMETER;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 fd = ffs_open(pathname, FFS_O_RDONLY);
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 if (fd <= 0)
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 return RV_INVALID_PARAMETER;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (rvf_get_buf(buzm_env->prim_id, sizeof(struct buzm_start_msg),
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 (T_RVF_BUFFER **)&msg) == RVF_RED) {
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 rvf_send_trace(
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 "rvf_get_buf() failed in buzm_play_melody()", 42,
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 NULL_PARAM, RV_TRACE_LEVEL_ERROR, BUZM_USE_ID);
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 ffs_close(fd);
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 return RV_MEMORY_ERR;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 msg->hdr.msg_id = BUZM_START_REQ;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 msg->hdr.src_addr_id = buzm_env->addr_id;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 msg->hdr.dest_addr_id = buzm_env->addr_id;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 msg->hdr.callback_func = NULL;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 msg->fd = fd;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 msg->volume = volume;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 msg->loop = loop;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 if (rvf_send_msg(buzm_env->addr_id, msg) != RV_OK) {
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 rvf_send_trace("buzm_play_melody(): Send failed!", 32,
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 NULL_PARAM, RV_TRACE_LEVEL_ERROR, BUZM_USE_ID);
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 rvf_free_buf(msg);
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 ffs_close(fd);
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 return RV_INTERNAL_ERR;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 return RV_OK;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 }
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 T_RV_RET buzm_stop_melody(void)
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 {
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 struct buzm_stop_msg *msg;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 if (!buzm_env)
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 return RV_NOT_READY;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 if (rvf_get_buf(buzm_env->prim_id, sizeof(struct buzm_stop_msg),
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 (T_RVF_BUFFER **)&msg) == RVF_RED) {
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 rvf_send_trace(
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 "rvf_get_buf() failed in buzm_stop_melody()", 42,
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 NULL_PARAM, RV_TRACE_LEVEL_ERROR, BUZM_USE_ID);
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 return RV_MEMORY_ERR;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 }
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 msg->hdr.msg_id = BUZM_STOP_REQ;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 msg->hdr.src_addr_id = buzm_env->addr_id;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 msg->hdr.dest_addr_id = buzm_env->addr_id;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 msg->hdr.callback_func = NULL;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 if (rvf_send_msg(buzm_env->addr_id, msg) != RV_OK) {
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 rvf_send_trace("buzm_stop_melody(): Send failed!", 32,
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 NULL_PARAM, RV_TRACE_LEVEL_ERROR, BUZM_USE_ID);
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 rvf_free_buf(msg);
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 return RV_INTERNAL_ERR;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 }
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 return RV_OK;
8dfdf88d632f BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 }