Beginer: How to send data from puck to webpage or text file #1250
Replies: 11 comments
-
Posted at 2024-02-29 by @gfwilliams Hi - I think probably your best solution is to put literally just Then, the Student's device will load that webpage from the server - and that would trigger your PHP to run which could record the current time. To stop the chances of a URL getting shared or reloaded, you could maybe do:
Note we do it on NFCoff - which will happen when the phone is away, so there is no 'race' between preparing the NFC packet and having it read. That way your PHP could discount any IDs that were the same, and it also reduces the chances of the page getting cached and your PHP not getting run |
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-03-01 by user157613 @gfwilliams I tried to capture the cureent time when the page loaded but its showing the current login time to details page. I tried to capture the time from puck and tried to send the data to my webpage even this did not work. Out of ideas now, i dont know where i am going wrong on my php or puck js. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-03-01 by @gfwilliams
So I'm not sure I understand - what went wrong? Did the page that was in |
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-03-02 by user157613 Hello @gfwilliams Sorry for the delayed response, so what I did was i used the puck as a beacon, and added a JavaScript code with NDEFreading event, so basically when someone scans a puck device it should display the current date and time of the sacn, which unfortunately did not work, I read on googlechome that NDEFreading is not supported anymore and it’s a experimental feature, I tried turning on the experimental feature in chrome still did not work.
Since this did not work, what I have done now is I put the url of my webpage on puck, when scanned it takes user to webpage, they login and on details page they click on checkin button which records date and time. I want to record the time and date on the event of nfc scan automatically, is this still possible? Can the puck be used just a a beacon? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-03-04 by @gfwilliams Why not use the Using the URL seems to be the easiest way to get data out of the Puck - as you say I'm not sure how great WebNFC support is. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-03-04 by user157613 How do i use the NRFon event to set the contents of he NFC tag to be a URL?
If i set the contents of the NFC Tag to be a URL content, how would i display it on my webpage? please could you help, thank you. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-03-04 by @gfwilliams Something like this?
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-03-08 by user157613 @gfwilliams
Below is the Javascript code to extract the date and time from URL on my php webpage
Dont know what i am doing wrong, please guide thank you. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-03-08 by @gfwilliams It's possible that your device will only forward you to an |
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-03-08 by user157613 @gfwilliams
And scan the puck, it works perfectly. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-03-08 by @gfwilliams Ok, all I can think is that maybe we're causing problems by changing the NFC URL while the NFC connection is active. Maybe try:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-02-29 by user157613
Hello,
I hope you're doing well.
I'm new to this and I'm working on a small project with Puck.js. Here's what I'm trying to do:
I've made a simple webpage using PHP. When a user logs in on their mobile, it takes them to a details page showing a few pieces of information.
Now, when the user taps their phone on the Puck device, I want the NFC function to activate and record the date and time.
I have code that currently works fine. It shows the date and time when the phone is tapped on the Puck device. Here's the code:
NRF.nfcURL('https://www.espruino.com');
NRF.on('NFCon', function() {
var currentTime = new Date();
var day = currentTime.getDate();
var month = currentTime.getMonth() + 1;
var year = currentTime.getFullYear();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var formattedDate = padNumber(day) + '/' + padNumber(month) + '/' + year;
var formattedTime = padNumber(hours) + ':' + padNumber(minutes);
console.log("Student checked-in at: " + formattedDate + " " + formattedTime);
});
function padNumber(number){return (number < 10 ? '0': '') + number;}
But now, I'm not sure how to send this data from the Puck device to my webpage or a text file. I've tried different methods but couldn't figure it out. Please help me. Thank you.
Let me know if you need the PHP code too.
Best regards,
Beta Was this translation helpful? Give feedback.
All reactions