Transmitting as iBeacon in XAMARIN - AltBeacon library - android-studio

I have come across a problem with iBeacon transmission in AltBeacon library in XAMARIN.
In Android Studio, this code works perfect (I can detect created iBeacon on iPhone). I am using Android 5:
mBeaconTransmitter = new BeaconTransmitter(this, new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
Beacon beacon = new Beacon.Builder()
.setId1("FDA50693-A4E2-4FB1-AFCF-C6EB07647825")
.setId2("1000")
.setId3("2000")
.setManufacturer(0x004C)
.setTxPower(-59)
.setDataFields(Arrays.asList(new Long[] {0l}))
.build();
mBeaconTransmitter.startAdvertising(beacon);
However, I have not managed to attain the same result in XAMARIN (Visual Studio). I cannot detect created iBeacon on iPhone in this case:
var iBeaconParser = new BeaconParser();
iBeaconParser.SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24");
BeaconTransmitter beaconTransmitter = new BeaconTransmitter(ApplicationContext, iBeaconParser);
var beacon1 = new AltBeacon.Builder().SetId1("FDA50693-A4E2-4FB1-AFCF-C6EB07647825")
.SetId2("1000").SetId3("2000").SetTxPower(-59).SetManufacturer(0x004C).Build();
beaconTransmitter.StartAdvertising(beacon1);
The transmission also works in the second case. Other Android device could detect the created iBeacon. It was unsuccessful to detect the iBeacon on iPhone.
Thank you for any advice.

Hey buddy it's been almost 3 years you have ask this question so I don't know that is it still relevant for you or not but my be this will help others.
I have seen this code this is absolutely right for the beacon broadcasting and I will suggest to check that if you have bind IBeaconconsumer with beacon manage in the initialization function Bind((IBeaconConsumer)Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity); or check that if you have use _tagRegion and this refers to right one.
Hope this will help.

Related

Web Bluetooth - Show extra info on scanning dialog

I'm trying to support web-bluetooth to connect to my devices and perform a simple task (such as playing LED).
However, the device information showed on the scanning dialog when calling navigator.bluetooth.requestDevice is not so clear. It only shows the device name and a random (?) hex string.
The problem here is all my devices have the same name (AWESOME_LED), thus it's not easy for the user to select the correct LED if all scanning items show the same device name info. As far as I know, we can not custom to add more info showing on the scanning dialog.
I come up with a new solution that is changing the device name to unique for each LED with the format AWESOME_LED + [uniqueid] e.g AWESOME_LED1, AWESOME_LED2, AWESOME_LED3 so that the user can distinguish one from the others.
My question are:
Is there any alternative solution without making the device name unique?
If not, is there any problem / rejection / limitation from Apple or Google for my current app on App Store / Google Play by not using the same device name for all devices? I have been investigating it at Apple forums / Accessory Design Guidelines and looks like there are no problems, just to make sure if anyone has faced trouble from Apple / Google.
Thanks for your help.
Scanning dialog
My question are:
Is there any alternative solution without making the device name unique?
The browser prompt is not customisable yet. One solution you highlighted already is to make your LED device name unique. If you're able to control the device, why not having one AWESOME_DEVICE name and a GATT characteristic you can write to that controls individual LED colors. Maybe something like:
const device = await navigator.bluetooth.requestDevice({
filters: [{ name: "AWESOME_DEVICE" }],
});
const server = await device.gatt.connect();
const service = await server.getPrimaryService(0x1234); // Your service UUID
const characteristic = await service.getCharacteristic(0x5678); // Your characteristic UUID
// Set LED #1 to red color.
await characteristic.writeValue(
new Uint8Array(/*ledIndex=*/ 1, /*r=*/ 255, /*g=*/ 0, /*b=*/ 0)
);
If not, is there any problem / rejection / limitation from Apple or Google for my current app on App Store / Google Play by not using the
same device name for all devices? I have been investigating it at
[Apple forums][1] / [Accessory Design Guidelines][2] and looks like
there are no problems, just to make sure if anyone has faced trouble
from Apple / Google.
None that I'm aware of.

How do you detect whether your Mixed Reality app is running on HoloLens 1, HoloLens 2 or an immersive headset?

Mixed Reality apps can soon run on three kinds of devices: HoloLens 1, Hololens 2 and Immersive (VR) headsets. Some behavior will likely be different depending on the type of device you run the app on. How can I ask the SDK what kind of device my app is running currently on?
If you are using MRTK (I noticed you might based on your tag), then the best way to do this is by using platform capabilities utility, since that will work as new devices come out, and across platforms. For example, instead of checking "am on on HoloLens 2" you can check "does my device support articulated hands?". That will then work on other platforms that support articulated hands. For an example, chekc out MixedRealityToolkit.Examples/Demos/Utilities/Scenes/MixedRealityCapabilityDemo.unity in MRTK examples.
If you need a temporary solution for now to differentiate WMR from HL1 from HL2, you can use the following code. Note it's windows-only:
using Windows.Security.ExchangeActiveSyncProvisioning;
EasClientDeviceInformation CurrentInfo = new EasClientDeviceInformation();
string sku = CurrentInfo.SystemSku;
HoloLens 1, HoloLens 2, and Immersive headsets should all return different strings.
Edit 6/5/2020:
It's also possible to check the runtime platform as follows:
if (Application.platform == RuntimePlatform.WSAPlayerARM)
{
// Running HoloLens 2, most likely.
}
HolographicDisplay.GetDefault().IsOpaque is true for Immersive VR headsets and false for AR devices like HoloLens.
For HoloLens you don't need to detect a precise device family. Instead you should check the feature support via Universal Contract Version like
bool checkUniversalApiContract(int contractNumber)
{
return winrt::Windows::Foundation::Metadata::ApiInformation::IsApiContractPresent(L"Windows.Foundation.UniversalApiContract", contractNumber);
}
bool supportsHandTracking = checkUniversalApiContract(8);
To check whether it is opaque (VR) or not (AR):
#if UNITY_2017_2_OR_NEWER
bool isOpaque = UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque;
#else
bool isOpaque = UnityEngine.VR.VRDevice.isPresent;
#endif
To check whether it is HL1 or HL2, this is a simple solution, not requiring other dlls:
#if UNITY_WSA || UNITY_WSA_10_0
// Get vertical field of view in degrees
// HL1 == 17.5, HL2 == 29
bool isHL1 = (Camera.main.fieldOfView < 23f);
#endif

Is it possible to scan barcodes into a process in the background?

I'm making a gym management web app that handles sign-ins. Members have a barcode on a tag that they scan when they arrive to the gym.
I've heard that most barcode scanners simply act as a keyboard. This would require the scanning-in page to be open and in the foreground when a barcode is scanned.
If it's just a keyboard, how would I send the barcode scanner input to a single background process running on the computer, and have it ignore by all processes that may be in focus?
You're right that most scanner can support HID in keyboard emulation, but that's just the start.
If you want to have a bit more control over the data you can use a scanners that support the OPOS driver model.
Take a look at Zebra's Windows SDK to have a overview of the things that you can do. It may be a better solution than try to steal the barcode data coming in the OS as a keyboard entry to the foreground app.
Disclaimer: I work for Zebra Technologies
Other Barcode scanner vendor support a similar driver model.
I found an interesting post with a simple solution:
On the form constructor
InitializeComponent():
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Form1_KeyPress);
Handler & supporting items:
DateTime _lastKeystroke = new DateTime(0);
List<char> _barcode = new List<char>(10);
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
// check timing (keystrokes within 100 ms)
TimeSpan elapsed = (DateTime.Now - _lastKeystroke);
if (elapsed.TotalMilliseconds > 100)
_barcode.Clear();
// record keystroke & timestamp
_barcode.Add(e.KeyChar);
_lastKeystroke = DateTime.Now;
// process barcode
if (e.KeyChar == 13 && _barcode.Count > 0) {
string msg = new String(_barcode.ToArray());
MessageBox.Show(msg);
_barcode.Clear();
}
}
Credits: #ltiong_sh
Original post: Here
Use RawInput API (https://www.codeproject.com/Articles/17123/Using-Raw-Input-from-C-to-handle-multiple-keyboard#_Toc156395975) and check device ID for incoming keystrokes. Different devices have different IDs. You can also block keystrokes from scanner from reaching your application and interfering with input fields.
One thing you might want to add is option for user to identity which device is used as a barcode scanner. I did it by asking user to test-scan barcode with scanner on first application startup or in settings.
Works with any barcode scanner which outputs keystrokes.

Windows Phone 8.1 play audio data stream through speaker?

I receive over network PCM audio data stream and this part works fine so I am ending up with
DataReader incomming = args.GetDataReader();
byte[] RcvBuffer = new byte[incomming.UnconsumedBufferLength];
incomming.ReadBytes(RcvBuffer);
I have all audio data in buffer.
How I can play this through telephone Speaker ? Can you point me in some direction ?
Thanks
There're many ways to do that.
You can prepend the WAVE header to your data, and use MediaElement for playback, see the documentation for SetSource method.
If however by “telephone speaker” you mean the earphone, then it is only possible if you are creating a VoIP app.
It took a while but I sorted it, maybe someone else will need help in the future.
First Problem - since I just started app development for Windows Phone I have chosen Blank App (Windows Phone) instead Blank App (Windows Phone Silverlight) and I did not have access to many features that are available in Silverlight projects, so my suggestions for beginners: understand what each project is for.
Like Soonts said there are many ways to do this, this is one that I used.
I simplified this code and retyped this so there can be some typos.
using Microsoft.Xna.Framework.Audio;
using System.IO;
1) Create Stream to load your incoming data:
MemoryStream stream = new MemoryStream();
2) Load data from buffer to stream:
stream.Write(RcvBuffer, 0, RcvBuffer.Length);
3) I am using SoundEfect to play this through Loud-Speaker. Sample rate that I use is 8 kHz
SoundEffect sound;
sound = new SoundEffect(stream.toArray(), 8000, AudioChannels.Mono)
sound.Play();

MonoTouch: ESSession for external accessories

I am porting coding from Objective C to MonoTouch to use an external accessory. It is super basic coding, however when I create The EASession and try to use the InputStream or OutputStream, they are both NULL. I have used it in Objective-C so I know this should not happen.
I am able to repeatedly connect/disconnect the device and detect it. Now I just can't seem to read the data from the device because of this null issue. Below is my coding:
session = new EASession(acc, "com.idtechproducts.reader");
session.OutputStream.Delegate = streamDel; // Crashed saying OutputStream is null
session.OutputStream.Schedule (NSRunLoop.Current , "NSDefaultRunLoopMode");
session.OutputStream.Open ();
You need to list the external accessories you're going to use in your
Info.plist.
There is some documentation on this on apple's site:
http://developer.apple.com/library/ios/#featuredarticles/ExternalAccessoryPT/Introduction/Introduction.html#//apple_ref/doc/uid/TP40009502
Here is a screenshot of how to set this value in Info.plist:
http://screencast.com/t/AYmOWjf8wkL

Resources