Skip to content

Commit

Permalink
create new features
Browse files Browse the repository at this point in the history
  • Loading branch information
iDevBrandon committed Feb 4, 2023
1 parent aa35121 commit a989dc4
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,40 @@ const oxinion = {
callback(peripheral.address);
});
},
megaphoneForCoupon: function (couponMessage) {
console.log(`Starting to broadcast coupon message: ${couponMessage}`);

noble.startAdvertising(couponMessage, () => {
console.log(
`Coupon message "${couponMessage}" is now being broadcasted.`
);
});
},

scanAndPay(paymentData) {
return new Promise((resolve, reject) => {
noble.startScanning();
noble.on("discover", (peripheral) => {
// Check if the peripheral has the desired payment service
if (peripheral.uuid === paymentData.uuid) {
// Connect to the peripheral and send the payment information
peripheral.connect((error) => {
if (error) {
reject(error);
} else {
peripheral.writeData(paymentData.data, (error) => {
if (error) {
reject(error);
} else {
resolve("Payment Successful!");
}
});
}
});
}
});
});
},
};

export default oxinion;

0 comments on commit a989dc4

Please sign in to comment.