Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BufferedSerial USBDevice XadowGPS XadowNFC mbed mbedPebbleSerial IAP
Revision 3:40e13433d193, committed 2015-11-06
- Comitter:
- KillingJacky
- Date:
- Fri Nov 06 03:26:26 2015 +0000
- Parent:
- 2:281fa9ce92c0
- Commit message:
- **added notification enhancement
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Nov 06 02:53:03 2015 +0000
+++ b/main.cpp Fri Nov 06 03:26:26 2015 +0000
@@ -33,6 +33,7 @@
#define ATTR_NFC_ERASE_NDEF 0x1004
uint8_t nfc_online, gps_online;
+bool need_notify = false;
char eep_block[ EEP_BLOCK_SIZE ];
@@ -251,6 +252,8 @@
dbg_serial.printf("\r\n");
memcpy((char *)s_pebble_buffer, (char *)last_tagid, last_tagid_len);
mbedPebbleSerial::write(true, s_pebble_buffer, last_tagid_len);
+
+ need_notify = false;
}
else if (attribute_id == ATTR_NFC_READ_NDEF && type == RequestTypeRead)
{
@@ -300,33 +303,42 @@
{
timer_notify.reset();
- uint8_t *uid = nfc_adapter_get_uid();
- uint8_t len = uid[1];
- dbg_serial.printf("Check NFC: ");
- if (len > 0)
+ if (need_notify)
+ {
+ mbedPebbleSerial::notify(SERVICE_NFC, ATTR_NFC_GET_UID);
+ }else
{
- for(int i=2; i<2+len; i++)
+ uint8_t *uid = nfc_adapter_get_uid();
+ uint8_t len = uid[1];
+ dbg_serial.printf("Check NFC: ");
+ if (len > 0)
{
- dbg_serial.printf("%02X ", uid[i]);
+ for(int i=2; i<2+len; i++)
+ {
+ dbg_serial.printf("%02X ", uid[i]);
+ }
+ }
+ dbg_serial.printf("\r\n");
+ len = min(len, 10);
+ if (memcmp(last_tagid, uid+2, len) != 0 || len != last_tagid_len)
+ {
+ need_notify = true;
+ mbedPebbleSerial::notify(SERVICE_NFC, ATTR_NFC_GET_UID);
+ if (len == 0)
+ {
+ memset(last_tagid, 0, sizeof(last_tagid));
+ }else
+ {
+ memcpy(last_tagid, uid+2, len);
+ }
+ last_tagid_len = len;
+ //changed, notify
}
}
- dbg_serial.printf("\r\n");
- len = min(len, 10);
- if (memcmp(last_tagid, uid+2, len) != 0 || len != last_tagid_len)
- {
- mbedPebbleSerial::notify(SERVICE_NFC, ATTR_NFC_GET_UID);
- if (len == 0)
- {
- memset(last_tagid, 0, sizeof(last_tagid));
- }else
- {
- memcpy(last_tagid, uid+2, len);
- }
- last_tagid_len = len;
- //changed, notify
- }
}
+
+
//check services' availability
if (timer_service.read() > 5)
{