bta_av_ssm.cc 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. /******************************************************************************
  2. *
  3. * Copyright 2004-2012 Broadcom Corporation
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at:
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. ******************************************************************************/
  18. /******************************************************************************
  19. *
  20. * This is the stream state machine for the BTA advanced audio/video.
  21. *
  22. ******************************************************************************/
  23. #include <string.h>
  24. #include "bt_target.h"
  25. #include "bta_av_co.h"
  26. #include "bta_av_int.h"
  27. /*****************************************************************************
  28. * Constants and types
  29. ****************************************************************************/
  30. /* state machine states */
  31. enum {
  32. BTA_AV_INIT_SST,
  33. BTA_AV_INCOMING_SST,
  34. BTA_AV_OPENING_SST,
  35. BTA_AV_OPEN_SST,
  36. BTA_AV_RCFG_SST,
  37. BTA_AV_CLOSING_SST
  38. };
  39. /* state machine action enumeration list */
  40. enum {
  41. BTA_AV_DO_DISC,
  42. BTA_AV_CLEANUP,
  43. BTA_AV_FREE_SDB,
  44. BTA_AV_CONFIG_IND,
  45. BTA_AV_DISCONNECT_REQ,
  46. BTA_AV_SECURITY_REQ,
  47. BTA_AV_SECURITY_RSP,
  48. BTA_AV_SETCONFIG_RSP,
  49. BTA_AV_ST_RC_TIMER,
  50. BTA_AV_STR_OPENED,
  51. BTA_AV_SECURITY_IND,
  52. BTA_AV_SECURITY_CFM,
  53. BTA_AV_DO_CLOSE,
  54. BTA_AV_CONNECT_REQ,
  55. BTA_AV_SDP_FAILED,
  56. BTA_AV_DISC_RESULTS,
  57. BTA_AV_DISC_RES_AS_ACP,
  58. BTA_AV_OPEN_FAILED,
  59. BTA_AV_GETCAP_RESULTS,
  60. BTA_AV_SETCONFIG_REJ,
  61. BTA_AV_DISCOVER_REQ,
  62. BTA_AV_CONN_FAILED,
  63. BTA_AV_DO_START,
  64. BTA_AV_STR_STOPPED,
  65. BTA_AV_RECONFIG,
  66. BTA_AV_DATA_PATH,
  67. BTA_AV_START_OK,
  68. BTA_AV_START_FAILED,
  69. BTA_AV_STR_CLOSED,
  70. BTA_AV_CLR_CONG,
  71. BTA_AV_SUSPEND_CFM,
  72. BTA_AV_RCFG_STR_OK,
  73. BTA_AV_RCFG_FAILED,
  74. BTA_AV_RCFG_CONNECT,
  75. BTA_AV_RCFG_DISCNTD,
  76. BTA_AV_SUSPEND_CONT,
  77. BTA_AV_RCFG_CFM,
  78. BTA_AV_RCFG_OPEN,
  79. BTA_AV_SECURITY_REJ,
  80. BTA_AV_OPEN_RC,
  81. BTA_AV_CHK_2ND_START,
  82. BTA_AV_SAVE_CAPS,
  83. BTA_AV_SET_USE_RC,
  84. BTA_AV_CCO_CLOSE,
  85. BTA_AV_SWITCH_ROLE,
  86. BTA_AV_ROLE_RES,
  87. BTA_AV_DELAY_CO,
  88. BTA_AV_OPEN_AT_INC,
  89. BTA_AV_OFFLOAD_REQ,
  90. BTA_AV_OFFLOAD_RSP,
  91. BTA_AV_NUM_SACTIONS
  92. };
  93. #define BTA_AV_SIGNORE BTA_AV_NUM_SACTIONS
  94. /* state table information */
  95. /* #define BTA_AV_SACTION_COL 0 position of actions */
  96. #define BTA_AV_SACTIONS 2 /* number of actions */
  97. #define BTA_AV_SNEXT_STATE 2 /* position of next state */
  98. #define BTA_AV_NUM_COLS 3 /* number of columns in state tables */
  99. /* state table for init state */
  100. static const uint8_t bta_av_sst_init[][BTA_AV_NUM_COLS] = {
  101. /* Event Action 1 Action 2 Next state */
  102. /* API_OPEN_EVT */ {BTA_AV_DO_DISC, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  103. /* API_CLOSE_EVT */ {BTA_AV_CLEANUP, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  104. /* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  105. /* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  106. /* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  107. /* API_PROTECT_REQ_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  108. /* API_PROTECT_RSP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  109. /* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  110. /* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  111. /* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  112. /* CI_SETCONFIG_FAIL_EVT */
  113. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  114. /* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  115. /* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  116. /* STR_DISC_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  117. /* STR_DISC_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  118. /* STR_GETCAP_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  119. /* STR_GETCAP_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  120. /* STR_OPEN_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  121. /* STR_OPEN_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  122. /* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  123. /* STR_START_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  124. /* STR_CLOSE_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  125. /* STR_CONFIG_IND_EVT */
  126. {BTA_AV_CONFIG_IND, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  127. /* STR_SECURITY_IND_EVT */
  128. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  129. /* STR_SECURITY_CFM_EVT */
  130. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  131. /* STR_WRITE_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  132. /* STR_SUSPEND_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  133. /* STR_RECONFIG_CFM_EVT */
  134. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  135. /* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  136. /* AVDT_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  137. /* AVDT_DISCONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  138. /* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  139. /* AVDT_DELAY_RPT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  140. /* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  141. /* API_OFFLOAD_START_EVT */
  142. {BTA_AV_OFFLOAD_REQ, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  143. /* API_OFFLOAD_START_RSP_EVT */
  144. {BTA_AV_OFFLOAD_RSP, BTA_AV_SIGNORE, BTA_AV_INIT_SST}};
  145. /* state table for incoming state */
  146. static const uint8_t bta_av_sst_incoming[][BTA_AV_NUM_COLS] = {
  147. /* Event Action 1 Action 2 Next state */
  148. /* API_OPEN_EVT */ {BTA_AV_OPEN_AT_INC, BTA_AV_SIGNORE,
  149. BTA_AV_INCOMING_SST},
  150. /* API_CLOSE_EVT */
  151. {BTA_AV_CCO_CLOSE, BTA_AV_DISCONNECT_REQ, BTA_AV_CLOSING_SST},
  152. /* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  153. /* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  154. /* API_RECONFIG_EVT */
  155. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  156. /* API_PROTECT_REQ_EVT */
  157. {BTA_AV_SECURITY_REQ, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  158. /* API_PROTECT_RSP_EVT */
  159. {BTA_AV_SECURITY_RSP, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  160. /* API_RC_OPEN_EVT */
  161. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  162. /* SRC_DATA_READY_EVT */
  163. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  164. /* CI_SETCONFIG_OK_EVT */
  165. {BTA_AV_SETCONFIG_RSP, BTA_AV_ST_RC_TIMER, BTA_AV_INCOMING_SST},
  166. /* CI_SETCONFIG_FAIL_EVT */
  167. {BTA_AV_SETCONFIG_REJ, BTA_AV_CLEANUP, BTA_AV_INIT_SST},
  168. /* SDP_DISC_OK_EVT */
  169. {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  170. /* SDP_DISC_FAIL_EVT */
  171. {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  172. /* STR_DISC_OK_EVT */
  173. {BTA_AV_DISC_RES_AS_ACP, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  174. /* STR_DISC_FAIL_EVT */
  175. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  176. /* STR_GETCAP_OK_EVT */
  177. {BTA_AV_SAVE_CAPS, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  178. /* STR_GETCAP_FAIL_EVT */
  179. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  180. /* STR_OPEN_OK_EVT */ {BTA_AV_STR_OPENED, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  181. /* STR_OPEN_FAIL_EVT */
  182. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  183. /* STR_START_OK_EVT */
  184. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  185. /* STR_START_FAIL_EVT */
  186. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  187. /* STR_CLOSE_EVT */ {BTA_AV_CCO_CLOSE, BTA_AV_CLEANUP, BTA_AV_INIT_SST},
  188. /* STR_CONFIG_IND_EVT */
  189. {BTA_AV_CONFIG_IND, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  190. /* STR_SECURITY_IND_EVT */
  191. {BTA_AV_SECURITY_IND, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  192. /* STR_SECURITY_CFM_EVT */
  193. {BTA_AV_SECURITY_CFM, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  194. /* STR_WRITE_CFM_EVT */
  195. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  196. /* STR_SUSPEND_CFM_EVT */
  197. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  198. /* STR_RECONFIG_CFM_EVT */
  199. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  200. /* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  201. /* AVDT_CONNECT_EVT */
  202. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  203. /* AVDT_DISCONNECT_EVT */
  204. {BTA_AV_CCO_CLOSE, BTA_AV_DISCONNECT_REQ, BTA_AV_CLOSING_SST},
  205. /* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  206. /* AVDT_DELAY_RPT_EVT */
  207. {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  208. /* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  209. /* API_OFFLOAD_START_EVT */
  210. {BTA_AV_OFFLOAD_REQ, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  211. /* API_OFFLOAD_START_RSP_EVT */
  212. {BTA_AV_OFFLOAD_RSP, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}};
  213. /* state table for opening state */
  214. static const uint8_t bta_av_sst_opening[][BTA_AV_NUM_COLS] = {
  215. /* Event Action 1 Action 2 Next state */
  216. /* API_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  217. /* API_CLOSE_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  218. /* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  219. /* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  220. /* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  221. /* API_PROTECT_REQ_EVT */
  222. {BTA_AV_SECURITY_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  223. /* API_PROTECT_RSP_EVT */
  224. {BTA_AV_SECURITY_RSP, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  225. /* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  226. /* SRC_DATA_READY_EVT */
  227. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  228. /* CI_SETCONFIG_OK_EVT */
  229. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  230. /* CI_SETCONFIG_FAIL_EVT */
  231. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  232. /* SDP_DISC_OK_EVT */
  233. {BTA_AV_CONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  234. /* SDP_DISC_FAIL_EVT */
  235. {BTA_AV_CONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  236. /* STR_DISC_OK_EVT */
  237. {BTA_AV_DISC_RESULTS, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  238. /* STR_DISC_FAIL_EVT */
  239. {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  240. /* STR_GETCAP_OK_EVT */
  241. {BTA_AV_GETCAP_RESULTS, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  242. /* STR_GETCAP_FAIL_EVT */
  243. {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  244. /* STR_OPEN_OK_EVT */
  245. {BTA_AV_ST_RC_TIMER, BTA_AV_STR_OPENED, BTA_AV_OPEN_SST},
  246. /* STR_OPEN_FAIL_EVT */
  247. {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  248. /* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  249. /* STR_START_FAIL_EVT */
  250. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  251. /* STR_CLOSE_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  252. /* STR_CONFIG_IND_EVT */
  253. {BTA_AV_CONFIG_IND, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST},
  254. /* STR_SECURITY_IND_EVT */
  255. {BTA_AV_SECURITY_IND, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  256. /* STR_SECURITY_CFM_EVT */
  257. {BTA_AV_SECURITY_CFM, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  258. /* STR_WRITE_CFM_EVT */
  259. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  260. /* STR_SUSPEND_CFM_EVT */
  261. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  262. /* STR_RECONFIG_CFM_EVT */
  263. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  264. /* AVRC_TIMER_EVT */
  265. {BTA_AV_SWITCH_ROLE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  266. /* AVDT_CONNECT_EVT */
  267. {BTA_AV_DISCOVER_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  268. /* AVDT_DISCONNECT_EVT */
  269. {BTA_AV_CONN_FAILED, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  270. /* ROLE_CHANGE_EVT*/ {BTA_AV_ROLE_RES, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  271. /* AVDT_DELAY_RPT_EVT */
  272. {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  273. /* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  274. /* API_OFFLOAD_START_EVT */
  275. {BTA_AV_OFFLOAD_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST},
  276. /* API_OFFLOAD_START_RSP_EVT */
  277. {BTA_AV_OFFLOAD_RSP, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}};
  278. /* state table for open state */
  279. static const uint8_t bta_av_sst_open[][BTA_AV_NUM_COLS] = {
  280. /* Event Action 1 Action 2 Next state */
  281. /* API_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  282. /* API_CLOSE_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  283. /* AP_START_EVT */ {BTA_AV_DO_START, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  284. /* AP_STOP_EVT */ {BTA_AV_STR_STOPPED, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  285. /* API_RECONFIG_EVT */ {BTA_AV_RECONFIG, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  286. /* API_PROTECT_REQ_EVT */
  287. {BTA_AV_SECURITY_REQ, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  288. /* API_PROTECT_RSP_EVT */
  289. {BTA_AV_SECURITY_RSP, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  290. /* API_RC_OPEN_EVT */ {BTA_AV_SET_USE_RC, BTA_AV_OPEN_RC, BTA_AV_OPEN_SST},
  291. /* SRC_DATA_READY_EVT */
  292. {BTA_AV_DATA_PATH, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  293. /* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  294. /* CI_SETCONFIG_FAIL_EVT */
  295. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  296. /* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  297. /* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  298. /* STR_DISC_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  299. /* STR_DISC_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  300. /* STR_GETCAP_OK_EVT */ {BTA_AV_SAVE_CAPS, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  301. /* STR_GETCAP_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  302. /* STR_OPEN_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  303. /* STR_OPEN_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  304. /* STR_START_OK_EVT */ {BTA_AV_START_OK, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  305. /* STR_START_FAIL_EVT */
  306. {BTA_AV_START_FAILED, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  307. /* STR_CLOSE_EVT */ {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  308. /* STR_CONFIG_IND_EVT */
  309. {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  310. /* STR_SECURITY_IND_EVT */
  311. {BTA_AV_SECURITY_IND, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  312. /* STR_SECURITY_CFM_EVT */
  313. {BTA_AV_SECURITY_CFM, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  314. /* STR_WRITE_CFM_EVT */
  315. {BTA_AV_CLR_CONG, BTA_AV_DATA_PATH, BTA_AV_OPEN_SST},
  316. /* STR_SUSPEND_CFM_EVT */
  317. {BTA_AV_SUSPEND_CFM, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  318. /* STR_RECONFIG_CFM_EVT */
  319. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  320. /* AVRC_TIMER_EVT */
  321. {BTA_AV_OPEN_RC, BTA_AV_CHK_2ND_START, BTA_AV_OPEN_SST},
  322. /* AVDT_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  323. /* AVDT_DISCONNECT_EVT */
  324. {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  325. /* ROLE_CHANGE_EVT*/ {BTA_AV_ROLE_RES, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  326. /* AVDT_DELAY_RPT_EVT */ {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  327. /* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  328. /* API_OFFLOAD_START_EVT */
  329. {BTA_AV_OFFLOAD_REQ, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  330. /* API_OFFLOAD_START_RSP_EVT */
  331. {BTA_AV_OFFLOAD_RSP, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}};
  332. /* state table for reconfig state */
  333. static const uint8_t bta_av_sst_rcfg[][BTA_AV_NUM_COLS] = {
  334. /* Event Action 1 Action 2 Next state */
  335. /* API_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  336. /* API_CLOSE_EVT */
  337. {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  338. /* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  339. /* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  340. /* API_RECONFIG_EVT */ {BTA_AV_RECONFIG, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  341. /* API_PROTECT_REQ_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  342. /* API_PROTECT_RSP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  343. /* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  344. /* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  345. /* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  346. /* CI_SETCONFIG_FAIL_EVT */
  347. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  348. /* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  349. /* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  350. /* STR_DISC_OK_EVT */
  351. {BTA_AV_DISC_RESULTS, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  352. /* STR_DISC_FAIL_EVT */
  353. {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  354. /* STR_GETCAP_OK_EVT */
  355. {BTA_AV_GETCAP_RESULTS, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  356. /* STR_GETCAP_FAIL_EVT */
  357. {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  358. /* STR_OPEN_OK_EVT */ {BTA_AV_RCFG_STR_OK, BTA_AV_SIGNORE, BTA_AV_OPEN_SST},
  359. /* STR_OPEN_FAIL_EVT */
  360. {BTA_AV_RCFG_FAILED, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  361. /* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  362. /* STR_START_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  363. /* STR_CLOSE_EVT */ {BTA_AV_RCFG_CONNECT, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  364. /* STR_CONFIG_IND_EVT */
  365. {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  366. /* STR_SECURITY_IND_EVT */
  367. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  368. /* STR_SECURITY_CFM_EVT */
  369. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  370. /* STR_WRITE_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  371. /* STR_SUSPEND_CFM_EVT */
  372. {BTA_AV_SUSPEND_CFM, BTA_AV_SUSPEND_CONT, BTA_AV_RCFG_SST},
  373. /* STR_RECONFIG_CFM_EVT */
  374. {BTA_AV_RCFG_CFM, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  375. /* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  376. /* AVDT_CONNECT_EVT */ {BTA_AV_RCFG_OPEN, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  377. /* AVDT_DISCONNECT_EVT */
  378. {BTA_AV_RCFG_DISCNTD, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  379. /* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  380. /* AVDT_DELAY_RPT_EVT */ {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  381. /* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  382. /* API_OFFLOAD_START_EVT */
  383. {BTA_AV_OFFLOAD_REQ, BTA_AV_SIGNORE, BTA_AV_RCFG_SST},
  384. /* API_OFFLOAD_START_RSP_EVT */
  385. {BTA_AV_OFFLOAD_RSP, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}};
  386. /* state table for closing state */
  387. static const uint8_t bta_av_sst_closing[][BTA_AV_NUM_COLS] = {
  388. /* Event Action 1 Action 2 Next state */
  389. /* API_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  390. /* API_CLOSE_EVT */
  391. {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  392. /* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  393. /* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  394. /* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  395. /* API_PROTECT_REQ_EVT */
  396. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  397. /* API_PROTECT_RSP_EVT */
  398. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  399. /* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  400. /* SRC_DATA_READY_EVT */
  401. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  402. /* CI_SETCONFIG_OK_EVT */
  403. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  404. /* CI_SETCONFIG_FAIL_EVT */
  405. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  406. /* SDP_DISC_OK_EVT */ {BTA_AV_SDP_FAILED, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  407. /* SDP_DISC_FAIL_EVT */
  408. {BTA_AV_SDP_FAILED, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  409. /* STR_DISC_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  410. /* STR_DISC_FAIL_EVT */
  411. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  412. /* STR_GETCAP_OK_EVT */
  413. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  414. /* STR_GETCAP_FAIL_EVT */
  415. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  416. /* STR_OPEN_OK_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  417. /* STR_OPEN_FAIL_EVT */
  418. {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  419. /* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  420. /* STR_START_FAIL_EVT */
  421. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  422. /* STR_CLOSE_EVT */
  423. {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  424. /* STR_CONFIG_IND_EVT */
  425. {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  426. /* STR_SECURITY_IND_EVT */
  427. {BTA_AV_SECURITY_REJ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  428. /* STR_SECURITY_CFM_EVT */
  429. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  430. /* STR_WRITE_CFM_EVT */
  431. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  432. /* STR_SUSPEND_CFM_EVT */
  433. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  434. /* STR_RECONFIG_CFM_EVT */
  435. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  436. /* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  437. /* AVDT_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  438. /* AVDT_DISCONNECT_EVT */
  439. {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST},
  440. /* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  441. /* AVDT_DELAY_RPT_EVT */
  442. {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  443. /* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  444. /* API_OFFLOAD_START_EVT */
  445. {BTA_AV_OFFLOAD_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST},
  446. /* API_OFFLOAD_START_RSP_EVT */
  447. {BTA_AV_OFFLOAD_RSP, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}};
  448. /* type for state table */
  449. typedef const uint8_t (*tBTA_AV_SST_TBL)[BTA_AV_NUM_COLS];
  450. /* state table */
  451. static const tBTA_AV_SST_TBL bta_av_sst_tbl[] = {
  452. bta_av_sst_init, bta_av_sst_incoming, bta_av_sst_opening,
  453. bta_av_sst_open, bta_av_sst_rcfg, bta_av_sst_closing};
  454. /*******************************************************************************
  455. *
  456. * Function bta_av_ssm_execute
  457. *
  458. * Description Stream state machine event handling function for AV
  459. *
  460. *
  461. * Returns void
  462. *
  463. ******************************************************************************/
  464. void bta_av_ssm_execute(tBTA_AV_SCB* p_scb, uint16_t event,
  465. tBTA_AV_DATA* p_data) {
  466. if (p_scb == NULL) {
  467. /* this stream is not registered */
  468. APPL_TRACE_EVENT("%s: AV channel not registered", __func__);
  469. return;
  470. }
  471. APPL_TRACE_VERBOSE(
  472. "%s: peer %s AV event(0x%x)=0x%x(%s) state=%d(%s) p_scb=%p", __func__,
  473. p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, event,
  474. bta_av_evt_code(event), p_scb->state, bta_av_sst_code(p_scb->state),
  475. p_scb);
  476. /* look up the state table for the current state */
  477. tBTA_AV_SST_TBL state_table = bta_av_sst_tbl[p_scb->state];
  478. /* set next state */
  479. event -= BTA_AV_FIRST_SSM_EVT;
  480. p_scb->state = state_table[event][BTA_AV_SNEXT_STATE];
  481. APPL_TRACE_VERBOSE("%s: peer %s AV next state=%d(%s) p_scb=%p", __func__,
  482. p_scb->PeerAddress().ToString().c_str(), p_scb->state,
  483. bta_av_sst_code(p_scb->state), p_scb);
  484. /* execute action functions */
  485. for (int i = 0; i < BTA_AV_SACTIONS; i++) {
  486. uint8_t action = state_table[event][i];
  487. if (action != BTA_AV_SIGNORE) {
  488. (*p_scb->p_act_tbl[action])(p_scb, p_data);
  489. } else
  490. break;
  491. }
  492. }
  493. /*******************************************************************************
  494. *
  495. * Function bta_av_is_scb_opening
  496. *
  497. * Description Returns true is scb is in opening state.
  498. *
  499. *
  500. * Returns true if scb is in opening state.
  501. *
  502. ******************************************************************************/
  503. bool bta_av_is_scb_opening(tBTA_AV_SCB* p_scb) {
  504. bool is_opening = false;
  505. if (p_scb) {
  506. if (p_scb->state == BTA_AV_OPENING_SST) is_opening = true;
  507. }
  508. return is_opening;
  509. }
  510. /*******************************************************************************
  511. *
  512. * Function bta_av_is_scb_incoming
  513. *
  514. * Description Returns true is scb is in incoming state.
  515. *
  516. *
  517. * Returns true if scb is in incoming state.
  518. *
  519. ******************************************************************************/
  520. bool bta_av_is_scb_incoming(tBTA_AV_SCB* p_scb) {
  521. bool is_incoming = false;
  522. if (p_scb) {
  523. if (p_scb->state == BTA_AV_INCOMING_SST) is_incoming = true;
  524. }
  525. return is_incoming;
  526. }
  527. /*******************************************************************************
  528. *
  529. * Function bta_av_set_scb_sst_init
  530. *
  531. * Description Set SST state to INIT.
  532. * Use this function to change SST outside of state machine.
  533. *
  534. * Returns None
  535. *
  536. ******************************************************************************/
  537. void bta_av_set_scb_sst_init(tBTA_AV_SCB* p_scb) {
  538. if (p_scb == nullptr) {
  539. return;
  540. }
  541. uint8_t next_state = BTA_AV_INIT_SST;
  542. APPL_TRACE_VERBOSE(
  543. "%s: peer %s AV (hndl=0x%x) state=%d(%s) next state=%d(%s) p_scb=%p",
  544. __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->hndl,
  545. p_scb->state, bta_av_sst_code(p_scb->state), next_state,
  546. bta_av_sst_code(next_state), p_scb);
  547. p_scb->state = next_state;
  548. }
  549. /*******************************************************************************
  550. *
  551. * Function bta_av_is_scb_init
  552. *
  553. * Description Returns true is scb is in init state.
  554. *
  555. *
  556. * Returns true if scb is in incoming state.
  557. *
  558. ******************************************************************************/
  559. bool bta_av_is_scb_init(tBTA_AV_SCB* p_scb) {
  560. bool is_init = false;
  561. if (p_scb) {
  562. if (p_scb->state == BTA_AV_INIT_SST) is_init = true;
  563. }
  564. return is_init;
  565. }
  566. /*******************************************************************************
  567. *
  568. * Function bta_av_set_scb_sst_incoming
  569. *
  570. * Description Set SST state to incoming.
  571. * Use this function to change SST outside of state machine.
  572. *
  573. * Returns None
  574. *
  575. ******************************************************************************/
  576. void bta_av_set_scb_sst_incoming(tBTA_AV_SCB* p_scb) {
  577. if (p_scb) {
  578. p_scb->state = BTA_AV_INCOMING_SST;
  579. }
  580. }
  581. /*****************************************************************************
  582. * Debug Functions
  583. ****************************************************************************/
  584. /*******************************************************************************
  585. *
  586. * Function bta_av_sst_code
  587. *
  588. * Description
  589. *
  590. * Returns char *
  591. *
  592. ******************************************************************************/
  593. const char* bta_av_sst_code(uint8_t state) {
  594. switch (state) {
  595. case BTA_AV_INIT_SST:
  596. return "INIT";
  597. case BTA_AV_INCOMING_SST:
  598. return "INCOMING";
  599. case BTA_AV_OPENING_SST:
  600. return "OPENING";
  601. case BTA_AV_OPEN_SST:
  602. return "OPEN";
  603. case BTA_AV_RCFG_SST:
  604. return "RCFG";
  605. case BTA_AV_CLOSING_SST:
  606. return "CLOSING";
  607. default:
  608. return "unknown";
  609. }
  610. }