顯示具有 BLUETOOTH 標籤的文章。 顯示所有文章
顯示具有 BLUETOOTH 標籤的文章。 顯示所有文章

2019年7月16日 星期二

Raspberry pi 同時使用 藍牙及 UART

sudo raspi-config
Interface > Serial > No

sudo nano /boot/config.txt
新增底下三行
core_freq=250
dtoverlay=pi3-miniuart-bt
enable_uart=1

注意此時 uart 是使用系統時脈產生 baud rate,不能太快

2017年12月21日 星期四

RaspberryPi BLE bluepy



install…
sudo apt-get install bluez
sudo hciconfig hci0 up

scan…
sudo hcitool lescan

or scan if no response...
sudo bluetoothctl
agent on
default-agent
scan on

other test...
using bluetoothctl

install bluepy…
https://github.com/IanHarvey/bluepy
sudo apt-get install python-pip libglib2.0-dev
sudo pip install bluepy

python test code…
from bluepy import btle
from bluepy.btle import Scanner, DefaultDelegate
import time
# Scan Delegate... 
class ScanDelegate(DefaultDelegate):
    def __init__(self):
        DefaultDelegate.__init__(self)

    def handleDiscovery(self, dev, isNewDev, isNewData):
        if isNewDev:
            print "Discovered device", dev.addr
        elif isNewData:
            print "Received new data from", dev.addr

print 'Scanning...'
scanner = Scanner().withDelegate(ScanDelegate())
devices = scanner.scan(3.0)

address = None
for dev in devices:
    print "Device %s (%s), RSSI=%d dB" % (dev.addr, dev.addrType, dev.rssi)
    for (adtype, desc, value) in dev.getScanData():
        print "  %s = %s" % (desc, value)
        if desc == 'Complete Local Name' and value == 'YOUR_BLE_DEVICE_NAME':
            address = dev.addr

print "Connecting..."

#address = "YOUR_FIX_DEVICE_MAC"
dev = btle.Peripheral( address )

print "Services..."
for svc in dev.services:
    print str(svc)
    chs = svc.getCharacteristics()
    for ch in chs:
        print '  ' + str(ch)
# Notification Delegate
class MyDelegate(btle.DefaultDelegate):
    def __init__(self):
        btle.DefaultDelegate.__init__(self)
        # ... initialise here

    def handleNotification(self, cHandle, data):
        print 'handleNotification:' + str(data)
        # ... perhaps check cHandle
        # ... process 'data'


# Initialisation  -------

dev.setDelegate( MyDelegate() )

service_uuid = btle.UUID("49535343-fe7d-4ae5-8fa9-9fafd205e455") # YOUR SERVICE UUID
char_uuid = btle.UUID("49535343-1e4d-4bd9-ba61-23c647249616") # YOUR CHARACTERISTICS UUID

# Setup to turn notifications on, e.g.
svc = dev.getServiceByUUID( service_uuid )
ch = svc.getCharacteristics( char_uuid )[0]
# Here is how to write a value to Notification Characteristic... 
write_handle = ch.getHandle()
notify_handle = ch.getHandle() + 1
dev.writeCharacteristic( notify_handle, bytes("\x01"), withResponse=True)

time.sleep(1.0)

# Main loop --------
while True:
    if dev.waitForNotifications(1.0):
        # handleNotification() was called
        continue

    print "Waiting..."
    # Perhaps do something else here
    # Here is how to write a value to Characteristic
    dev.writeCharacteristic( write_handle, bytes("A"), False ) # YOUR DATA

2017年7月17日 星期一

iOS App 上架駁回


由於是藍牙產品,App 需要連線才能動作,所以審核員也會要求你將硬體寄送過去給 Apple

底下是遭駁回的理由…

Guideline 2.1 - Information Needed

Thank you for your resubmission. We have started the review of your app, but we are not able to continue because we need the associated hardware to fully assess your app features.

Next Steps

To help us proceed with the review of your app, please send the necessary hardware/accessory to the address below.

NOTE: Please include your app name and app ID in the shipment; failure to provide this information can delay the review process.

Additionally, it may take several business days for us to receive the hardware once it has been delivered to Apple.

Apple, Inc.
1 Infinite Loop, M/S: 124-2APP
Cupertino, CA 95014
USA


解決方法…

先嘗式拍攝一段完整的DEMO影片回覆看看。
(後續:已審核通過)



2017年6月5日 星期一

nRF51 Development Kit 開發環境

nRF51 Development Kit

開發環境安裝…

安裝 Keil 5

Keil - Pack Installer / Update

安裝 Device Family Pack
https://developer.nordicsemi.com/nRF5_SDK/
e.g. NordicSemiconductor.nRF_DeviceFamilyPack.8.11.1.pack

安裝 CMSIS pack
https://github.com/ARM-software/CMSIS/releases
e.g. ARM.CMSIS.4.5.0.pack

Keil 選單 project/manage/select software packs


2017年5月5日 星期五

Bluetooth GPS Tracer

一個簡單有趣的 GPS 應用,可以拿來用在尋機…

結合現成的三種模組 GPS Module、HC12 RF Module、HC-05 Bluetooth Module 再加上簡單的 App 解 MNEA GPS 格式,就能實現遠距 GPS 追蹤,類似防丟器的概念,但即時距離可達 1 公里。

Combine "CRIUS GPS Module"、"HC12 - Long Range RF Wireless SERIAL Module" and "HC-05 Bluetooth Module",make remote location trace with 433mhz RF and Bluetooth comunication

App...
https://play.google.com/store/apps/details?id=com.longfellowchen.bluetoothgpstracer

系統架構 - System Architecture…
GPS--[UART]-->HC12-->~~[RF433MHZ]~~-->HC12-->HC-05-->~~[BT2.4G]-->SmartPhone

硬體線路 - Hardware circuit...
基本上只是把模組 UART 線路全串在一起…

Remote device...
GPS-TX ---------------->HC12-RX
GPS-RX ---------------->HC12-TX (option)

Local device
HC05-TX ---------------->HC12-RX(option)
HC05-RX ---------------->HC12-TX

All Module..
VCC ----------------> +5V
GND ----------------> GND

注意事項…
*All module should set the same baud-rate (default is 9600)
*HC12 Module can set transmit power to what you want. (see it's documents)


VirtualBox 空間減肥

@windows vm sdelete64 -z c: @macos VBoxManage  modifymedium  disk  "/Users/fellow/VirtualBox VMs/Win10/Win10.vdi"  --compact *.vdi...