Packet type recognition without the need for decryption?

Hi am looking to add a buzzer to my board to bleep when an incoming message is received. Is it possible to distinguish between packet types of i.e Becon packets, location packets and the one i want to distinguish is the msg packet for the phone user.
Also long term a way to send none encrypted style packet that can send a status byte that the esp32 can use to send and receive input output status of pins
My basic code below edited into PhoneAPI.cpp i fear will bleep on all types of received packets.


  • Handle a packet that the phone wants us to send. It is our responsibility to free the packet to the pool


void PhoneAPI::handleToRadioPacket(MeshPacket *p) {}

extern bool BleepOnOff;

/// If the mesh service tells us fromNum has changed, tell the phone

int PhoneAPI::onNotify(uint32_t newValue)


checkConnectionTimeout(); // a handy place to check if we've heard from the phone (since the BLE version doesn't call this

                          // from idle)

if (state == STATE_SEND_PACKETS || state == STATE_LEGACY) {

   BleepOnOff=(!BleepOnOff);   '// toggle bleeper on and off 

    DEBUG_MSG("Telling client we have new packets %u\n", newValue);


    DEBUG_MSG("BEEP  %u%u\n", BleepOnOff, newValue); // debug message to simulate my attached sounder

    if (BleepOnOff== true) delay(5000); // delay for on time of bleeper.. is there a smart delay to use to allow other processes 

} else

    DEBUG_MSG("(Client not yet interested in packets)\n");

return 0;


1 Like

All of the ‘packet type’ info inside the portion that is encrypted.

Though by the time onNotify is called the packet has already been decrypted.

Ah yes should have guessed that considering my TTGO displays the msg on OLED even though the phone is not connected to it.
Now found the location where i can best look at the decoded msg and do my debug beep msg received thing in NodeDB.cpp. Not found it yet , but this also means there will be a place to inject a msg string for PIN IO such as a string '#GPIO03=1" to be decoded at the the other end as GPIO03 has changed state to High and dealt with accordingly.

case SubPacket_data_tag: {

        // Keep a copy of the most recent text message.

        if ( == Data_Type_CLEAR_TEXT) {

            DEBUG_MSG("Received text msg from=0x%0x, id=%d, msg=%.*s\n", mp.from,,,


            if ( == NODENUM_BROADCAST || == nodeDB.getNodeNum()) {

                // We only store/display messages destined for us.

                devicestate.rx_text_message = mp;

                devicestate.has_rx_text_message = true;

                updateTextMessage = true;


                notifyObservers(true); // Force an update whether or not our node counts have changed

                DEBUG_MSG("BEEP ON\n"); // my beep on thing


                DEBUG_MSG("BEEP OFF\n"); // my Beep thing

                delay (200);