- ets Jun 8 2016 00:22:57
- rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
- configsip: 0, SPIWP:0xee
- clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
- mode:DIO, clock div:1
- load:0x3fff0018,len:4
- load:0x3fff001c,len:1216
- ho 0 tail 12 room 4
- load:0x40078000,len:9720
- ho 0 tail 12 room 4
- load:0x40080400,len:6352
- entry 0x400806b8
- Beginning Notification Library Test
- Beginning creation test:
- assertion "%s" failed: file "%s", line %d%s%s
- ssertion "%s" failed: file "%s", line %d%s%s
- sertion "%s" failed: file "%s", line %d%s%s
- ertion "%s" failed: file "%s", line %d%s%s
- rtion "%s" failed: file "%s", line %d%s%s
- tion "%s" failed: file "%s", line %d%s%s
- ion "%s" failed: file "%s", line %d%s%s
- on "%s" failed: file "%s", line %d%s%s
- Creation test finished. Success!!
- Assigning titles:
- assertion "%s" failed: file "%s", line %d%s%s
- ssertion "%s" failed: file "%s", line %d%s%s
- sertion "%s" failed: file "%s", line %d%s%s
- ertion "%s" failed: file "%s", line %d%s%s
- rtion "%s" failed: file "%s", line %d%s%s
- tion "%s" failed: file "%s", line %d%s%s
- ion "%s" failed: file "%s", line %d%s%s
- on "%s" failed: file "%s", line %d%s%s
- Title creation finished. Success!!
I'm trying to build a library for the arduino framework for the ESP32 which is intended to provide a class which will work as a data container for notifications provided by the ANCS ble service. For those of you who don't know, ANCS stands for Apple Notification Center Service. It's the service you subscribe to in order to read and modify apple system notifications over bluetooth.
Basically, there are a bunch of attributes that a notification can have which the bluetooth device retrieves lazily based on UID's. When a device subscribes to the ANCS, it begins a session, and for the length of that session each notification that the device encounters uses a UID to identify itself. These start at 0 at the beginning of the session and they are 32 bit unsigned integers. The attributes which are retrievable are as follows:
- AppIdentrifier: the ID apple uses to identify the notification's source (i.e. com.apple.messaging.SMS)
- Title
- Subtitle
- Message
- MessageSize
- Date
- PositiveActionLabel: there are always two actions available for ANCS notifications: a positive action and a negative action. For an incoming call notification for example, the label for the positive action would be "Accept", and the negative action label would be "Decline".
- NegativeActionLabel
Basically, there are private variables for each attribute, and also "set", "get", and "has" methods ("has" methods confirm or deny whether or not the attribute has been set).
My library code is as follows (I used the arduino Library tutorial to help me create this):
- #ifndef Notification_h
- #define Notification_h
- #include "Arduino.h"
- class Notification {
- public:
- Notification();
- void create(uint8_t _uuid1, uint8_t _uuid2, uint8_t _uuid3, uint8_t _uuid4);
- void create(uint32_t _uuid);
- uint8_t uuid1;
- uint8_t uuid2;
- uint8_t uuid3;
- uint8_t uuid4;
- uint32_t uuid;
- String getAppIdentifier();
- String getTitle();
- String getSubtitle();
- String getMessage();
- String getMessageSizeString();
- uint16_t getMessageSize();
- String getDateString();
- String getPositiveActionLabel();
- String getNegativeActionLabel();
- String setAppIdentifier(String _appIdentifier);
- String setTitle(String _title);
- String setSubtitle(String _subtitle);
- String setMessage(String _message);
- String setMessageSizeString(String _messageSizeString);
- String setDateString(String _dateString);
- String setPositiveActionLabel(String _positiveActionLabel);
- String setNegativeActionLabel(String _negativeActionLabel);
- bool hasAppIdentifier();
- bool hasTitle();
- bool hasSubtitle();
- bool hasMessage();
- bool hasMessageSizeString();
- bool hasMessageSize();
- bool hasDateString();
- bool hasPositiveActionLabel();
- bool hasNegativeActionLabel();
- private:
- String appIdentifier;
- String title;
- String subtitle;
- String message;
- String messageSizeString;
- String dateString;
- String positiveActionLabel;
- String negativeActionLabel;
- uint16_t messageSize;
- };
- #endif
- #include "Arduino.h"
- #include "String.h"
- #include "Notification.h"
- Notification::Notification(){}
- void Notification::create(uint8_t _uuid1, uint8_t _uuid2, uint8_t _uuid3, uint8_t _uuid4){
- uuid1 = _uuid1;
- uuid2 = _uuid2;
- uuid3 = _uuid3;
- uuid4 = _uuid4;
- }
- void Notification::create(uint32_t _uuid){
- uuid = _uuid;
- }
- String Notification::getAppIdentifier() {
- if (appIdentifier == NULL) {
- return "";
- } else {
- return appIdentifier;
- }
- }
- String Notification::getTitle() {
- if (title == NULL) {
- return "";
- } else {
- return title;
- }
- }
- String Notification::getSubtitle() {
- if (subtitle == NULL) {
- return "";
- } else {
- return subtitle;
- }
- }
- String Notification::getMessage() {
- if (message == NULL) {
- return "";
- } else {
- return message;
- }
- }
- String Notification::getMessageSizeString() {
- if (messageSizeString == NULL) {
- return "";
- } else {
- return messageSizeString;
- }
- }
- uint16_t Notification::getMessageSize() {
- if (messageSize == NULL) {
- if (messageSizeString == NULL) {
- return NULL;
- } else {
- messageSize = messageSizeString.toInt();
- return messageSize;
- }
- } else {
- return messageSize;
- }
- }
- String Notification::getDateString() {
- if (dateString == NULL) {
- return "";
- } else {
- return dateString;
- }
- }
- String Notification::getPositiveActionLabel() {
- if (positiveActionLabel == NULL) {
- return "";
- } else {
- return positiveActionLabel;
- }
- }
- String Notification::getNegativeActionLabel() {
- if (negativeActionLabel == NULL) {
- return "";
- } else {
- return negativeActionLabel;
- }
- }
- String Notification::setAppIdentifier(String _appIdentifier) {
- appIdentifier = _appIdentifier;
- }
- String Notification::setTitle(String _title) {
- title = _title;
- }
- String Notification::setSubtitle(String _subtitle) {
- subtitle = _subtitle;
- }
- String Notification::setMessage(String _message) {
- message = _message;
- }
- String Notification::setMessageSizeString(String _messageSizeString) {
- messageSizeString = _messageSizeString;
- }
- String Notification::setDateString(String _dateString) {
- dateString = _dateString;
- }
- String Notification::setPositiveActionLabel(String _positiveActionLabel) {
- positiveActionLabel = _positiveActionLabel;
- }
- String Notification::setNegativeActionLabel(String _negativeActionLabel) {
- negativeActionLabel = _negativeActionLabel;
- }
- bool Notification::hasAppIdentifier() {
- if (appIdentifier == NULL) {
- return false;
- } else {
- return true;
- }
- }
- bool Notification::hasTitle() {
- if (title == NULL) {
- return false;
- } else {
- return true;
- }
- }
- bool Notification::hasSubtitle() {
- if (subtitle == NULL) {
- return false;
- } else {
- return true;
- }
- }
- bool Notification::hasMessage() {
- if (message == NULL) {
- return false;
- } else {
- return true;
- }
- }
- bool Notification::hasMessageSizeString() {
- if (messageSizeString == NULL) {
- return false;
- } else {
- return true;
- }
- }
- bool Notification::hasMessageSize() {
- if (messageSize == NULL) {
- return false;
- } else {
- return true;
- }
- }
- bool Notification::hasDateString() {
- if (dateString == NULL) {
- return false;
- } else {
- return true;
- }
- }
- bool Notification::hasPositiveActionLabel() {
- if (positiveActionLabel == NULL) {
- return false;
- } else {
- return true;
- }
- }
- bool Notification::hasNegativeActionLabel() {
- if (negativeActionLabel == NULL) {
- return false;
- } else {
- return true;
- }
- }
- #include <notification.h>
- #define NUMBER_OF_TESTS 10
- Notification notifications[NUMBER_OF_TESTS];
- void setup() {
- Serial.begin(115200);
- delay(5000);
- Serial.println("Beginning Notification Library Test");
- Serial.println("");
- Serial.println("Beginning creation test:");
- // put your setup code here, to run once:
- for (int i = 0; i < NUMBER_OF_TESTS; i++) {
- notifications[i].create(i);
- Serial.print(i + " ");
- }
- Serial.println("\n");
- Serial.println("Creation test finished. Success!!");
- Serial.println("");
- Serial.println("Assigning titles:");
- for (int i = 0; i < NUMBER_OF_TESTS; i++) {
- String title = "Notification Title";
- for (int j = 0; j < i; j++) {
- title = title + " Blah";
- }
- notifications[i].setTitle(title);
- Serial.print(i + " ");
- }
- Serial.println("\n");
- Serial.println("Title creation finished. Success!!");
- }
- void loop() {
- // put your main code here, to run repeatedly:
- }
When I run this however, the test... I guess it fails? This is the output:
Can somebody please tell me what "assertion "%s" failed: file "%s", line %d%s%s" means? I looked but I couldn't find anything. Also, if you have any recommendations for my library, please let me know!