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: Servo GroveGPS Cayenne-LPP driver_mbed_TH02
Revision 65:724a61ad654c, committed 2022-03-29
- Comitter:
- younousleconquerant
- Date:
- Tue Mar 29 09:43:58 2022 +0000
- Parent:
- 64:4cd8fed3f437
- Commit message:
- 12;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Mar 15 08:54:01 2022 +0000
+++ b/main.cpp Tue Mar 29 09:43:58 2022 +0000
@@ -151,7 +151,7 @@
//myTH02.startTempConv(true,true);
printf("\r\n*********************Initialization**********************************");
RfChip.PCD_Init(); /* Init. RC522 Chip*/
- printf("\r\n**********************Starting Reading Tags**************************");
+ printf("\r\n**********************Starting Reading Tags**************************");
// stores the status of a call to LoRaWAN protocol
lorawan_status_t retcode;
@@ -207,7 +207,7 @@
* Sends a message to the Network Server
*************************************************************************************************************/
-
+
static void send_message()
{
int iTime,iTempbrute,iRHbrute;
@@ -232,42 +232,35 @@
printf("\r\n gpsLatitude=%s", gpsLat);
printf("\r\n gpsLongitude=%s", gpsLon);
printf("\r\n gpsAltitude=%s", gpsalt);
-
- //RFID
- if ( ! RfChip.PICC_IsNewCardPresent())
- {
- wait_ms(500);
- }
+
// Select one of the cards
- if (!RfChip.PICC_ReadCardSerial())
- {
- wait_ms(500);
- printf("\r\nReading a card");
+ wait_ms(500);
+ if (!RfChip.PICC_ReadCardSerial()) {
+ wait_ms(500);
+ printf("\r\nReading a card");
+ if (RfChip.PICC_IsNewCardPresent()) {
+ // Print Card UID
+ printf("\r\nNew card UID: ");
+ for (uint8_t i = 0; i < RfChip.uid.size; i++) {
+ printf(" %X02", RfChip.uid.uidByte[i]);
+ }
+ printf("\r\n");
+ }
}
+
+ // Print Card type
+ //uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak);
+ // printf("PICC Type: %s \r\n", RfChip.PICC_GetTypeName(piccType));
+ //strcat(nfcData, RfChip.PICC_GetTypeName(piccType));
+ //printf("DATA send: %s \r\n", nfcData);
+ //wait_ms(1000);
- // Print Card UID
- char nfcData[100];
- printf("\r\nCard UID: ");
- for (uint8_t i = 0; i < RfChip.uid.size; i++)
- {
- printf(" %X02", RfChip.uid.uidByte[i]);
- nfcData[i] = RfChip.uid.uidByte[i];
- }
- printf("\r\n");
-
- // Print Card type
- uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak);
- printf("PICC Type: %s \r\n", RfChip.PICC_GetTypeName(piccType));
- strcat(nfcData, RfChip.PICC_GetTypeName(piccType));
- printf("DATA send: %s \r\n", nfcData);
- wait_ms(1000);
-
Payload.reset();
size = Payload.addTemperature(1, (float) fTemp);
size = size + Payload.addRelativeHumidity(2, fHumid);
size = size + Payload.addGPS(3, atof(gpsLat), atof(gpsLon), atof(gpsalt));
- size = size + Payload.addNFC(4, (char *)nfcData);
+ size = size + Payload.addNFC(4, (char *)RfChip.uid.uidByte);
// send complete message with cayenne format
retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, Payload.getBuffer(), Payload.getSize(),