1# @ohos.secureElement (SE Management)
2
3The **secureElement** module provides APIs for managing secure elements (SEs). SEs include the Embedded SE (eSE) and SIM on a device. The SE service mentioned in this topic is an **SEService** instance. For details, see [newSEService](#omapinewseservice).
4
5The instances of the following types are mentioned in this topic:
6
7| Type   | Description                                          |
8| ------- | ---------------------------------------------- |
9| Reader  | SE supported by the device. If eSE and SIM are supported, two instances will be returned.|
10| Session | Session created on an SE **Reader** instance.|
11| Channel | Channel set up by a **Session** instance. The channel can be a basic channel or a logical channel.  |
12
13> **NOTE**
14>
15> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
16
17## **Modules to Import**
18
19```js
20import { omapi } from '@kit.ConnectivityKit';
21```
22
23## ServiceState
24
25Enumerates the SE service stats.
26
27**System capability**: SystemCapability.Communication.SecureElement
28
29| Name        | Value  | Description              |
30| ------------ | ---- | ------------------ |
31| DISCONNECTED | 0    | The SE service is disconnected.|
32| CONNECTED    | 1    | The SE service is connected.|
33
34## omapi.newSEService
35
36newSEService(type: 'serviceState', callback: Callback\<ServiceState>): SEService
37
38Creates an **SEService** instance for connecting to all available SEs in the system. The connection is time-consuming. Therefore, this API supports only the asynchronous mode. This API uses an asynchronous callback to return the result.
39
40The returned **SEService** instance is available only when **true** is returned by the specified callback or [isConnected](#seserviceisconnected).
41
42> **NOTE**
43> This API is supported since API version 10 and deprecated since API version 12. Use [createService](#omapicreateservice12) instead.
44
45**System capability**: SystemCapability.Communication.SecureElement
46
47**Parameters**
48
49| **Name**| **Type**                                            | **Mandatory**| **Description**            |
50| ---------- | ---------------------------------------------------- | ------ | -------------------- |
51| type       | string                                               | Yes     | Type of the SE service to create. It has a fixed value of **'serviceState'**.     |
52| callback   | Callback<[ServiceState](#servicestate)> | Yes     | Callback used to return the SE service state.|
53
54**Return value**
55
56| **Type** | **Description**  |
57| -------- | --------- |
58| SEService | **SEService** instance created.|
59
60**Error codes**
61
62For details about error codes, see [SE Error Codes](errorcode-se.md).
63
64| ID| Error Message|
65| ------- | -------|
66| 401  | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
67| 801  | Capability not supported. |
68
69**Example**
70
71```js
72import { omapi } from '@kit.ConnectivityKit';
73import { hilog } from '@kit.PerformanceAnalysisKit';
74
75let seService : omapi.SEService;
76
77function secureElementDemo() {
78    // Obtain the service.
79    try {
80        seService = omapi.newSEService("serviceState", (state) => {
81        hilog.info(0x0000, 'testTag', 'se service state = %{public}s', JSON.stringify(state));
82        });
83    } catch (error) {
84        hilog.error(0x0000, 'testTag', 'newSEService error %{public}s', JSON.stringify(error));
85    }
86    if (seService == undefined || !seService.isConnected()) {
87        hilog.error(0x0000, 'testTag', 'secure element service disconnected.');
88        return;
89    }
90}
91```
92
93## omapi.createService<sup>12+</sup>
94
95createService(): Promise\<SEService>;
96
97Creates an **SEService** instance for connecting to all available SEs in the system. The connection is time-consuming. Therefore, only asynchronous APIs are provided. This API uses a promise to return the result.
98
99The **SEService** object is available only when [isConnected](#seserviceisconnected) returns **true**.
100
101**System capability**: SystemCapability.Communication.SecureElement
102
103**Return value**
104
105| **Type** | **Description**  |
106| :-------- | :--------- |
107| Promise\<[SEService](#seservice)> | Primose used to return the **SEService** instance created.|
108
109**Error codes**
110
111For details about error codes, see [SE Error Codes](errorcode-se.md).
112
113| ID| Error Message                                 |
114| -------- | ----------------------------------------- |
115| 801  | Capability not supported. |
116
117**Example**
118
119```js
120import { omapi } from '@kit.ConnectivityKit';
121import { BusinessError } from '@kit.BasicServicesKit';
122import { hilog } from '@kit.PerformanceAnalysisKit';
123
124let seService : omapi.SEService;
125
126function secureElementDemo() {
127    omapi.createService().then((data) => {
128        seService = data;
129        if (seService == undefined || !seService.isConnected()) {
130            hilog.error(0x0000, 'testTag', 'seservice state disconnected');
131            return;
132        }
133        hilog.info(0x0000, 'testTag', 'seservice state connected');
134    }).catch((error : BusinessError)=> {
135        hilog.error(0x0000, 'testTag', 'createService error %{public}s', JSON.stringify(error));
136    });
137}
138```
139
140## SEService
141
142**SEService** indicates the connection service used to connect to all available SEs in the system. You can use [createService](#omapicreateservice12) to create an **SEService** instance.
143
144### SEService.getReaders
145
146getReaders(): Reader[]
147
148Obtains available SE readers, which include all the SEs on the device.
149
150**System capability**: SystemCapability.Communication.SecureElement
151
152**Return value**
153
154| **Type**| **Description**              |
155| :------- | :--------------------- |
156| [Reader](#reader)[] | Available readers obtained.|
157
158**Error codes**
159
160For details about error codes, see [SE Error Codes](errorcode-se.md).
161
162| ID| Error Message                                 |
163| -------- | ----------------------------------------- |
164| 801  | Capability not supported. |
165
166**Example**
167
168<!--code_no_check-->
169```js
170import { omapi } from '@kit.ConnectivityKit';
171import { hilog } from '@kit.PerformanceAnalysisKit';
172
173let seService : omapi.SEService;
174let seReaders : omapi.Reader[];
175
176// Initialize seService before using it.
177function secureElementDemo() {
178    // Obtain readers.
179    try {
180        seReaders = seService.getReaders();
181    } catch (error) {
182        hilog.error(0x0000, 'testTag', 'getReaders error %{public}s', JSON.stringify(error));
183    }
184    if (seReaders == undefined || seReaders.length == 0) {
185        hilog.error(0x0000, 'testTag', 'no valid reader found.');
186        return;
187    }
188}
189```
190
191### SEService.isConnected
192
193isConnected(): boolean
194
195Checks whether this SE service is connected.
196
197**System capability**: SystemCapability.Communication.SecureElement
198
199**Return value**
200
201| **Type**| **Description**                                      |
202| :------- | :--------------------------------------------- |
203| boolean  | Returns **true** if the SE service is connected; returns **false** otherwise.|
204
205**Error codes**
206
207For details about error codes, see [SE Error Codes](errorcode-se.md).
208
209| ID| Error Message                                 |
210| -------- | ----------------------------------------- |
211| 801  | Capability not supported. |
212
213**Example**
214
215
216```JS
217import { omapi } from '@kit.ConnectivityKit';
218import { BusinessError } from '@kit.BasicServicesKit';
219import { hilog } from '@kit.PerformanceAnalysisKit';
220
221let seService : omapi.SEService;
222
223function secureElementDemo() {
224    // Obtain the service.
225    try {
226        seService = omapi.newSEService("serviceState", (state) => {
227        hilog.info(0x0000, 'testTag', 'se service state = %{public}s', JSON.stringify(state));
228        });
229    } catch (error) {
230        hilog.error(0x0000, 'testTag', 'newSEService error %{public}s', JSON.stringify(error));
231    }
232    if (seService == undefined || !seService.isConnected()) {
233        hilog.error(0x0000, 'testTag', 'secure element service disconnected.');
234        return;
235    }
236}
237```
238
239### SEService.shutdown
240
241shutdown(): void
242
243Releases all SE resources allocated to this SE service. After that, [isConnected](#seserviceisconnected) returns **false**.
244
245**System capability**: SystemCapability.Communication.SecureElement
246
247**Error codes**
248
249For details about error codes, see [SE Error Codes](errorcode-se.md).
250
251| ID| Error Message                                 |
252| -------- | ----------------------------------------- |
253| 801  | Capability not supported. |
254
255**Example**
256
257<!--code_no_check-->
258```js
259import { omapi } from '@kit.ConnectivityKit';
260import { BusinessError } from '@kit.BasicServicesKit';
261import { hilog } from '@kit.PerformanceAnalysisKit';
262
263let seService : omapi.SEService;
264
265// Initialize seService before using it.
266
267try {
268    seService.shutdown();
269} catch (error) {
270    hilog.error(0x0000, 'testTag', 'shutdown error %{public}s', JSON.stringify(error));
271}
272```
273
274### SEService.getVersion
275
276getVersion(): string
277
278Obtains the version of the Open Mobile API (OMAPI) specification used.
279
280**System capability**: SystemCapability.Communication.SecureElement
281
282**Return value**
283
284| **Type**| **Description**                                          |
285| -------- | -------------------------------------------------- |
286| string   | OMAPI version obtained. For example, **3.3** indicates Open Mobile API Specification v3.3.|
287
288**Error codes**
289
290For details about error codes, see [SE Error Codes](errorcode-se.md).
291
292| ID| Error Message                                 |
293| -------- | ----------------------------------------- |
294| 801  | Capability not supported. |
295
296**Example**
297
298<!--code_no_check-->
299```JS
300import { omapi } from '@kit.ConnectivityKit';
301import { BusinessError } from '@kit.BasicServicesKit';
302import { hilog } from '@kit.PerformanceAnalysisKit';
303
304let seService : omapi.SEService;
305
306// Initialize seService before using it.
307
308try {
309    let version = seService.getVersion();
310    hilog.error(0x0000, 'testTag', 'version %{public}s', JSON.stringify(version));
311} catch (error) {
312    hilog.error(0x0000, 'testTag', 'getVersion error %{public}s', JSON.stringify(error));
313}
314```
315## Reader
316
317A **Reader** instance indicates the SEs supported by a device. If eSE and SIM are supported, two instances will be returned. You can use [SEService.getReaders](#seservicegetreaders) to obtain a **Reader** instance.
318
319### Reader.getName
320
321getName(): string
322
323Obtains the name of this reader. The name is **SIM[*Slot*]** for a SIM reader and **eSE** for an eSE.
324
325**System capability**: SystemCapability.Communication.SecureElement
326
327**Return value**
328
329| **Type**| **Description**  |
330| -------- | ---------- |
331| string   | [Reader](#reader) name obtained.|
332
333**Error codes**
334
335For details about the error codes, see [NFC Error Codes](errorcode-nfc.md).
336
337| ID| Error Message                                 |
338| -------- | ----------------------------------------- |
339| 801  | Capability not supported. |
340
341**Example**
342
343<!--code_no_check-->
344```js
345import { hilog } from '@kit.PerformanceAnalysisKit';
346import { omapi } from '@kit.ConnectivityKit';
347
348let seReaders : omapi.Reader[];
349
350// Initialize seReaders before using it.
351
352try {
353    let reader = seReaders[0]; // change it to the selected reader, ese or sim.
354    let name = reader.getName();
355    hilog.info(0x0000, 'testTag', 'name %{public}s', JSON.stringify(name));
356} catch (error) {
357    hilog.error(0x0000, 'testTag', 'getName error %{public}s', JSON.stringify(error));
358}
359```
360
361### Reader.isSecureElementPresent
362
363isSecureElementPresent(): boolean
364
365Checks whether the SE corresponding to this reader is available.
366
367**System capability**: SystemCapability.Communication.SecureElement
368
369**Return value**
370
371| **Type**| **Description**                                    |
372| -------- | -------------------------------------------- |
373| boolean  | Returns **true** if the SE is available; returns **false** otherwise.|
374
375**Error codes**
376
377For details about error codes, see [SE Error Codes](errorcode-se.md).
378
379| ID| Error Message                        |
380| -------- | -------------------------------- |
381| 801  | Capability not supported. |
382| 3300101  | IllegalStateError, service state exception. |
383
384**Example**
385
386<!--code_no_check-->
387```js
388import { hilog } from '@kit.PerformanceAnalysisKit';
389import { omapi } from '@kit.ConnectivityKit';
390
391let seReaders : omapi.Reader[];
392
393// Initialize seReaders before using it.
394
395try {
396    let reader = seReaders[0]; // change it to the selected reader, ese or sim.
397    let isPresent = reader.isSecureElementPresent();
398    hilog.info(0x0000, 'testTag', 'isPresent %{public}s', JSON.stringify(isPresent));
399} catch (error) {
400    hilog.error(0x0000, 'testTag', 'isSecureElementPresent error %{public}s', JSON.stringify(error));
401}
402```
403
404### Reader.openSession
405
406 openSession(): Session
407
408Opens a session to connect to an SE in this reader. Multiple sessions can be opened on a reader at the same time.
409
410**System capability**: SystemCapability.Communication.SecureElement
411
412**Return value**
413
414| **Type**| **Description**                      |
415| -------- | ------------------------------ |
416| [Session](#session)  | Session instance opened.|
417
418**Error codes**
419
420For details about error codes, see [SE Error Codes](errorcode-se.md).
421
422| ID| Error Message                        |
423| -------- | -------------------------------- |
424| 801  | Capability not supported. |
425| 3300101  | IllegalStateError, service state exception. |
426| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
427
428**Example**
429
430<!--code_no_check-->
431```js
432import { hilog } from '@kit.PerformanceAnalysisKit';
433import { omapi } from '@kit.ConnectivityKit';
434
435let seReaders : omapi.Reader[];
436let seSession : omapi.Session;
437
438// Initialize seReaders before using it.
439function secureElementDemo() {
440    try {
441        let reader = seReaders[0]; // change it to the selected reader, ese or sim.
442        seSession = reader.openSession();
443    } catch (error) {
444        hilog.error(0x0000, 'testTag', 'openSession error %{public}s', JSON.stringify(error));
445    }
446    if (seSession == undefined) {
447        hilog.error(0x0000, 'testTag', 'seSession invalid.');
448        return;
449    }
450}
451```
452
453### Reader.closeSessions
454
455 closeSessions(): void
456
457Closes all sessions opened on this reader. All channels opened by these sessions will be closed.
458
459**System capability**: SystemCapability.Communication.SecureElement
460
461**Error codes**
462
463For details about error codes, see [SE Error Codes](errorcode-se.md).
464
465| ID| Error Message                        |
466| -------- | -------------------------------- |
467| 801  | Capability not supported. |
468| 3300101  | IllegalStateError, service state exception. |
469
470**Example**
471
472<!--code_no_check-->
473```js
474import { hilog } from '@kit.PerformanceAnalysisKit';
475import { omapi } from '@kit.ConnectivityKit';
476
477let seReaders : omapi.Reader[];
478let seSession : omapi.Session;
479let reader : omapi.Reader;
480
481// Initialize seReaders before using it.
482function secureElementDemo() {
483    try {
484        reader = seReaders[0]; // change it to the selected reader, ese or sim.
485        seSession = reader.openSession();
486    } catch (error) {
487        hilog.error(0x0000, 'testTag', 'openSession error %{public}s', JSON.stringify(error));
488    }
489    if (seSession == undefined) {
490        hilog.error(0x0000, 'testTag', 'seSession invalid.');
491        return;
492    }
493    try {
494        reader.closeSessions();
495    } catch (error) {
496        hilog.error(0x0000, 'testTag', 'closeSessions error %{public}s', JSON.stringify(error));
497    }
498}
499```
500
501## Session
502
503A **Session** instance indicates a session created on an SE **Reader** instance. You can use [Reader.openSession](#readeropensession) to obtain a **Session** instance.
504
505### Session.getReader
506
507getReader(): Reader
508
509Obtains the reader that provides this session.
510
511**System capability**: SystemCapability.Communication.SecureElement
512
513**Return value**
514
515| **Type**| **Description**                   |
516| -------- | --------------------------- |
517| [Reader](#reader)   | Reader instance obtained.|
518
519**Error codes**
520
521For details about error codes, see [SE Error Codes](errorcode-se.md).
522
523| ID| Error Message                                 |
524| -------- | ----------------------------------------- |
525| 801  | Capability not supported. |
526
527**Example**
528
529<!--code_no_check-->
530```js
531import { hilog } from '@kit.PerformanceAnalysisKit';
532import { omapi } from '@kit.ConnectivityKit';
533
534let seReaders : omapi.Reader[];
535let seSession : omapi.Session;
536let reader : omapi.Reader;
537
538// Initialize seReaders before using it.
539function secureElementDemo() {
540    try {
541        reader = seReaders[0]; // change it to the selected reader, ese or sim.
542        seSession = reader.openSession();
543    } catch (error) {
544        hilog.error(0x0000, 'testTag', 'openSession error %{public}s', JSON.stringify(error));
545    }
546    if (seSession == undefined) {
547        hilog.error(0x0000, 'testTag', 'seSession invalid.');
548        return;
549    }
550    try {
551        let sessionReader = seSession.getReader();
552    } catch (error) {
553        hilog.error(0x0000, 'testTag', 'getReader error %{public}s', JSON.stringify(error));
554    }
555}
556```
557
558### Session.getATR
559
560getATR(): number[]
561
562Obtains the Answer to Reset (ATR) of this SE. If the ATR of this SE is not available, an empty array will be returned.
563
564**System capability**: SystemCapability.Communication.SecureElement
565
566**Return value**
567
568| **Type**| **Description**                                    |
569| -------- | -------------------------------------------- |
570| number[] | Returns the ATR obtained if the SE has an available ATR; returns an empty array otherwise.|
571
572**Error codes**
573
574For details about error codes, see [SE Error Codes](errorcode-se.md).
575
576| ID| Error Message                        |
577| -------- | -------------------------------- |
578| 801  | Capability not supported. |
579| 3300101  | IllegalStateError, service state exception. |
580
581**Example**
582
583<!--code_no_check-->
584```js
585import { hilog } from '@kit.PerformanceAnalysisKit';
586import { omapi } from '@kit.ConnectivityKit';
587
588let seSession : omapi.Session;
589
590// Initialize seSession before using it.
591
592try {
593    let atr = seSession.getATR();
594    hilog.info(0x0000, 'testTag', 'atr %{public}s', JSON.stringify(atr));
595} catch (error) {
596    hilog.error(0x0000, 'testTag', 'getATR error %{public}s', JSON.stringify(error));
597}
598```
599
600### Session.close
601
602close(): void
603
604Closes the session with the SE. All channels opened by this session will be closed.
605
606**System capability**: SystemCapability.Communication.SecureElement
607
608**Error codes**
609
610For details about error codes, see [SE Error Codes](errorcode-se.md).
611
612| ID| Error Message                        |
613| -------- | -------------------------------- |
614| 801  | Capability not supported. |
615| 3300101  | IllegalStateError, service state exception. |
616
617**Example**
618
619<!--code_no_check-->
620```js
621import { hilog } from '@kit.PerformanceAnalysisKit';
622import { omapi } from '@kit.ConnectivityKit';
623
624let seSession : omapi.Session;
625
626// Initialize seSession before using it.
627
628try {
629    seSession.close();
630} catch (error) {
631    hilog.error(0x0000, 'testTag', 'close error %{public}s', JSON.stringify(error));
632}
633```
634
635### Session. isClosed
636
637isClosed(): boolean
638
639Checks whether this session is closed.
640
641**System capability**: SystemCapability.Communication.SecureElement
642
643**Return value**
644
645| **Type**| **Description**                            |
646| -------- | ------------------------------------ |
647| boolean  | Returns **true** if the session is closed; returns **false** otherwise.|
648
649**Error codes**
650
651For details about error codes, see [SE Error Codes](errorcode-se.md).
652
653| ID| Error Message                                 |
654| -------- | ----------------------------------------- |
655| 801  | Capability not supported. |
656
657**Example**
658
659<!--code_no_check-->
660```Js
661import { hilog } from '@kit.PerformanceAnalysisKit';
662import { omapi } from '@kit.ConnectivityKit';
663
664let seSession : omapi.Session;
665
666// Initialize seSession before using it.
667
668try {
669    let isClosed = seSession.isClosed();
670    hilog.info(0x0000, 'testTag', 'isClosed %{public}s', JSON.stringify(isClosed));
671} catch (error) {
672    hilog.error(0x0000, 'testTag', 'isClosed error %{public}s', JSON.stringify(error));
673}
674```
675
676### Session.closeChannels
677
678closeChannels(): void
679
680Closes all channels opened on this session.
681
682**System capability**: SystemCapability.Communication.SecureElement
683
684**Error codes**
685
686For details about error codes, see [SE Error Codes](errorcode-se.md).
687
688| ID| Error Message                        |
689| -------- | -------------------------------- |
690|801 | Capability not supported.          |
691| 3300101  | IllegalStateError, service state exception. |
692
693**Example**
694
695<!--code_no_check-->
696```js
697import { hilog } from '@kit.PerformanceAnalysisKit';
698import { omapi } from '@kit.ConnectivityKit';
699
700let seSession : omapi.Session;
701
702// Initialize seSession before using it.
703
704try {
705    seSession.closeChannels();
706} catch (error) {
707    hilog.error(0x0000, 'testTag', 'closeChannels error %{public}s', JSON.stringify(error));
708}
709```
710
711### Session.openBasicChannel
712
713openBasicChannel(aid: number[]): Promise\<Channel>
714
715Opens a basic channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the basic channel or the application does not have the permission to access the SE, null is returned. This API uses a promise to return the result.
716
717**System capability**: SystemCapability.Communication.SecureElement
718
719**Parameters**
720
721| **Name**| **Type**| **Mandatory**| **Description**                                                    |
722| ---------- | -------- | ------ | ------------------------------------------------------------ |
723| aid        | number[] | Yes     |AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
724
725**Return value**
726
727| **Type**| **Description**             |
728| -------- | --------------------- |
729| Promise\<[Channel](#channel)>  | Promise used to return the basic channel instance obtained.|
730
731**Error codes**
732
733For details about error codes, see [SE Error Codes](errorcode-se.md).
734
735| ID| Error Message                        |
736| -------- | -------------------------------- |
737|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
738|801 | Capability not supported.          |
739| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
740| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected.       |
741| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
742| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
743
744**Example**
745
746<!--code_no_check-->
747```js
748import { hilog } from '@kit.PerformanceAnalysisKit';
749import { omapi } from '@kit.ConnectivityKit';
750
751let seSession : omapi.Session;
752let seChannel : omapi.Channel;
753let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
754
755// Initialize seSession before using it.
756function secureElementDemo() {
757    try {
758        // Change the AID value for the channel to open.
759        seSession.openBasicChannel(aidArray).then((data) => {
760            seChannel = data;
761        }).catch((error : BusinessError)=> {
762            hilog.error(0x0000, 'testTag', 'openBasicChannel error %{public}s', JSON.stringify(error));
763        });
764    } catch (exception) {
765        hilog.error(0x0000, 'testTag', 'openBasicChannel exception %{public}s', JSON.stringify(exception));
766    }
767    if (seChannel == undefined) {
768        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
769        return;
770    }
771}
772```
773
774### Session.openBasicChannel
775
776 openBasicChannel(aid: number[], callback: AsyncCallback\<Channel>): void
777
778Opens a basic channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the basic channel or the application does not have the permission to access the SE, null is returned. This API uses an asynchronous callback to return the result.
779
780**System capability**: SystemCapability.Communication.SecureElement
781
782**Parameters**
783
784| **Name**| **Type**              | **Mandatory**| **Description**                                                    |
785| ---------- | ---------------------- | ------ | ------------------------------------------------------------ |
786| aid        | number[]               | Yes     | AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
787| callback   | AsyncCallback\<[Channel](#channel)> | Yes     | Callback used to return the basic channel instance obtained.                           |
788
789**Error codes**
790
791For details about error codes, see [SE Error Codes](errorcode-se.md).
792
793| ID| Error Message                        |
794| -------- | -------------------------------- |
795|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
796|801 | Capability not supported.          |
797| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
798| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected.       |
799| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
800| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
801
802**Example**
803
804<!--code_no_check-->
805```js
806import { hilog } from '@kit.PerformanceAnalysisKit';
807import { omapi } from '@kit.ConnectivityKit';
808
809let seSession : omapi.Session;
810let seChannel : omapi.Channel;
811let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
812
813// Initialize seSession before using it.
814function secureElementDemo() {
815    try {
816        // Change the AID value for the channel to open.
817        seSession.openBasicChannel(aidArray, (error, data) => {
818            if (error) {
819                hilog.error(0x0000, 'testTag', 'openBasicChannel error %{public}s', JSON.stringify(error));
820            } else {
821                seChannel = data;
822            }
823        });
824    } catch (exception) {
825        hilog.error(0x0000, 'testTag', 'openBasicChannel exception %{public}s', JSON.stringify(exception));
826    }
827    if (seChannel == undefined) {
828        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
829        return;
830    }
831}
832```
833
834### Session.openBasicChannel
835
836openBasicChannel(aid: number[], p2: number): Promise\<Channel>
837
838Opens a basic channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the basic channel or the application does not have the permission to access the SE, null is returned. This API uses a promise to return the result.
839
840**System capability**: SystemCapability.Communication.SecureElement
841
842**Parameters**
843
844| **Name**| **Type**| **Mandatory**| **Description**                                                    |
845| ---------- | -------- | ------ | ------------------------------------------------------------ |
846| aid        | number[] | Yes      | AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
847| p2         | number   | Yes      |P2 parameter of the **SELECT APDU** command executed on this channel.                    |
848
849**Return value**
850
851| **Type**| **Description**             |
852| -------- | --------------------- |
853| Promise\<[Channel](#channel)>  | Promise used to return the basic channel instance obtained.|
854
855**Error codes**
856
857For details about error codes, see [SE Error Codes](errorcode-se.md).
858
859| ID| Error Message                        |
860| -------- | -------------------------------- |
861|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
862|801 | Capability not supported.          |
863| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
864| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected.       |
865| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
866| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
867
868**Example**
869
870<!--code_no_check-->
871```js
872import { hilog } from '@kit.PerformanceAnalysisKit';
873import { omapi } from '@kit.ConnectivityKit';
874
875let seSession : omapi.Session;
876let seChannel : omapi.Channel;
877let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
878let p2 : number = 0x00;
879
880// Initialize seSession before using it.
881function secureElementDemo() {
882    try {
883        // Change the AID value for the channel to open.
884        seSession.openBasicChannel(aidArray, p2).then((data) => {
885            seChannel = data;
886        }).catch((error : BusinessError)=> {
887            hilog.error(0x0000, 'testTag', 'openBasicChannel error %{public}s', JSON.stringify(error));
888        });
889    } catch (exception) {
890        hilog.error(0x0000, 'testTag', 'openBasicChannel exception %{public}s', JSON.stringify(exception));
891    }
892    if (seChannel == undefined) {
893        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
894        return;
895    }
896}
897```
898
899### Session.openBasicChannel
900
901openBasicChannel(aid: number[], p2:number, callback: AsyncCallback\<Channel>): void
902
903Opens a basic channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the basic channel or the application does not have the permission to access the SE, null is returned. This API uses an asynchronous callback to return the result.
904
905**System capability**: SystemCapability.Communication.SecureElement
906
907**Parameters**
908
909| **Name**| **Type**              | **Mandatory**| **Description**                                                    |
910| ---------- | ---------------------- | ------ | ------------------------------------------------------------ |
911| aid        | number[]               | Yes     | AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
912| p2         | number                 | Yes     | P2 parameter of the **SELECT APDU** command executed on this channel.                    |
913| callback   | AsyncCallback\<[Channel](#channel)> | Yes     | Callback used to return the basic channel instance obtained.                           |
914
915**Error codes**
916
917For details about error codes, see [SE Error Codes](errorcode-se.md).
918
919| ID| Error Message                        |
920| -------- | -------------------------------- |
921|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
922|801 | Capability not supported.          |
923| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
924| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected.      |
925| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
926| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
927
928**Example**
929
930<!--code_no_check-->
931```js
932import { hilog } from '@kit.PerformanceAnalysisKit';
933import { omapi } from '@kit.ConnectivityKit';
934
935let seSession : omapi.Session;
936let seChannel : omapi.Channel;
937let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
938let p2 : number = 0x00;
939
940// Initialize seSession before using it.
941function secureElementDemo() {
942    try {
943        // Change the AID value for the channel to open.
944        seSession.openBasicChannel(aidArray, p2, (error, data) => {
945            if (error) {
946                hilog.error(0x0000, 'testTag', 'openBasicChannel error %{public}s', JSON.stringify(error));
947            } else {
948                seChannel = data;
949            }
950        });
951    } catch (exception) {
952        hilog.error(0x0000, 'testTag', 'openBasicChannel exception %{public}s', JSON.stringify(exception));
953    }
954    if (seChannel == undefined) {
955        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
956        return;
957    }
958}
959```
960
961### Session.openLogicalChannel
962
963openLogicalChannel(aid: number[]): Promise\<Channel>
964
965Opens a logical channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the logical channel or the application does not have the permission to access the SE, null is returned. This API uses a promise to return the result.
966
967**System capability**: SystemCapability.Communication.SecureElement
968
969**Parameters**
970
971| **Name**| **Type**| **Mandatory**| **Description**                               |
972| ---------- | -------- | ------ | --------------------------------------- |
973| aid        | number[] | Yes     | AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
974
975**Return value**
976
977| **Type**| **Description**                                                    |
978| -------- | ------------------------------------------------------------ |
979| Promise\<[Channel](#channel)>  | Promise used to return the logical channel instance obtained.|
980
981**Error codes**
982
983For details about error codes, see [SE Error Codes](errorcode-se.md).
984
985| ID| Error Message                        |
986| -------- | -------------------------------- |
987|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
988|801 | Capability not supported.          |
989| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
990| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected or a logical channel is already open to a non-multi-selectable applet.      |
991| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
992| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
993
994**Example**
995
996<!--code_no_check-->
997```js
998import { hilog } from '@kit.PerformanceAnalysisKit';
999import { omapi } from '@kit.ConnectivityKit';
1000
1001let seSession : omapi.Session;
1002let seChannel : omapi.Channel;
1003let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
1004
1005// Initialize seSession before using it.
1006function secureElementDemo() {
1007    try {
1008        // Change the AID value for the channel to open.
1009        seSession.openLogicalChannel(aidArray).then((data) => {
1010            seChannel = data;
1011        }).catch((error : BusinessError)=> {
1012            hilog.error(0x0000, 'testTag', 'openLogicalChannel error %{public}s', JSON.stringify(error));
1013        });
1014    } catch (exception) {
1015        hilog.error(0x0000, 'testTag', 'openLogicalChannel exception %{public}s', JSON.stringify(exception));
1016    }
1017    if (seChannel == undefined) {
1018        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
1019        return;
1020    }
1021}
1022```
1023
1024### Session.openLogicalChannel
1025
1026 openLogicalChannel(aid: number[], callback: AsyncCallback\<Channel>): void
1027
1028Opens a logical channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the logical channel or the application does not have the permission to access the SE, null is returned. This API uses an asynchronous callback to return the result.
1029
1030**System capability**: SystemCapability.Communication.SecureElement
1031
1032**Parameters**
1033
1034| **Name**| **Type**              | **Mandatory**| **Description**                                                    |
1035| ---------- | ---------------------- | ------ | ------------------------------------------------------------ |
1036| aid        | number[]               | Yes     | AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
1037| callback   | AsyncCallback\<[Channel](#channel)> | Yes     | Callback used to return the logical channel instance obtained.|
1038
1039**Error codes**
1040
1041For details about error codes, see [SE Error Codes](errorcode-se.md).
1042
1043| ID| Error Message                        |
1044| -------- | -------------------------------- |
1045|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
1046|801 | Capability not supported.          |
1047| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
1048| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected or a logical channel is already open to a non-multi-selectable applet.      |
1049| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
1050| 3300104  | IOError, there is a communication problem to the reader or the SE.    |
1051
1052**Example**
1053
1054<!--code_no_check-->
1055```js
1056import { hilog } from '@kit.PerformanceAnalysisKit';
1057import { omapi } from '@kit.ConnectivityKit';
1058
1059let seSession : omapi.Session;
1060let seChannel : omapi.Channel;
1061let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
1062
1063// Initialize seSession before using it.
1064function secureElementDemo() {
1065    try {
1066        // Change the AID value for the channel to open.
1067        seSession.openLogicalChannel(aidArray, (error, data) => {
1068            if (error) {
1069                hilog.error(0x0000, 'testTag', 'openLogicalChannel error %{public}s', JSON.stringify(error));
1070            } else {
1071                seChannel = data;
1072            }
1073        });
1074    } catch (exception) {
1075        hilog.error(0x0000, 'testTag', 'openLogicalChannel exception %{public}s', JSON.stringify(exception));
1076    }
1077    if (seChannel == undefined) {
1078        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
1079        return;
1080    }
1081}
1082```
1083
1084### Session.openLogicalChannel
1085
1086openLogicalChannel(aid: number[], p2: number): Promise\<Channel>
1087
1088Opens a logical channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the logical channel or the application does not have the permission to access the SE, null is returned. This API uses a promise to return the result.
1089
1090**System capability**: SystemCapability.Communication.SecureElement
1091
1092**Parameters**
1093
1094| **Name**| **Type**| **Mandatory**| **Description**                                 |
1095| ---------- | -------- | ------ | ----------------------------------------- |
1096| aid        | number[] | Yes     | AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
1097| p2         | number   | Yes     | P2 parameter of the **SELECT APDU** command executed on this channel. |
1098
1099**Return value**
1100
1101| **Type**| **Description**      |
1102| -------- | -------------- |
1103| Promise\<[Channel](#channel)> | Promise used to return the logical channel instance obtained.|
1104
1105**Error codes**
1106
1107For details about error codes, see [SE Error Codes](errorcode-se.md).
1108
1109| ID| Error Message                        |
1110| -------- | -------------------------------- |
1111|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
1112|801 | Capability not supported.          |
1113| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
1114| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected or a logical channel is already open to a non-multi-selectable applet.      |
1115| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
1116| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
1117
1118**Example**
1119
1120<!--code_no_check-->
1121```js
1122import { hilog } from '@kit.PerformanceAnalysisKit';
1123import { omapi } from '@kit.ConnectivityKit';
1124
1125let seSession : omapi.Session;
1126let seChannel : omapi.Channel;
1127let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
1128let p2 : number = 0x00;
1129
1130// Initialize seSession before using it.
1131function secureElementDemo() {
1132    try {
1133        // Change the AID value for the channel to open.
1134        seSession.openLogicalChannel(aidArray, p2).then((data) => {
1135            seChannel = data;
1136        }).catch((error : BusinessError)=> {
1137            hilog.error(0x0000, 'testTag', 'openLogicalChannel error %{public}s', JSON.stringify(error));
1138        });
1139    } catch (exception) {
1140        hilog.error(0x0000, 'testTag', 'openLogicalChannel exception %{public}s', JSON.stringify(exception));
1141    }
1142    if (seChannel == undefined) {
1143        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
1144        return;
1145    }
1146}
1147```
1148
1149### Session.openLogicalChannel
1150
1151openLogicalChannel(aid: number[], p2: number, callback: AsyncCallback\<Channel>):void
1152
1153Opens a logical channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the logical channel or the application does not have the permission to access the SE, null is returned. This API uses an asynchronous callback to return the result.
1154
1155**System capability**: SystemCapability.Communication.SecureElement
1156
1157**Parameters**
1158
1159| **Name**| **Type**              | **Mandatory**| **Description**                                                    |
1160| ---------- | ---------------------- | ------ | ------------------------------------------------------------ |
1161| aid        | number[]               | Yes     | AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
1162| p2         | number                 | Yes     | P2 parameter of the **SELECT APDU** command executed on this channel.|
1163| callback   | AsyncCallback\<[Channel](#channel)> | Yes     | Callback used to return the logical channel instance obtained.|
1164
1165**Error codes**
1166
1167For details about error codes, see [SE Error Codes](errorcode-se.md).
1168
1169| ID| Error Message                        |
1170| -------- | -------------------------------- |
1171|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
1172|801 | Capability not supported.          |
1173| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
1174| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected or a logical channel is already open to a non-multi-selectable applet.       |
1175| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
1176| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
1177
1178**Example**
1179
1180<!--code_no_check-->
1181```js
1182import { hilog } from '@kit.PerformanceAnalysisKit';
1183import { omapi } from '@kit.ConnectivityKit';
1184
1185let seSession : omapi.Session;
1186let seChannel : omapi.Channel;
1187let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
1188let p2 : number = 0x00;
1189
1190// Initialize seSession before using it.
1191function secureElementDemo() {
1192    try {
1193    // Change the AID value for the channel to open.
1194        seSession.openLogicalChannel(aidArray, p2, (error, data) => {
1195            if (error) {
1196                hilog.error(0x0000, 'testTag', 'openLogicalChannel error %{public}s', JSON.stringify(error));
1197            } else {
1198                seChannel = data;
1199            }
1200        });
1201    } catch (exception) {
1202        hilog.error(0x0000, 'testTag', 'openLogicalChannel exception %{public}s', JSON.stringify(exception));
1203    }
1204    if (seChannel == undefined) {
1205        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
1206        return;
1207    }
1208}
1209```
1210## Channel
1211
1212A **Channel** instance indicates a channel set up by a **Session** instance. The channel can be a basic channel or a logical channel. You can use [Session.openBasicChannel](#sessionopenbasicchannel) or [Session.openLogicalChannel](#sessionopenlogicalchannel) to obtain a channel instance.
1213
1214### Channel.getSession
1215
1216 getSession(): Session
1217
1218Obtains the session used to open this channel.
1219
1220**System capability**: SystemCapability.Communication.SecureElement
1221
1222**Return value**
1223
1224| **Type**| **Description**                     |
1225| -------- | ----------------------------- |
1226| [Session](#session)  | Session instance obtained.|
1227
1228**Error codes**
1229
1230For details about error codes, see [SE Error Codes](errorcode-se.md).
1231
1232| ID| Error Message                                 |
1233| -------- | ----------------------------------------- |
1234| 801  | Capability not supported. |
1235
1236**Example**
1237
1238<!--code_no_check-->
1239```js
1240import { hilog } from '@kit.PerformanceAnalysisKit';
1241import { omapi } from '@kit.ConnectivityKit';
1242
1243let seSession : omapi.Session;
1244let seChannel : omapi.Channel;
1245
1246// Initialize seChannel before using it.
1247
1248try {
1249    seSession = seChannel.getSession();
1250} catch (exception) {
1251    hilog.error(0x0000, 'testTag', 'getSession exception %{public}s', JSON.stringify(exception));
1252}
1253```
1254
1255### Channel.close
1256
1257close(): void
1258
1259Closes this channel.
1260
1261**System capability**: SystemCapability.Communication.SecureElement
1262
1263**Error codes**
1264
1265For details about error codes, see [SE Error Codes](errorcode-se.md).
1266
1267| ID| Error Message                                 |
1268| -------- | ----------------------------------------- |
1269| 801  | Capability not supported. |
1270
1271**Example**
1272
1273<!--code_no_check-->
1274```js
1275import { hilog } from '@kit.PerformanceAnalysisKit';
1276import { omapi } from '@kit.ConnectivityKit';
1277
1278let seChannel : omapi.Channel;
1279
1280// Initialize seChannel before using it.
1281
1282try {
1283    seChannel.close();
1284} catch (exception) {
1285    hilog.error(0x0000, 'testTag', 'close exception %{public}s', JSON.stringify(exception));
1286}
1287```
1288
1289### Channel.isBasicChannel
1290
1291isBasicChannel(): boolean
1292
1293Checks whether this channel is a basic channel.
1294
1295**System capability**: SystemCapability.Communication.SecureElement
1296
1297**Return value**
1298
1299| **Type**| **Description**                                                    |
1300| -------- | ------------------------------------------------------------ |
1301| boolean  | Returns **true** if the channel is a basic channel; returns **false** otherwise.|
1302
1303**Error codes**
1304
1305For details about error codes, see [SE Error Codes](errorcode-se.md).
1306
1307| ID| Error Message                                 |
1308| -------- | ----------------------------------------- |
1309| 801  | Capability not supported. |
1310
1311**Example**
1312
1313<!--code_no_check-->
1314```js
1315import { hilog } from '@kit.PerformanceAnalysisKit';
1316import { omapi } from '@kit.ConnectivityKit';
1317
1318let seChannel : omapi.Channel;
1319
1320// Initialize seChannel before using it.
1321
1322try {
1323    let isBasic = seChannel.isBasicChannel();
1324    hilog.info(0x0000, 'testTag', 'isBasic = %{public}s', JSON.stringify(isBasic));
1325} catch (exception) {
1326    hilog.error(0x0000, 'testTag', 'isBasicChannel exception %{public}s', JSON.stringify(exception));
1327}
1328```
1329
1330### Channel.isClosed
1331
1332isClosed(): boolean
1333
1334Checks whether this channel is closed.
1335
1336**System capability**: SystemCapability.Communication.SecureElement
1337
1338**Return value**
1339
1340| **Type**| **Description**                                     |
1341| -------- | --------------------------------------------- |
1342| boolean  | Returns **true** if the channel is closed; returns **false** otherwise.|
1343
1344**Error codes**
1345
1346For details about error codes, see [SE Error Codes](errorcode-se.md).
1347
1348| ID| Error Message                                 |
1349| -------- | ----------------------------------------- |
1350| 801  | Capability not supported. |
1351
1352**Example**
1353
1354<!--code_no_check-->
1355```js
1356import { hilog } from '@kit.PerformanceAnalysisKit';
1357import { omapi } from '@kit.ConnectivityKit';
1358
1359let seChannel : omapi.Channel;
1360
1361// Initialize seChannel before using it.
1362
1363try {
1364    let isClosed = seChannel.isClosed();
1365    hilog.info(0x0000, 'testTag', 'isClosed = %{public}s', JSON.stringify(isClosed));
1366} catch (exception) {
1367    hilog.error(0x0000, 'testTag', 'isClosed exception %{public}s', JSON.stringify(exception));
1368}
1369```
1370
1371### Channel.getSelectResponse
1372
1373getSelectResponse(): number[]
1374
1375Obtains the response data including the status word of **SELECT Applet**.
1376
1377**System capability**: SystemCapability.Communication.SecureElement
1378
1379**Return value**
1380
1381| **Type**| **Description**                                                    |
1382| -------- | ------------------------------------------------------------ |
1383| number[] | Response data including the status word obtained.|
1384
1385**Error codes**
1386
1387For details about error codes, see [SE Error Codes](errorcode-se.md).
1388
1389| ID| Error Message                                 |
1390| -------- | ----------------------------------------- |
1391| 801  | Capability not supported. |
1392
1393**Example**
1394
1395<!--code_no_check-->
1396```js
1397import { hilog } from '@kit.PerformanceAnalysisKit';
1398import { omapi } from '@kit.ConnectivityKit';
1399
1400let seChannel : omapi.Channel;
1401
1402// Initialize seChannel before using it.
1403
1404try {
1405    let response = seChannel.getSelectResponse();
1406    hilog.info(0x0000, 'testTag', 'response = %{public}s', JSON.stringify(response));
1407} catch (exception) {
1408    hilog.error(0x0000, 'testTag', 'getSelectResponse exception %{public}s', JSON.stringify(exception));
1409}
1410```
1411
1412### Channel.transmit
1413
1414transmit(command: number[]): Promise\<number[]>
1415
1416Transmits APDU data (as per ISO/IEC 7816) to the SE. This API uses a promise to return the result.
1417
1418**System capability**: SystemCapability.Communication.SecureElement
1419
1420**Parameters**
1421
1422| **Name**| **Type**| **Mandatory**| **Description**                             |
1423| ---------- | -------- | ------ | ------------------------------------- |
1424| command    | number[] | Yes     | APDU data to send.|
1425
1426**Return value**
1427
1428| **Type**| **Description**      |
1429| -------- | -------------- |
1430| Promise\<number[]> | Promise used to return the response received, in a number array.|
1431
1432**Error codes**
1433
1434For details about error codes, see [SE Error Codes](errorcode-se.md).
1435
1436| ID| Error Message                        |
1437| -------- | -------------------------------- |
1438|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
1439|801 | Capability not supported.          |
1440| 3300101  | IllegalStateError, an attempt is made to use an SE session or channel that has been closed. |
1441| 3300103  | SecurityError, the command is filtered by the security policy. |
1442| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
1443
1444**Example**
1445
1446<!--code_no_check-->
1447```js
1448import { hilog } from '@kit.PerformanceAnalysisKit';
1449import { omapi } from '@kit.ConnectivityKit';
1450
1451let seChannel : omapi.Channel;
1452
1453// Initialize seChannel before using it.
1454
1455let cmdData = [0x01, 0x02, 0x03, 0x04]; // Change the raw data as required.
1456try {
1457    seChannel.transmit(cmdData).then((response) => {
1458        hilog.info(0x0000, 'testTag', 'transmit response = %{public}s.', JSON.stringify(response));
1459    }).catch((error : BusinessError) => {
1460        hilog.error(0x0000, 'testTag', 'transmit error = %{public}s.', JSON.stringify(error));
1461    });
1462} catch (exception) {
1463    hilog.error(0x0000, 'testTag', 'transmit exception = %{public}s.', JSON.stringify(exception));
1464}
1465```
1466
1467### Channel.transmit
1468
1469transmit(command: number[], callback: AsyncCallback\<number[]>): void
1470
1471Transmits APDU data (as per ISO/IEC 7816) to the SE. This API uses an asynchronous callback to return the result.
1472
1473**System capability**: SystemCapability.Communication.SecureElement
1474
1475**Parameters**
1476
1477| **Name**| **Type**               | **Mandatory**| **Description**                             |
1478| ---------- | ----------------------- | ------ | ------------------------------------- |
1479| command    | number[]                | Yes     | APDU data to send.|
1480| callback   | AsyncCallback\<number[]> | Yes     | Callback used to return the response received, in a number array. |
1481
1482**Error codes**
1483
1484For details about error codes, see [SE Error Codes](errorcode-se.md).
1485
1486| ID| Error Message                        |
1487| -------- | -------------------------------- |
1488|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
1489|801 | Capability not supported.          |
1490| 3300101  | IllegalStateError, an attempt is made to use an SE session or channel that has been closed. |
1491| 3300103  | SecurityError, the command is filtered by the security policy. |
1492| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
1493
1494**Example**
1495
1496<!--code_no_check-->
1497```js
1498import { hilog } from '@kit.PerformanceAnalysisKit';
1499import { omapi } from '@kit.ConnectivityKit';
1500
1501let seChannel : omapi.Channel;
1502
1503// Initialize seChannel before using it.
1504
1505let cmdData = [0x01, 0x02, 0x03, 0x04]; // Change the raw data as required.
1506try {
1507    seChannel.transmit(cmdData, (error, response) => {
1508    if (error) {
1509        hilog.error(0x0000, 'testTag', 'transmit error %{public}s', JSON.stringify(error));
1510    } else {
1511        hilog.info(0x0000, 'testTag', 'transmit response = %{public}s.', JSON.stringify(response));
1512    }
1513    });
1514} catch (exception) {
1515    hilog.error(0x0000, 'testTag', 'transmit exception %{public}s', JSON.stringify(exception));
1516}
1517```
1518