Author Topic: BlueSmirf to Teensy controller help please  (Read 3565 times)

0 Members and 1 Guest are viewing this topic.

Offline Sirric

  • Thread Starter
  • Posts: 10
BlueSmirf to Teensy controller help please
« on: Mon, 09 February 2015, 19:27:06 »
I am trying to connect BlueSmirf to the tx/rx of my teensy. I am using the TMK_Keyboard onekey just for testing. I am not sure exactly what i need to change in the bluefruit controller to get it to work. I was wondering if someone can point me in the right direction?

I have been able to configure the teensy as a passthrough to the bluesmirf, so that i can connect to it in console and have it relay over bluetooth what i type. This was just a test/proof of concept.

I copied over some of the code from "M0110 to Bluetooth Project" as they appear to just want to communicate through the RX/TX. This uses the bluefruit module however, and doesn't work for me. I than saw a post from Smasher "Bluetooth HHKB Help" who uses the bluesmirf, however i am not sure what changes he mentioned need to be made.

I am not that good at the coding thing, atleast not c, so feel free to "over explain" if you have suggestions/pointers.

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: BlueSmirf to Teensy controller help please
« Reply #1 on: Mon, 09 February 2015, 19:44:21 »
I got class tonight but I will try to upload my changes when I get back.

I never bothered to get add all the other logic such as connecting/disconnecting devices, toggling modes, etc. But the transmitting over serial to the bluetooth module works fine. I hope that will help.

Offline Sirric

  • Thread Starter
  • Posts: 10
Re: BlueSmirf to Teensy controller help please
« Reply #2 on: Mon, 09 February 2015, 19:59:13 »
Smasher!

Yeah that would be amazing, you are the best! Yeah basic functionality is what im after at the moment. Ill feature creep it once i have a better understanding of what im doing.


Offline Sirric

  • Thread Starter
  • Posts: 10
Re: BlueSmirf to Teensy controller help please
« Reply #3 on: Wed, 11 February 2015, 15:57:24 »
Anyone have comments on their battery life? What are your settings (sleep/switch type/controller/battery/backlight?)

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: BlueSmirf to Teensy controller help please
« Reply #4 on: Thu, 12 February 2015, 01:43:49 »
Sorry, been busy with tests, essays, and minecraft. lol. I promise I will make the diff soon...

For your more recent question I would look at this. Hasu is using the same chip, just surface mount, instead of on a breakout board. https://geekhack.org/index.php?topic=56494.msg1595705#msg1595705

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: BlueSmirf to Teensy controller help please
« Reply #5 on: Thu, 12 February 2015, 20:14:44 »
Alright, here goes nothing. First off, all my changes were to an older version of Hasu's code so I'm not sure how much has changed.

I removed my personal layout changes. I also stripped out the matrix code, bootloader config, and other device specific stuff (if you need help using the teensy you might check my hhkb guide). What is left should is only related to the bluetooth.

I was also playing around with a bluetooth console before I stopped working on the project, but I stripped that out too as it was buggy and you said you already had your passthrough working. The serial code was acting strange for me so I used PJRC's sample uart code in place. You might be able to leave those changes alone. What is most relevant is the changes to the bluefruit files (bluesmirf uses the full packet headers, while the bluefruit uses a simpler header).

Here is the diff. Hope it helps you some... http://ix.io/giv

If you have any questions feel free to ask and I will try my best to reply if I know the answer. Good luck with your adventures :thumb:
« Last Edit: Thu, 12 February 2015, 20:17:31 by Smasher816 »

Offline Sirric

  • Thread Starter
  • Posts: 10
Re: BlueSmirf to Teensy controller help please
« Reply #6 on: Fri, 13 February 2015, 16:11:50 »
Hey Smasher,

Thanks a bunch for this. Ill look over it and hopefully get it incorporated into my code. Ill let you know how it goes over the weekend!

Thanks again!

Offline Sirric

  • Thread Starter
  • Posts: 10
Re: BlueSmirf to Teensy controller help please
« Reply #7 on: Mon, 16 February 2015, 02:57:19 »
I got a chance to look over the doc you sent. First off let me say again, thanks a bunch for the help. Like you mentioned, i think i will leave the uart stuff alone at first and see if i can get going without it. As for the simpler header changes, (i am terrible at c, im mostly a hardware hdl guy), I think the only thing i would need to change is the serial send commands line 406-410. With that i have to add the defines at the top (283-286), while removing pretty much the rest of the 243-282. Are our consumer keys mapped completely different, or was this something custom you had going on with your keyboard? (are the changes 351-362 specific to the bluesmirf?)

It looks like all the changes are in the bluefruit.c, i don't see any changes beyond the uart stuff (and testing code?) anywhere else.
All the changes in common.mk, print.h, uart.c/h, bluefruit.mk are for the modifications you had to do to your uart  it looks like.

You change the baud from 9600 to 115200 (Lines 179 in config.h) . Did you have to reconfigure the bluesmirf to operate at that, or was your HID module defaulted to that? I will have to check again but i think my pass through only did 9600, and i had to go into the command mode to change any of the bluetooth tx/rx settings ( the $$$ command mode thing ).

I cant say thank you enough for this, extremely awesome of you!

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: BlueSmirf to Teensy controller help please
« Reply #8 on: Mon, 16 February 2015, 18:12:33 »
The consumer commands are completely different. Both chips have their own arbitrary numbering system. You are correct that most of the changes are in bluefruit.c. I also made some changes to main.c like sending $$$C or whatever to cause to device to try to repair automatically.

I don't remember what the baud rate is but I do know that I used a usb->uart converter to play around with some of the settings on the device. Unfortunately I cannot remember everything I changed. It might be worth while to look over the documentation while you test it out. I remember some pairing modes had issues with certain devices.

Offline Sirric

  • Thread Starter
  • Posts: 10
Re: BlueSmirf to Teensy controller help please
« Reply #9 on: Fri, 20 February 2015, 13:59:35 »
Well i implemented the changes to the bluefruit.c module. Still no communication through bluetooth. I will need to go over the code a bit more and see if i messed up or missed something. Might also throw a logic analyzer on the tx of the teensy to make sure im getting the right packets. Compare that against the pass through output. Let me know if you have some other suggestions.

Offline Sirric

  • Thread Starter
  • Posts: 10
Re: BlueSmirf to Teensy controller help please
« Reply #10 on: Fri, 20 February 2015, 14:07:36 »
Where in the code sets it to output through the TX and RX pins of the teensy (PD2/3)?

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: BlueSmirf to Teensy controller help please
« Reply #11 on: Sat, 21 February 2015, 04:12:54 »
I would look at the serial defines in the header file and then just the serial source file. Iirc the code just calls serial send function, and doesn't need to specific any more.

Perhaps look at the configs for whatever keyboard used the bluefruit. That should atleast get you sending something over the lines. Then you change up the file some to use the bluesmirf style packets.