Hello Everyone,
I am new to LPWAN technology, but I have read and Learned about it and I bought Rak 3172-e evaluation board. Now, I want to connect this evaluation board to external microcontroller (Cypress Microcontroller), and send the AT commands through UART to rak 3172 module. Is there, any reference mannual availabe for, how to connect RAK3172-E with external micro-controller, and comminicate through UART? OR, if there is no refernece mannual, How the hardware connection should be?
Below, I am attaching the code, which I tried to implement through Psoc Creater IDE for Cypress Microcontroller:
#include "project.h"
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#define UART_BUFFER_SIZE 256
char uartBuffer[UART_BUFFER_SIZE];
// Function to send an AT command over UART
void sendATCommand(const char* command)
{
UART_PutString(command);
UART_PutString("\r\n");
}
// Function to receive data from UART
void receiveUARTData()
{
uint8_t byte;
uint16_t index = 0;
while (UART_GetRxBufferSize() > 0 && index < UART_BUFFER_SIZE - 1)
{
byte = UART_GetByte();
uartBuffer[index++] = (char)byte;
}
uartBuffer[index] = '\0'; // Null-terminate the received data
}
// Function to check if a specific response is received
bool checkResponse(const char* response)
{
return (strstr(uartBuffer, response) != NULL);
}
int main(void)
{
__enable_irq(); // Enable global interrupts
CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start();
// Send AT command
sendATCommand("AT");
while (1)
{
if (UART_GetRxBufferSize() > 0)
{
receiveUARTData();
// Check if "OK" response is received
if (checkResponse("OK"))
{
// Handle "OK" response
// Do something here when "OK" is received
Pin_1_Write(1u);
CyDelay(1000);
Pin_1_Write(0u);
break; // Exit the loop and move to the next step or state
}
}
CyDelay(100);
}
// Continue with the next steps or states
for (;;)
{
// Implement your main program logic here
}
}
/* [] END OF FILE */
Can anyone please help me?
Thanks in advance