# Network selection

Here we will discuss how to perform:

* Operator selection
* Check current network
* Check available networks

## Operator selection <a href="#atcommands-networkselection-operatorselection" id="atcommands-networkselection-operatorselection"></a>

To force a SIM to a network, we can use the following AT command:

{% hint style="info" %}
AT+COPS=\<mode>,\<format>,\<operator>
{% endhint %}

Here **\<mode>** determines if the network selection is done automatically or forced to a network specified in **\<operator>** using the format specified in **\<format>**.

Possible values for **\<mode>** are as follows:

| **\<mode>** | **Meaning**                                                                                                                    | **Actions**                                                                                     |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- |
| 0           | Automatic selection (**\<operator>** field is ignored)                                                                         | SIM will connect to any operator                                                                |
| 1           | Manual selection (**\<operator>** field is mandatory)                                                                          | SIM will only connect to the operator specified                                                 |
| 2           | Deregister from network                                                                                                        | SIM will not connect to any operator                                                            |
| 3           | Sets the **\<format>** for the read command +COPS? (**\<operator>** field is ignored)                                          | No attempt to connect/ disconnect                                                               |
| 4           | Manual selection, if possible (**\<operator>** field is required). Switches to automatic (\<mode>=0) if manual selection fails | SIM will attempt to connect to the operator specified and switch to any operator if that fails. |

Possible values for **\<format>** are as follows:

| **\<format>** | **Meaning**                                                                             |
| ------------- | --------------------------------------------------------------------------------------- |
| 0             | **\<loperator>** Long format alphanumeric (E.g. T-Mobile USA)                           |
| 1             | **\<soperator>** Short format alphanumeric (E.g. TMO)                                   |
| 2             | **\<noperator>** Numeric (E.g. 310260) which is the Country and Network code (MCC, MNC) |

The **\<operator>** can be retrieved from the result of a AT+COPS=? to check available networks.

Some examples below of how to perform operator selection in various modes/ formats.

```xml
// Manual network selection with Long format alphanumeric format
AT+COPS=1,0,"TMO"
OK 

// Manual network selection with Short format alphanumeric format
AT+COPS=1,1,"T-Mobile USA"
OK 

// Manual network selection with Numeric format
AT+COPS=1,2,"310260"
OK 

// Deregister from network
AT+COPS=2
OK
```

## Check current network

To check the network registration status of the SIM, we can use the following AT command:

{% hint style="info" %}
AT+COPS?
{% endhint %}

This command returns the current **\<mode>** and currently selected operator. If operator is not selected the **\<operator>** and **\<format>** are omitted. The results of the command could be as follows:

<table data-header-hidden><thead><tr><th width="237.92299684074038"></th><th></th></tr></thead><tbody><tr><td><strong>&#x3C;mode></strong></td><td><strong>Meaning</strong></td></tr><tr><td>0</td><td>Automatic selection, registered to network if <strong>&#x3C;operator></strong> and <strong>&#x3C;format></strong> are present</td></tr><tr><td>1</td><td>Manual selection, registered to network if <strong>&#x3C;operator></strong> and <strong>&#x3C;format></strong> are present</td></tr><tr><td>2</td><td>Deregistered from network</td></tr><tr><td>4</td><td>Manual selection, if possible, registered to network if <strong>&#x3C;operator></strong> and <strong>&#x3C;format></strong> are present</td></tr></tbody></table>

Examples below:

```
// Registered to GSM network with automatic operator selection
AT+COPS?
+COPS: 0,0,"AT&T"
OK 

// Registered to GSM network with manual operator selection
AT+COPS?
+COPS: 1,0,"AT&T"
OK 

// Not registered to GSM network
AT+COPS?
+COPS: 2
OK
```

## Check available networks <a href="#atcommands-fplmn-checkavailablenetworks" id="atcommands-fplmn-checkavailablenetworks"></a>

To scan and report visible networks the network registration status of the SIM, we can use the following AT command:

{% hint style="info" %}
AT+COPS=?
{% endhint %}

This command returns a list of quadruplets, each representing an operator present on GSM network followed by a list of supported modes and formats.

The quadruplet consists of:

{% hint style="info" %}
+COPS: \<status>,\<loperator>,\<soperator>,\<noperator>
{% endhint %}

where the status carries the following meaning:

| **Status** | **Meaning** |
| ---------- | ----------- |
| 0          | Unknown     |
| 1          | Available   |
| 2          | Current     |
| 3          | Forbidden   |

Examples below:

```xml
// Currently on AT&T and T-Mobile is available
AT=COPS=?
+COPS: (2,"AT&T","AT&T","310410"),(1,"T-Mobile USA","TMO","310260"),(0,1,4),(0,1,2)
OK 

// Currently on AT&T and T-Mobile is forbidden
AT=COPS=?
+COPS: (2,"AT&T","AT&T","310410"),(3,"T-Mobile USA","TMO","310260"),(0,1,4),(0,1,2)
OK

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.connectedyou.io/knowledge-base/devices/at-commands/network-selection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
