Skip to content

peek() returns second char in buffer - after update to MKRNB v1.6 #126

@andersop91

Description

@andersop91

Currently working with the board MKR NB 1500.

After ugrading to MKRNB v1.6.0 i'm experiencing a problem with the message disposal functionality from example RecieveSMS.ino
I believe it's connected with the change in #100.
I acknowledge the bug presented - the first character is clipped if using peek in <v1.6.0, and was not according to the given documentation . Nevertheless, according to my experience this fix is breaking other functionality, as it now consequently reads the second character in the buffer, and not the first as I would expect.

Am I doing anything wrong?

Output;
image
Where 83 corresponds to 'S' in ascii.

Current code;

// If there are any SMSs available()
  if (sms.available()) {
    Serial.println("Message received from:");

    // Get remote number
    sms.remoteNumber(senderNumber, 20);
    Serial.println(senderNumber);

    Serial.print("Message starts with: ");
    int peek = sms.peek();
    Serial.println(peek);

    // Read message bytes and print them
    while ((c = sms.read()) != -1) {
      Serial.print((char)c);
    }

    Serial.println("\nEND OF MESSAGE");

    // Delete message from modem memory
    sms.flush();
    Serial.println("MESSAGE DELETED");
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions