Until now I have developed several programs to use in my Raspberry Rpi2 and RPi3 as BLE perifpherals using bleno.
Can anyone tell me if there is something alternative to Bleno, in Python or even better in C, to develop a code for a BLE peripherals service for my Raspberry?
I've had this same pain as you - trying to get a good BLE Peripheral role library for python - so I went ahead and ported Bleno to python2/3.
It's still a WIP, but the Echo demo works just fine.
https://github.com/Adam-Langley/pybleno/
And it's on pypi as "pybleno"
Of course, a big shout out to Sandeep Mistry for the fantastic original node codebase.
Hopefully people find it useful.
Well you can always use the HCI_CHANNEL_USER feature in Linux to talk to the Bluetooth controller directly (from C for example). In fact that's exactly what bleno does. Just follow the HCI protocol in the Bluetooth specification.
I can't give you answers for C, but bluepy seems to be the best in breed for speaking to BLE peripherals (as bleno does) right now, and if you want to use core mode, there's Adafruit's BlueFruit LE.
Caveat: I'm only getting my feet wet with Pi peripherals myself and don't have any successful projects with either of these yet.
There isn't a library written in C as far as I know, but here's an interesting place to start:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/ (especially interesting are: doc/mgmt-api.txt, doc/gatt-api.txt for LE things)
There seem to be two interfaces to do Bluetooth stuff: D-Bus and HCI sockets.
HCI sockets are actual C socket()s with the special AF_BLUETOOTH domain (http://man7.org/linux/man-pages/man2/socket.2.html is kind of helpful for explaining this).
And you can use org.bluez.* for higher-level interfacing using D-Bus.
Getting all of that to work would be probably a nightmare, and all of the other Python libraries probably work fine. If you want higher performance, you could totally get something to work in C or Rust, and all you should need is sockets and D-Bus, it just sounds really really hard.
Related
I'm looking to see if there is a way to connect or disconnect to a wireless network in python, preferably a way that would work for both public and secured networks if I supplied the password. If I can configure the options about wireless, that would be an added bonus (ex. see all networks in range, see information about networks in range (like encryption type)). I run a windows computer, so I see many answers to this question in Linux, or other operating systems, but none in windows. Thanks in advance.
You'll probably have to use one of the DLLs in windows for that. Using ctypes you can get access to the win32 API from Python.
It looks like the functions from wlanapi.dll, starting with WlanOpenHandle and WlanEnumInterfaces might do what you want.
Edit: For example code, see the accepted answer to this.
I have a robotics type project with an Arduino Uno, and to make a long story short, I am experimenting with some AI algorithms. However, I need to implement some high level matrix algorithms that would be quite simple using NumPy/SciPy, but they are an utter nightmare in C or C++. Even with the libraries out there, this is just getting ridiculous.
Is there any way I can do this project in Python? I think I heard something about the Mega having this capability, but I have an Uno, and replacing it is not an option at this point (that would set the project back quite a bit.) Also, I heard somethings about using Python to communicate to the Arduino via USB, but I cannot have the USB cable in while the thing is running. I need to be able to upload the program and be done with it.
Are there any options out there, or have I just reached a dead end?
There was a talk about using Python with robotics at this years PyConAU called Ah! I see you have the machine that goes 'BING'! by Dr. Graeme Cross.
The only option he recommended for using Python on a microcontroller board was PyMite which I think also goes by the name of Python-On-A-Chip.
It has been ported to a range of boards - specifically he mentions the Arduino Mega which you said is not an option for you, but it is possible it is supported on other Arduino boards.
However, because it is a "batteries not included" version of Python it is more than likely that you will have a real problem getting numpy/scipy etc up and running.
As other posters have suggested, implementing in C might be the path of least resistence.
Update: again, not specifically for Arduino, but pyMCU looks to provide python on a chip. The author states he may look at developing an Arduino version of pyMCU if there is enough interest.
I've started work on a "Little Python" to C++ (called Pyxie - a play on Py CC- Pyc-C) compiler, with the specific aim of compiling a sane subset of python to C++ such that it can run on an arduino.
This is far from complete at time of writing (0.0.16), but it can currently compile a very small subset of python - enough for the arduino "blink" example to run. To support this, it has a compilation profile - which essentially means "compile using the arduino toolchain."
A program it can compile looks like this:
led = 13
pinMode(led, OUTPUT)
while True:
digitalWrite(led, HIGH)
delay(1000)
digitalWrite(led, LOW)
delay(1000)
This parses, performs analysis (like type inference, etc), compiles to C++, which is then compiled to a hex file, which you can load onto your device.
There's a long way to go before it's useful, but it is progressing and does have a roadmap/etc.
PyPI - http://pypi.python.org/pypi/pyxie
Homepage - http://www.sparkslabs.com/pyxie/index.html
In particular a key difference from Micropython (and PyMite) is that it's designed to compile to devices too small to run either implementation. (This also means it's very different from things like ShedSkin which while a Python to C++ compiler target larger execution environments)
It's going to be difficult to get any kind of Python script running directly on the Arduino uno.Reason is that it is an interpreted language, so you will need a interpreter on-board in addition to the plain text script. There is probably not going to be enough memory for all of thatin arduino uno.
What you can do best is to find a way to compile a Python script to native machine code (this is how C/C++ works). I have seen projects around to do something like that for other platforms, but (as far as I know) none which does it successfully for Arduino uno yet.
you can visit http://www.toptechboy.com/using-python-with-arduino-lessons/ for more.
wish this will help you.
thanks!
This is not a direct solution but in your circumstances If I were you, I would write the AI program on my computer and the rest of it in Arduino. after that I would write a flask server with my AI program. and then, port forward from my router to the local machine. finally, make requests from Arduino to the server.
I would like to know if there are any API's for python to programmatically control a phone, like starting and ending calls, but also to record conversations.
I would also like to use the Headphones and Mic of the computer to talk over the phone.
Any info would be great, I tried googling for something, but nothing useful came up.
Be careful when using PyBluez! The results will actually depend on the BT-USB dongle you are using. Depending on the hardware(the BT chip in there), PyBluez will use one or another BT stack - for example there was one from WIDCOMM. Results will vary, as PyBluez is actually wrapping around those stacks - all of which are far from complete.
So, when you have a working project, be sure to know what actual BT stack you were using :)
For Python audio stuff, you could try this.
PyBluez is an effort to create python wrappers around system Bluetooth resources to allow Python developers to easily and quickly create Bluetooth applications.
Unfortunately I've not found a page dedicated to its features, but it could be a good starting point, whether everything you need is in its feature set, or if you could build your application upon it by extending it.
http://code.google.com/p/pybluez/
Okay, so not strictly a programming question BUT the point is I want to integrate my new building's business access/alarm system into the rest of my *NIX setup at my business. I do NOT want to use some cruddy windows GUI program written for Windows XP SP1 that manages a bare circuit-board via a serial connection and provides absolutely zero APIs. There's got to be something decent out there!
Any decent access/alarm hardware vendors out there? I'd love to interface via python, perl, ruby, etc. to some nice control panel that has an integrated NIC. Heck, I'd even settle for some CLI tool that I could at least exec and parse.
We've got mag card readers on doors/elevators, mag locks, rex's, fingerprint readers, etc. for our access.
We've got standard door/window, motion, etc. for our alarm.
Hardware vendor suggestions?
What is you physical location? If europe you could have a look at EIB-Technologies. Just google for EIB and you'll see many answers for your question. EIB stands for European Installation Bus. It is a technology used for controlling almost everything in buildings (light, alarms, aircon, etc...) using a bus and centralized control centers. Depending on technology providers you'll also have interfaces to *nix systems.
have a look at e.g. link text
Does this answer your question?
What do you actually want to do with your integrated system?
Two of my former employers developed access control systems, both running on Windows. Both provided a programmatic API (DCOM or TCP socket.) *NIX support was another matter, but you avoid the hardware interfacing problem, at least.
One was Honeywell, but that's designed for big systems and will probably be out of your price (and complexity) range. The other (a small startup) doesn't support all of the devices you list.
If your building wiring is RS485, you're unlikely to be allowed to interface over that. Ethernet to the access control software is your best bet.
Ethernet-connected devices have traditionally been uncommon as the configuration is tricky; your typical alarm installer doesn't know about IP addresses, subnets, switches and whatnot.
I suppose the way to go will be DPWS; as Windows provides built-in support for this now, you can expect hardware vendors to jump on the bandwagon.
I ended up finding some good hardware by eData that was run off of embedded Linux with ssh, SOAP, REST, and Web GUI access. Unfortunately the integrator bid way too high and wouldn't commit to working in our time frame, so we ended up with the crappy Kantech stuff. Yay serial cables. :-(
Is there a way to accept input from more than one mouse separately? I'm interested in making a multi-user application and I thought it would be great if I could have 2 or more users holding wireless mice each interacting with the app individually with a separate mouse arrow.
Is this something I should try to farm out to some other application/driver/os_magic? or is there a library I can use to accomplish this? Language isn't a HUGE deal, but C, C++, and Python are preferrable.
Thanks :)
edit:
Found this multi-pointer toolkit for linux (it's actually a multi-pointer x server):
http://wearables.unisa.edu.au/mpx/
You could try the Microsoft Windows MultiPoint Software Development Kit 1.1
or the new
Microsoft Windows MultiPoint Software Development Kit 1.5
and the main Microsoft Multipoint site
Yes. I know of at least one program that does this, KidPad. I think it's written in Java and was developed by Juan Pablo Hourcade, now at the University of Iowa. You'd have to ask him how it was implemented.
http://code.google.com/p/pymultimouse/ is a library using windows raw input, it worked in a test with 2 mice.
You could use DirectInput with C/C++ (there's probably also bindings in other languages). You use IDirectInput8::EnumDevices() (using DX8; same function, different interface in other versions of DirectX) to get a list of all attached devices. Then, you create the devices and poll them IDirectInputDevice8::Poll(). This should almost definitely work with any number of mice, keyboards, and other input devices. MSDN has really good documentation on this.
I have this vague feeling that BeOS used to let one pair a mouse and keyboard and have separate active windows and inputs. Wow... that was a long time ago. I thought that it would be very interesting for "paired" programming.
See my answer here (avoid the JNI stuff): How can I handle multiple mouse inputs in Java?