You are not logged in.

#1 2009-05-24 19:29:49

DrMikeDuke
Member
From: Australia
Registered: 2008-05-12
Posts: 79
Website

Thinkpad Bluetooth

Hello,

I'm not sure if there is a need for this (being that you can write echo statements)
but I wrote a small C program which turns your bluetooth on and off and loads and unloads
the required modules into/out of the kernel.
It is written for an IBM X31 Thinkpad, but I suspect perhaps it may work just as well on any
lenevo/IBM thinkpad.

If anyones vaugely interested let me know smile


Workstation: Core i7 2600k | Asus PBZ68-V/GEN3 | 8GB DDR3-2000 | Gainward GLH GTX570 | Velociraptor 300 | AntecSS 850W | Essence ST | Corsair 800D | Win7x64 Pro/Arch LinuxX64
Server: 2x Six-Core AMD Opteron Processor 8439 SE, 64GB DDR2 ECC, Tyan S2932-SI, Areca ARC-1230 Raid, PCP&C 1Kw PSU, LSi FusionMPT Ultra320 SCSI/Tandberg LTO4 Autoloader
Laptop: Alienware M14xR3

Offline

#2 2009-05-24 20:02:45

Urfaust
Member
From: Germany
Registered: 2009-01-30
Posts: 164

Re: Thinkpad Bluetooth

Will it work on a SL500? This series is based on Ideapad firmware...
But I'll give it a try if it works...:D

Last edited by Urfaust (2009-05-24 20:34:36)

Offline

#3 2009-05-25 06:19:12

DrMikeDuke
Member
From: Australia
Registered: 2008-05-12
Posts: 79
Website

Re: Thinkpad Bluetooth

Hey,

Glad to see theres some interest! It'd be awesome if you could test that for me.
Im just on my way out at the moment I'll post details later today. Cheers!


Regards,

Mike.


Workstation: Core i7 2600k | Asus PBZ68-V/GEN3 | 8GB DDR3-2000 | Gainward GLH GTX570 | Velociraptor 300 | AntecSS 850W | Essence ST | Corsair 800D | Win7x64 Pro/Arch LinuxX64
Server: 2x Six-Core AMD Opteron Processor 8439 SE, 64GB DDR2 ECC, Tyan S2932-SI, Areca ARC-1230 Raid, PCP&C 1Kw PSU, LSi FusionMPT Ultra320 SCSI/Tandberg LTO4 Autoloader
Laptop: Alienware M14xR3

Offline

#4 2009-05-25 13:20:49

jouz
Member
Registered: 2009-04-16
Posts: 5

Re: Thinkpad Bluetooth

I own a x60s and would love to see what you did. Could you post your code on github or bitbucket?

Offline

#5 2009-05-30 13:12:45

DrMikeDuke
Member
From: Australia
Registered: 2008-05-12
Posts: 79
Website

Re: Thinkpad Bluetooth

Hello All,

Sorry Ive been *really* busy these past few. Anyhow. To give you an idea here is a *really* early implementation
of the little program I hacked out. Its not very clean but it works. I am currently testing the modular version of this
program which includes command line checking so you can use the -on -off functions from outside the program, useful
for scripts and so on, which I shall post in the coming week.
Please don't think too harshly of my little program its not too often I write C wink

/* ----------------------------------------------------------
-    BlueControl - An IBM ThinkPad bluetooth control utility
-  Version 0.1.0a
- M.Cockrem (mikecockrem@gmail.com) 
- Distributed under GPL 2
- No direct or implied fitness for any particular purpose
-----------------------------------------------------------*/

#include <stdio.h>
#include <string.h>

int menuchoice = 0;
int flag = 0;
FILE *fp;
char user[5];

int main()
{

    /* Establish if the user is root */
    printf("Checking for root privileges...\n");
    fp = popen("whoami", "r");
    fgets(user, sizeof user, fp);
    printf("Current User: %s\n", user);

    if((strcmp (user,"root")) == 0) 
    {
        //printf("debug %d\n", strcmp (user,"root")); /* Debug info */
        
        do
        {
            /* Title Screen */            
            system ("clear");    
            printf("\n");
            printf("Bluecontrol\n\n");
            printf(" /\\/\\\n");            
            printf("\(*'A')\n");    
         printf(" U U\n");
            printf("\n");  
            printf("Bluetooth chip control for IBM X-Series ThinkPads\(TM)\n");
            printf("\(C) Michael Cockrem 2009 ~ Version 1.2.1b \(b for eternal Beta)\n");
            printf("\n");
            printf("Menu\n----\n\n 0: off\n 1: on\n q: quit\n or h for help\n");    
            printf("Please confirm choice (and press return)\n");
            printf("\n");
            
            scanf("%c", &menuchoice);
            
            /* Quit */
            if(menuchoice == 'q')
            {
                printf("Quit Requested:\n");
                printf("Exiting, Goodbye.\n");
                flag = 3;
            }        
            
            /* Help */
            else if(menuchoice == 'h')
            {
                printf("Help\n\n");
                printf("This is a program designed to control the bluetooth module\n");
                printf("for the IBM X series and others with built in bluetooth modules\n");
                printf("(as part of IBM_ACPI) It has been tested on: IBM X31\n");
                printf("Please email the author with problems, suggestions or if you have\n");
                printf("used this program on another machine we have not yet tested!\n");
                printf("mikecockrem@gmail.com - All comments welcome\n");
                printf("\n\n");
                printf("Press 0 to disable bluetooth\n");
                printf("Press 1 to enable bluetooth\n");
                printf("Press q to quit the program\n");
                printf("Press h for help \(this screen!)\n");
                printf("\n");
                printf("[Enter] to continue\n");                
                getchar();
                getchar(); //dirty but who knows why it wont stay still: clean up in next version!
                flag = 0;        
            }                
            
            /* Bluetooth OFF */            
            else if(menuchoice == '0')
            {
                printf("Turning BlueTooth OFF\n");
                    system ("echo 0 >> /sys/devices/platform/thinkpad_acpi/bluetooth_enable");
                    printf("Unloading modules, byebye!\n");
                    system ("rmmod -v btusb");
                    system ("rmmod -v bluetooth");                
                    flag = 3;        
                }    

                /* Bluetooth ON */
                else if(menuchoice == '1')
                    {
                        printf("Turning BlueTooth ON\n");
                        system ("echo 1 >> /sys/devices/platform/thinkpad_acpi/bluetooth_enable");
                        printf("Loading Modules...\n");
                        system ("modprobe -v btusb");
                        system ("modprobe -v bluetooth");        
                        flag = 3;            
                    }    
                    
                    /* catch-all for invalid input */
                    else
                    {
                        printf("Error \(#2):\n\a You did not give valid input \(0, 1 or Q)\n Its REALLY not that hard...\n press enter\n");
                        getchar();                    
                        flag = 0;
                    }    
                
            
        }while(flag != 3); /* We won't leave the program 'till the user quits (and the 3 flag is set) */

    }
    
    /* Dumped here if not root */
    else
    {
        printf("BlueControl has encountered an error\a\n");        
        printf("oops!         \(#3):\n\a You must run this program as root!\n");
    }
    
    /* See ya! */
    printf("\n");
   printf("All done! Goodbye.\n");
    return(0);
}

Edit: Adding in to the next version better checking of file existance.
Can anyone tell me if sys/devices/platform/thinkpad_acpi/bluetooth_enable is a standard location across all thinkpads?
Any additional suggestions or better ways of doing things (no doubt there is) because speaking to others it seems theres no
good tool for doing just this out there atm.

Last edited by DrMikeDuke (2009-05-30 13:15:44)


Workstation: Core i7 2600k | Asus PBZ68-V/GEN3 | 8GB DDR3-2000 | Gainward GLH GTX570 | Velociraptor 300 | AntecSS 850W | Essence ST | Corsair 800D | Win7x64 Pro/Arch LinuxX64
Server: 2x Six-Core AMD Opteron Processor 8439 SE, 64GB DDR2 ECC, Tyan S2932-SI, Areca ARC-1230 Raid, PCP&C 1Kw PSU, LSi FusionMPT Ultra320 SCSI/Tandberg LTO4 Autoloader
Laptop: Alienware M14xR3

Offline

#6 2009-05-30 20:23:43

DrMikeDuke
Member
From: Australia
Registered: 2008-05-12
Posts: 79
Website

Re: Thinkpad Bluetooth

Confirmed Compatibility list

