ESP32 - NFC Peer to Peer with Android Device

stevenesp
Posts: 1
Joined: Wed Jul 31, 2019 1:12 pm

ESP32 - NFC Peer to Peer with Android Device

Postby stevenesp » Wed Jul 31, 2019 1:19 pm

Dear ESP team I have an enquiry and hoping to get some help from the experts!

I connected my microcontroller with Elechouse NFC (https://www.elechouse.com/elechouse/ind ... fp87gk9bm0)
and succesfully read tags and transferred data to a mobile application.

Using Peer to Peer i can transfer fine using the following code(android beam) data less than 300 bytes, but for my project I need to be able to transfer up to 3-4kb of data to the phone.
Is there any limitation? Is there any way I can change this to transfer NDEFMessages of 3-4kb size?

Code: Select all


#include "SPI.h"
#include "PN532_SPI.h"
#include "snep.h"
#include "NdefMessage.h"

#define SD_MISO 13
#define SD_MOSI 14
#define SD_SCK 17
#define SD_CS 23
#define NDEF_DEBUG 1

#define MAX_NDEF_RECORDS 30

SPIClass sd_spi(HSPI);
PN532_SPI pn532spi(sd_spi, SD_CS);
SNEP nfc(pn532spi);
uint8_t ndefBuf[2055];

void setup()
{
    Serial.begin(115200);
    Serial.println("-------Peer to Peer--------");
    sd_spi.begin(SD_SCK, SD_MISO, SD_MOSI, SD_CS);
}

void loop()
{
    NdefMessage intromessage = NdefMessage();
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    intromessage.addMimeMediaRecord("text/plain", "@");
    
    int messageSizeIntro = intromessage.getEncodedSize();
    
    if (messageSizeIntro > sizeof(ndefBuf)) {
        Serial.println("ndefBuf is too small!!!");
        while (1) {
        }
    }
    intromessage.encode(ndefBuf);
    Serial.print("Sending message intro...");
    int result = nfc.write(ndefBuf, messageSizeIntro,3000);
    Serial.print("MessageSize:"); Serial.println(messageSizeIntro);
    if (0 >= result) 
    {
        Serial.print("error");
        Serial.print(" - Failed Intro! - ");
        Serial.println(result);
    }

}
I tried splitting it to more records but still I get the same issue. It looks like its expecting a if SNEP_RESPONSE_SUCCESS and it fails at this point in the SNEP.CPP library.

Code: Select all


 if (SNEP_RESPONSE_SUCCESS != rbuf[1]) {
 DMSG("Expect a success response\n");
 Serial.println("Expect a success response\n");
 return -4;
 }


Thank you for your help!!

Who is online

Users browsing this forum: No registered users and 16 guests