# Exemplos

Os exemplos mostrados abaixo, visam criar uma familiaridade do módulo juntamente com os principais comandos envolvidos durante uma operação na Rede LoRaWAN.

### 1 - Testando a comunicação com o módulo:

Comando:

```
AT
```

Saída:

```
OK
```

### 2 - Reiniciando o módulo:

Comando:

```
ATZ
```

Saída:

```
MCU: TYPE-A
ATtention command interface
OTAA Mode enabled
DevEui= E4:A0:32:9B:C0:0C:15:F5
JoinEui= 01:01:01:01:01:01:01:01
AppKey= 2B:7E:15:16:28:AE:D2:A6:AB:F7:15:88:09:CF:4F:3C

```

### 3 - Restaurando o módulo para configurações de fábrica:

Comando:

```
AT+DEFLT
```

Saída

```
E7:D8:3F:61:15:93:63:19OTAA Mode enabled
DevEui= E4:A0:32:9B:C0:0C:15:F5
JoinEui= 01:01:01:01:01:01:01:01
AppKey= 2B:7E:15:16:28:AE:D2:A6:AB:F7:15:88:09:CF:4F:3C


OK
```

### 4 - Configurações iniciais do módulo:

#### 4.1 - Definindo uma nova chave de segurança(App Key):

Comando:

```
AT+APPKEY=2B:7E:15:16:28:AE:D2:A6:AB:F7:15:88:09:CF:4F:3C   
```

Saída:

```
OK
```

### 5 - Realizando JOIN na rede LoRaWAN

#### 5.1 - Modo OTAA

Comando:

```
AT+JOIN
```

Saída:

```
OK
JOINED
```

{% hint style="info" %}
Por padrão, o módulo LoRa já vem configurado em modo OTAA.
{% endhint %}

#### 5.2 Modo ABP

* Trocando o modo de autenticação para ABP

Comando:

```
AT+NJM=0
```

Saída:

```
ABP Mode enabled
DevEui= 00:05:16:80:00:11:55:5C
DevAdd=  01F9B4E4
NwkSKey= 2B:7E:15:16:28:AE:D2:A6:AB:F7:15:88:09:CF:4F:3C
AppSKey= 2B:7E:15:16:28:AE:D2:A6:AB:F7:15:88:09:CF:4F:3C


OK
```

* Salvar as configurações

Comando:

```
AT+SAVE
```

Saída:

```
OK
```

{% hint style="warning" %}
Quando o dispositivo entra modo ABP, não é preciso efetuar o JOIN na rede. Caso você execute o comando **AT+JOIN**, perceberá que receberá o retorno **AT\_ERROR**.
{% endhint %}

Para finalizar, reinicie o módulo.

### 6 - Envio de Uplinks

#### 6.1 - Payload plain text

Comando:

```
AT+SEND=1:Hello
```

Saída:

```
OK
```

#### 6.2 - Payload binária

Comando:

```
AT+SENDB=1:01
```

Saída:

```
OK
```

### 7 - Envio de Uplinks Confirmados

#### 7.1 - Configurando Mensagem Confirmada

Comando:

```
AT+CFM=1
```

Saída:

```
OK
```

#### 7.2 - Enviando Uplink

Comando:

```
AT+SENDB=1:01
```

Saída:

```
OK
Network Server "ack" an uplink data confirmed message transmission
```

### 8 - Recebimento de Downlinks

#### 8.1 - Sem Downlinks para serem recebidos:

Comando:

```
AT+RECVB
```

Saída:

```
0:

OK
```

#### 9.1 - Com Downlinks para serem recebidos:

Comando:

```
AT+RECVB
```

Saída:

```
6:0102

OK
```

### 10 - Dispositivo em Classe C:

#### 10.1 - Alterando a classe do módulo para Class C:

Comando:

```
AT+CLASS=C
```

Saída:

```
switch to class C done


OK
```

#### 10.2 - Salvando as configurações:

Comando:

```
AT+SAVE
```

Saída:

```
OK
```

#### 10.3 - Reiniciando o módulo

Comando:

```
ATZ
```

#### 10.4 - Efetuando o Join na Rede:

Comando:

```
AT+JOIN
```

Saída:

```
OK
JOINED
switch to class C done
```

### 11 - Salvando configurações na memória do módulo

Comando:

```
AT+SAVE
```

Saída:

```
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://devkit-lorawan.douglaszuqueto.com/comandos-at/exemplos.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.