IBM Thinkpad X31
Lenovo Thinkpad T400 (Thanks unsaid)
Lenovo Thinkpad T500 (Thanks Samuele)

Last edited by DrMikeDuke (2009-05-31 01:44:36)


Workstation: Core i7 2600k | Asus PBZ68-V/GEN3 | 8GB DDR3-2000 | Gainward GLH GTX570 | Velociraptor 300 | AntecSS 850W | Essence ST | Corsair 800D | Win7x64 Pro/Arch LinuxX64
Server: 2x Six-Core AMD Opteron Processor 8439 SE, 64GB DDR2 ECC, Tyan S2932-SI, Areca ARC-1230 Raid, PCP&C 1Kw PSU, LSi FusionMPT Ultra320 SCSI/Tandberg LTO4 Autoloader
Laptop: Alienware M14xR3

Offline

#7 2009-05-30 20:36:08

BetterLeftUnsaid
Member
From: My Happy Place
Registered: 2007-11-04
Posts: 78

Re: Thinkpad Bluetooth

DrMikeDuke wrote:

I am currently testing the modular version of this program which includes command line checking so you can use the -on -off functions from outside the program

That would be awesome.


And everything seems to work perfectly with my T400.

Thanks!

Offline

#8 2009-05-30 22:27:13

Urfaust
Member
From: Germany
Registered: 2009-01-30
Posts: 164

Re: Thinkpad Bluetooth

DrMikeDuke wrote:

Can anyone tell me if sys/devices/platform/thinkpad_acpi/bluetooth_enable is a standard location across all thinkpads?

No it is not. I have a SL500 and this Series is based on Ideapad Firmware but sold as Thinkpad.
See: http://www.thinkwiki.org/wiki/Category:SL_Series

So I installed this driver: http://github.com/tetromino/lenovo-sl-l … ree/master (available in AUR). The path for activating Bluetooth here is /sys/devices/platform/lenovo-sl-laptop/rfkill/rfkill*/state. This may change in future versions according to the dev, see http://linux.derkeiler.com/Mailing-List … 06220.html for further documentation.

So your script won't work for me. hmm
Thanks for sharing anyway.

Offline

#9 2009-05-31 01:43:26

DrMikeDuke
Member
From: Australia
Registered: 2008-05-12
Posts: 79
Website

Re: Thinkpad Bluetooth

Urfaust wrote:
DrMikeDuke wrote:

Can anyone tell me if sys/devices/platform/thinkpad_acpi/bluetooth_enable is a standard location across all thinkpads?

No it is not. I have a SL500 and this Series is based on Ideapad Firmware but sold as Thinkpad.
See: http://www.thinkwiki.org/wiki/Category:SL_Series

So I installed this driver: http://github.com/tetromino/lenovo-sl-l … ree/master (available in AUR). The path for activating Bluetooth here is /sys/devices/platform/lenovo-sl-laptop/rfkill/rfkill*/state. This may change in future versions according to the dev, see http://linux.derkeiler.com/Mailing-List … 06220.html for further documentation.

So your script won't work for me. hmm
Thanks for sharing anyway.

I had a nifty idea for support of ANY laptop. Lets see how my implementation goes smile
i'll let this thread age untill I've got something to show you guys and I'll resurect it - Promise.


Workstation: Core i7 2600k | Asus PBZ68-V/GEN3 | 8GB DDR3-2000 | Gainward GLH GTX570 | Velociraptor 300 | AntecSS 850W | Essence ST | Corsair 800D | Win7x64 Pro/Arch LinuxX64
Server: 2x Six-Core AMD Opteron Processor 8439 SE, 64GB DDR2 ECC, Tyan S2932-SI, Areca ARC-1230 Raid, PCP&C 1Kw PSU, LSi FusionMPT Ultra320 SCSI/Tandberg LTO4 Autoloader
Laptop: Alienware M14xR3

Offline

#10 2009-05-31 09:36:58

Urfaust
Member
From: Germany
Registered: 2009-01-30
Posts: 164

Re: Thinkpad Bluetooth

Ok, cool.:D I look forward to read from you.

Offline

#11 2009-07-22 19:52:57

harbind
Member
Registered: 2009-05-08
Posts: 22

Re: Thinkpad Bluetooth

Seems to be working perfectly with my T40. Thanks DrMikeDuke

Offline

Board footer

Powered by FluxBB