Guest User

Untitled

a guest
Nov 6th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. const bleno = require('bleno');
  2.  
  3. const UUID = '69d9fdd724fa4987aa3f43b5f4cabcbf';
  4. const MINOR = 2;
  5. const MAJOR = 1;
  6. const TX_POWER = -60;
  7.  
  8. console.log("Starting Bleno...");
  9.  
  10. console.log(bleno.state);
  11. bleno.on('StateChange', state => {
  12. if (state === 'poweredOn') {
  13. console.log("Starting Broadcast...");
  14.  
  15. bleno.startAdvertisingIBeacon(UUID, MAJOR, MINOR, TX_POWER, err => {
  16. if(err) {
  17. console.error(err);
  18. }
  19. else {
  20. console.log('Broadcasting as IBeacon uuid:${UUID}, major: ${MAJOR}, minor: ${MINOR}')
  21. }
  22. });
  23. }
  24. else {
  25. console.log("Stopping Broadcast...");
  26. bleno.stopAdvertising();
  27. }
  28. });
Add Comment
Please, Sign In to add comment