{"id":25668044,"url":"https://github.com/laftho/node-nfc-nci","last_synced_at":"2025-04-22T23:27:58.012Z","repository":{"id":34220988,"uuid":"171976563","full_name":"laftho/node-nfc-nci","owner":"laftho","description":"nodejs api for linux NXP NFC NCI","archived":false,"fork":false,"pushed_at":"2024-06-28T21:41:53.000Z","size":138,"stargazers_count":1,"open_issues_count":14,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-18T13:05:35.963Z","etag":null,"topics":["nfc","nodejs","om5578","om5578-pn7150rpi","pn7150","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/laftho.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-22T01:58:30.000Z","updated_at":"2023-05-12T16:37:59.000Z","dependencies_parsed_at":"2024-10-04T11:34:18.318Z","dependency_job_id":null,"html_url":"https://github.com/laftho/node-nfc-nci","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laftho%2Fnode-nfc-nci","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laftho%2Fnode-nfc-nci/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laftho%2Fnode-nfc-nci/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laftho%2Fnode-nfc-nci/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laftho","download_url":"https://codeload.github.com/laftho/node-nfc-nci/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250339489,"owners_count":21414364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nfc","nodejs","om5578","om5578-pn7150rpi","pn7150","raspberry-pi"],"created_at":"2025-02-24T10:20:30.704Z","updated_at":"2025-04-22T23:27:57.983Z","avatar_url":"https://github.com/laftho.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"### node-nfc-nci\n\n#### depedencies\n\ncmake\n\n`sudo apt install -y cmake automake autoconf libtool pkg-config`\n\nlinux_libnfc-nci - https://github.com/NXPNFCLinux/linux_libnfc-nci\n\n`git clone https://github.com/NXPNFCLinux/linux_libnfc-nci.git`\n\n`./bootstrap`\n\n\n`./configure --enable-alt`\n\n`make`\n\n`sudo make install`\n\nIt installs the libnfc-nci-linux library to /usr/local/lib target directory. This path must be\nadded to LD_LIBRARY_PATH environment variable for proper reference to the library\nduring linking/execution of application.\n\n#### setup\n\n`npm install node-nfc-nci`\n\nhttps://www.npmjs.com/package/node-nfc-nci\n\n#### documentation\n\ninclude\n`const nci = require(\"node-nfc-nci\");`\n\nmodule exports nci interface object with single method `listen`\n\n`listen(callback\u003cfunction\u003e)` - will attempt to initialize the device via the `linux_libnfc-nci` library on a new thread and immediately call the callback with a `context` object.\n\n`context` - context is an event emitter and interface to setting tag write for the next tag to arrive.\n\n###### events\n\n`error` - `message\u003cstring\u003e` - emits on any error, even for errors when attempting to initialize the device.\n`arrived` - `tag\u003cobject\u003e` - emits on NFC tag arrival\n`departed` -`tag\u003cobject\u003e` - emits on NFC tag departure. Provide a copy of the original arrived tag. If NDEF data has been updated during the tag's presence it will not be reflected in departure.\n`written` - `tag\u003cobject\u003e, previous\u003cobject\u003e` - emits on successful tag NDEF write. Provides updated tag and a copy of the original arrived tag prior to update.\n\n###### tag object\n\nexample\n```\n{\n  \"technology\": {\n    \"code\": 9,\n    \"name\": \"Type A - Mifare Ul\",\n    \"type\": \"MIFARE_UL\"\n  },\n  \"uid\": {\n    \"id\": \"04:e1:5f:d2:9c:39:80\",\n    \"type\": \"NFCID1\",\n    \"length\": 7\n  },\n  \"ndef\": {\n    \"size\": 868,\n    \"length\": 18,\n    \"read\": 11,\n    \"writeable\": true,\n    \"type\": \"Text\",\n    \"content\": \"hello world\"\n  }\n}\n```\n\n##### tag write\n\nvia context\n\n`context.setNextWrite(type\u003cstring\u003e, content\u003cstring\u003e)` - set data to write for next tag arrival, this will attempt to indiscriminately write the next tag that arrives.\n`context.clearNextWrite()` - clears the pending next write.\n`context.hasNextWrite()\u003cbool\u003e` - flag to check if there is a next write pending.\n`context.immediateWrite(type\u003cstring\u003e, content\u003cstring\u003e)` - attempts to immediately write to the device that is present. However, tag `arrived` event provides a `tag.write` function which is an alias of `immediateWrite` but likely more practical because `immediateWrite` depends on a device being present.\n\nvia tag\n\n`tag.write(type\u003cstring\u003e, content\u003cstring\u003e)` - attempt immediate write to which ever tag is present. This write does not guarantee it will write only to the particular tag `tag` describes, as it's only a convenience alias to `context.immediateWrite` \n\nAcceptable types\n- `Text` - writes `en` lang text to the NDEF content\n\n#### example\n\n```\nconst nci = require(\"node-nfc-nci\");\n\nnci.listen(context =\u003e {\n    context.on(\"error\", msg =\u003e console.log(msg));\n\n    context.on(\"arrived\", tag =\u003e {\n        console.log(`ARRIVED: ${JSON.stringify(tag)}`);\n\n        if (!context.hasNextWrite()) {\n            if (tag.uid.id === \"04:e1:5f:d2:9c:39:80\") {\n                tag.write(\"Text\", \"hello world\");\n            }\n        }\n    });\n\n    context.on(\"written\", (tag, previous) =\u003e {\n        console.log(`PREVIOUS: ${JSON.stringify(previous)}`);\n        console.log(`UPDATED: ${JSON.stringify(tag)}`);\n    });\n\n    context.on(\"departed\", tag =\u003e {\n        console.log(`DEPARTED: ${JSON.stringify(tag)}`);\n\n        if (tag.ndef.content !== \"foobar\") {\n            context.setNextWrite(\"Text\", \"foobar\"); // will attempt write on any next tag\n        }\n    });\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaftho%2Fnode-nfc-nci","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaftho%2Fnode-nfc-nci","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaftho%2Fnode-nfc-nci/lists"}