Git Product home page Git Product logo

ancs_go's Introduction

ancs_go

运行在树莓派上,用于获取iphone通知内容

需要树莓派有蓝牙功能

1. 将树莓派与手机配对

树莓派中依次运行

   bluetoothctl
   power on
   agent on

等待终端中出现手机的蓝牙名称 扫描到后执行

配对完成后记录下手机蓝牙的地址

    trust xx:xx:xx:xx:xx
    pair xx:xx:xx:xx:xx

2. 运行

下面代码中

dev_xx_xx_xx_xx_xx_xx

修改为你的蓝牙id,蓝牙id中的冒号修改为下划线,如:蓝牙id为 DF:SD:QW:3S:SD 改为 dev_DF_SD_QW_3S_SD

func main() {
	ancs, err := NewAncs("/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx")
	if err != nil {
		panic(err)
	}
	err = ancs.StartNotify()
	if err != nil {
		fmt.Println(err)
	}

	for {
		select {
		case notification := <-ancs.NotificationChan:
			fmt.Println(notification.Original)
			err := ancs.GetNotificationAttributes(notification)
			if err != nil {
				fmt.Println(err.Error())
			}
		case data := <-ancs.DataChan:
			fmt.Println(data.Original)
			fmt.Printf("%s app:%s title:%s subtitle:%s message:%s \n", time.Now(), data.AppIdentifier, data.Title, data.Subtitle, data.Message)
		}
	}
}

ancs_go's People

Contributors

orzmoe avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.