PHP extension doesn't work

Moderator: Telldus

Post Reply
kboek
Posts: 5
Joined: Fri Mar 17, 2023 9:45 am

PHP extension doesn't work

Post by kboek »

I created a PHP extension for Telldus, based on the code from developer.telldus.se (/trunk/bindings/php). My PHP directory is C:\php and the extension folder is C:\php\ext, the php.ini was edited to load the extension. The extension loads fine and I can call the functions without error. But nothing happens, and tdGetNumberOfDevices returns -1.

I remember having the same problem when using tdtool with a non-user (system) account in Win 7, can this be the same type of problem? How can I get around the UAC hassles in Win 7 and use tdtool (and most likely also the PHP extension) from a system account?
kboek
Posts: 5
Joined: Fri Mar 17, 2023 9:45 am

Re: PHP extension doesn't work

Post by kboek »

Found it :)

In the registry I had to find HKLM\Software\Telldus\Devices and set SharedDevices to 1. I had to redefine my devices in TelldusCenter (had only 2 devices so far, so that didn't matter). Now, I have a PHP extension that runs in a PHP server from where I can control the devices, without the need of calling tdtool.exe

I'll work this out a little further, my goal is to create an extension that IP-Symcon (http://www.ip-symcon.de) can use. Let me know if you're interested in the extension by replying in this thread, and I'll keep you informed
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: PHP extension doesn't work

Post by micke.prag »

How did you compile the extension under Windows?

To make the devices global across all users, set the value "My Comupter\HKEY_LOCAL_MACHINE\SOFTWARE\Telldus\Devices\SharedDevices" to "1" in the windows registry.
Micke Prag
Software
Telldus Technologies
kboek
Posts: 5
Joined: Fri Mar 17, 2023 9:45 am

Re: PHP extension doesn't work

Post by kboek »

I started with the "My first PHP extension" from Risman Adnan, then removed the sample methods and replaced it with the code from developer.telldus.se (/trunk/bindings/php), did this for both the header (.h) and code (.cpp) file. Then compiled the whole, and copied the dll to the PHP extensions folder.

I'd be happy to write a little guide with source code later on, but right now I'm still in the very alpha of getting things to work.
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: PHP extension doesn't work

Post by micke.prag »

Great, I will take a look at that. Sofar I have only been able to compile my extension on Linux.

I am not sure you know but yesterday I updated the extension to use all functions exported from telldus-core. Maybe your extension is based on the old with only a few functions available?
Micke Prag
Software
Telldus Technologies
kboek
Posts: 5
Joined: Fri Mar 17, 2023 9:45 am

Re: PHP extension doesn't work

Post by kboek »

I guess so yes, since I use the telldus-core that I downloaded about a week ago. It doesn't matter though, I started with the methods tdTurnOn and tdTurnOff and got those to work now. I'll extend it later with more (probably all supported) methods. But I just got to know that the extension must be compiled with Visual C++ 6.0 against PHP 5.3.1 in order to make it work in IP-Symcon, so I'm working on that first.

By the way, a PHP extension might not be the ideal solution for two-way communication, since a PHP extension can't listen for - and react on - events. I'm also thinking about if it would be possible to create a more direct plugin for IP-Symcon, and I posted a message about that on their forum as well.
Post Reply