1 /* 2 This example code is in the Public Domain (or CC0 licensed, at your option.) 3 4 Unless required by applicable law or agreed to in writing, this 5 software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 6 CONDITIONS OF ANY KIND, either express or implied. 7 */ 8 9 10 #include <stdio.h> 11 #include <stdlib.h> 12 #include <string.h> 13 14 //EventID values 15 typedef enum { 16 EventIDNotificationAdded = 0, 17 EventIDNotificationModified = 1, 18 EventIDNotificationRemoved = 2, 19 //Reserved EventID values = 3–255 20 } esp_EventID; 21 22 //EventFlags 23 typedef enum { 24 EventFlagSilent = (1 << 0), 25 EventFlagImportant = (1 << 1), 26 EventFlagPreExisting = (1 << 2), 27 EventFlagPositiveAction = (1 << 3), 28 EventFlagNegativeAction = (1 << 4), 29 //Reserved EventFlags = (1 << 5)–(1 << 7 30 }esp_EventFlags; 31 32 // CategoryID values 33 typedef enum { 34 CategoryIDOther = 0, 35 CategoryIDIncomingCall = 1, 36 CategoryIDMissedCall = 2, 37 CategoryIDVoicemail = 3, 38 CategoryIDSocial = 4, 39 CategoryIDSchedule = 5, 40 CategoryIDEmail = 6, 41 CategoryIDNews = 7, 42 CategoryIDHealthAndFitness = 8, 43 CategoryIDBusinessAndFinance = 9, 44 CategoryIDLocation = 10, 45 CategoryIDEntertainment = 11, 46 //Reserved CategoryID values = 12–255 47 } esp_CategoryID; 48 49 //CommandID values 50 typedef enum { 51 CommandIDGetNotificationAttributes = 0, 52 CommandIDGetAppAttributes = 1, 53 CommandIDPerformNotificationAction = 2, 54 //Reserved CommandID values = 3–255 55 } esp_CommandID; 56 57 //NotificationAttributeID 58 typedef enum { 59 NotificationAttributeIDAppIdentifier = 0, 60 NotificationAttributeIDTitle = 1, //(Needs to be followed by a 2-bytes max length parameter) 61 NotificationAttributeIDSubtitle = 2, //(Needs to be followed by a 2-bytes max length parameter) 62 NotificationAttributeIDMessage = 3, //(Needs to be followed by a 2-bytes max length parameter) 63 NotificationAttributeIDMessageSize = 4, 64 NotificationAttributeIDDate = 5, 65 NotificationAttributeIDPositiveActionLabel = 6, 66 NotificationAttributeIDNegativeActionLabel = 7, 67 //Reserved NotificationAttributeID values = 8–255 68 } esp_NotificationAttributeID; 69 70 /* 71 Note: The format of the NotificationAttributeIDMessageSize constant is a string that represents the integral value 72 of the message size. The format of the NotificationAttributeIDDate constant is a string that uses the Unicode Technical 73 Standard (UTS) #35 date format pattern yyyyMMdd'T'HHmmSS. The format of all the other constants in Table 3-5 are UTF-8 74 strings. 75 */ 76 77 //ActionID values 78 typedef enum { 79 ActionIDPositive = 0, 80 ActionIDNegative = 1, 81 //Reserved ActionID values = 2–255 82 } esp_ActionID; 83 84 //AppAttributeID Values 85 typedef enum { 86 AppAttributeIDDisplayName = 0, 87 //Reserved AppAttributeID values = 1–255 88 } esp_AppAttributeID; 89 90 typedef struct { 91 uint8_t noti_attribute_id; 92 uint16_t attribute_len; 93 } esp_noti_attr_list_t; 94 95 typedef enum { 96 Unknown_command = (0xA0), //The commandID was not recognized by the NP. 97 Invalid_command = (0xA1), //The command was improperly formatted. 98 Invalid_parameter = (0xA2), // One of the parameters (for example, the NotificationUID) does not refer to an existing object on the NP. 99 Action_failed = (0xA3), //The action was not performed 100 } esp_error_code; 101 102 typedef enum { 103 attr_appidentifier_index = 0, //The commandID was not recognized by the NP. 104 attr_title_index, 105 attr_subtitle_index, 106 attr_message_index, 107 attr_messagesize_index, 108 attr_date_index, 109 attr_positiveactionlabel_index, 110 attr_negativeactionlabel_index, 111 } esp_attr_index; 112 113 #define ESP_NOTIFICATIONUID_LEN 4 114 115 116 char *EventID_to_String(uint8_t EventID); 117 char *CategoryID_to_String(uint8_t CategoryID); 118 void esp_receive_apple_notification_source(uint8_t *message, uint16_t message_len); 119 void esp_receive_apple_data_source(uint8_t *message, uint16_t message_len); 120 char *Errcode_to_String(uint16_t status); 121