aanon4 / BlueBasic

BASIC interpreter for CC2540 and CC2541 Bluetooth LE chips
https://gitlab.com/timwilkinson/BlueBasic
97 stars 55 forks source link

Set Major Minor (iBeacon) #4

Closed gregwinn closed 9 years ago

gregwinn commented 9 years ago

Hello, I am trying to set the Major and Minor values using the iBeacon example but am running into an issue.

The values in the example are (work just fine):

M(0) = 0
M(1) = 1

I am trying to set:

M(0) = 0x11
M(1) = 0x59D8

I am able to program the chip and it comes back with "OK" but the values are not set along... I am using hex values should i be doing something different?

aanon4 commented 9 years ago

Major and minor number both need to be a single byte, so M(1) cannot be that big. I assume your just copy-and-pasting the example into the console? Did you type "RUN" to execute the code? The "AUTORUN ON" statement will make sure this happens automatically after the device is rebooted.

I'm going to add this example to the Examples directory which a few expanded comments.

aanon4 commented 9 years ago

PS. Please power cycle the device after programming.

gregwinn commented 9 years ago

Yes, I am using the example you provided and just editing M(0) & M(1).

gregwinn commented 9 years ago

I am still unable to write a Major... All are showing as "0" I have tried:

30 // MAJOR
40 M(0) = 0X5
50 // MINOR
60 M(1) = 0X2

and

30 // MAJOR
40 M(0) = 5
50 // MINOR
60 M(1) = 2

Major always shows a 0.

aanon4 commented 9 years ago

Well apparently I didn't know what I was doing when I wrote that example. Please look at the new updated example in the Examples directory and on the Wiki. This one appears to work properly.

gregwinn commented 9 years ago

No worries.

Should power be "M(4)" and not M(2)?

// "Power"
80 M(4) = 0xC8

I am running this in the console and it is coming back with "OK" but after I power cycle the beacon it is not showing as the name I set it to be (Checking in two applications "BasicBlue Console" and an App on my phone).

aanon4 commented 9 years ago

Yes it should (fixed). Not sure on the name thing. I see the name just fine using the "Locate" app on my iPhone. Not totally surprised about the name with BlueBasicConsole because the Mac caches a lot of the Bluetooth state and refuses to fresh it. What app are you using on your phone?

gregwinn commented 9 years ago

I am using an Android App called Bluetooth LE Scanner

To date it has been working great with all the BLE stuff i have been building just this last time i tried to run the new iBeacon example in BBConsole and it's still showing the Original name "BASIC#2C".

aanon4 commented 9 years ago

Just to clarify a few things - the old name is only showing up on the BBConsole program now, but is okay on the Android app? Is this the new Swift BBConsole version or the older Objective-C version?

gregwinn commented 9 years ago

The Objective-C version of the BBConsole is showing the old name along with the Android App.

This is after i use the new iBeacon example. If i use the old example it will work but I am unable to set the Major/Minor correctly.

gregwinn commented 9 years ago

No sorry using the NEW Swift version (The one that's in the zip file) Console/osx/BlueBasicConsole.zip

aanon4 commented 9 years ago

Okay. I've updated that app (and zip file) to better handle device name updates. Let me know if that improves things.

gregwinn commented 9 years ago

After using the updated Console when I connect to the Beacon it will say "connected" but nothing prints out in the terminal. I have tried "NEW" but no response.

screen shot 2014-10-02 at 8 36 38 pm

aanon4 commented 9 years ago

I've seen this sometime when OSX caches the services on a device, but the services have changed. Can you try running the following commands and then relaunch the console:

sudo defaults write /Library/Preferences/com.apple.Bluetooth CoreBluetoothCache -dict
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.blued.plist
sudo launchctl load /System/Library/LaunchDaemons/com.apple.blued.plist

This flushes the services OSX has cached and forces it to rediscover.

gregwinn commented 9 years ago

Bingo! Ok, Now i will try the updated iBeacon example!

gregwinn commented 9 years ago

All working! Major and Minor is now set! Thank you!!

aanon4 commented 9 years ago

I really appreciate the time you've invested in this - thanks!