Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build with Windows VisualStudio 2010. #64

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

rti7743
Copy link

@rti7743 rti7743 commented Nov 23, 2016

I changed it so that it can build with Windows VisualStudio 2010.

*detail
In VisualStudio 2010, since initialization can not be done simultaneously with the declaration of member variables, we changed the initialization method.

In windows, since socket can not be manipulated by read / write, it changed to recv / send.

In windows, since socket is closed with "closesocket" instead of "close", we added ifdef.

I made a simple pthread compatibility routine.

We prepared the same as unistd.h.(This is based on what this person made. http://d.hatena.ne.jp/deraw/20070517/1179334643 )

When building with windows, I use Bonjour SDK for Windows instead of avahi. However, since this is done in VisualStudio's project settings, there is nothing to modify the source code.

Changed the position of #include "ed25519-randombytes.h" in ed25519.c because of winsock include order.

With VisualStudio 2010, since inline specification did not go well, I dropped inline from chacha20_simple.c only with windows ifdef.

Removed _P () from srp / srp.h. With VisualStudio, we could not compile without removing it.

I wrote an explanation on my blog.( Japanese )
http://d.hatena.ne.jp/rti7743/20161124

mizyanlu and others added 9 commits June 22, 2016 10:53
I changed to setting that does not depend on Configuration.h.
This is to make it easier to reuse modules.
Specifically, we made it possible to pass information in PHKNetwork IP class constructor.
Example.
PHKNetworkIP networkIP(deviceName,devicePassword,deviceIdentity,controllerRecordsAddress);
do {
    networkIP.handleConnection();
} while (true);

2.
I made PHKControllerRecord.cpp from a function to a class.
This is to make it possible to pass the path saving vector <PHKKeyRecord> from outside by changing (1).

The PHKControllerRecord class delegates administration to the AccessorySet.
This is because AccessorySet is singleton so it is easy to use.
Originally, I want it under PHKNetworkIP, but since it is hard to modify, I delegated to AccessorySet for the time being.

3.
I changed have taken measures against buffer overrun of scanf.
Example.
We changed it as

char buf[10];
sccanf(a, "%s", buf);

 --->

char buf[10+1];
sccanf (a, "%10s", buf);

4.
Changed it to a code that is harder to leak memory.
Example.
We changed it as

char* a = new[100];

 --->

vector<char> a_vec(100); char* a = &a_vec[0];

If secured with vector<char>, it is safe because you do not have to delete it.

5.
I introduced AccessorySetAutoLock autolock; to avoid forgetting mutex lock release.
When you leave the scope, it automatically releases the mutex.
{
   lock

   ....

   unlock
}

---->

{
   AccessorySetAutoLock autolock

   ....
} //auto unlock

6.
I changed the method of initialization.
I use this as C ++ will initialize.
char a[100]; bzero(b,100);

----->

char a[100] = {0};
(It is very easy because C ++ will initialize without permission.)

7.
Fixed a problem that boolCharacteristics "1" can not be judged as true.

8.
Added PHKNetworkIP::closeAcceptConnection command to end accept loop.
Now you can stop with CTRL + C, and reusability as a module increases.

For details,plasess see the end of main.cpp.

PHKNetworkIP networkIP(deviceName,devicePassword,deviceIdentity,controllerRecordsAddress);
do {
    networkIP.handleConnection();
} while (true);

//if you running PHKNetworkIP new accept thread,
//call PHKNetworkIP::closeAcceptConnection to stop.

9.
To fix memory leak, we fixed to release memory when releasing Service and Characteristics.

10.
Uint8 Characteristic support added.
(However, perhaps, this may not be necessary ...?? )

11.
We have supported the number of digits up to 8 digits.
(Question: Why are you making three digits, why do you have [3] a reason?)

char buf[3];
snprintf(buf,3,"%d",intValue);

--->

char buf[8];
snprintf(buf, 8, "%d", intValue);

(I wrote this sentence using google translation. Sorry if we had funny English.)
…was the same as snprintf's behavior and safe.
Fixed Windows WinsockStartup
 - Adding pthread_detach
 - Fix srp_free leak
@etwmc
Copy link
Owner

etwmc commented Feb 1, 2017

You disabled the broadcastMessage(). But you can't get status notification without it.

@rti7743
Copy link
Author

rti7743 commented Feb 1, 2017

Thank you for reply.
Even without broadcastMessage (), I think that the state is correctly taken.
Ios 10 Home application works correctly.
Which environment is problematic if there is no broadcastMessage ()?

@etwmc
Copy link
Owner

etwmc commented Feb 3, 2017

The state can be fetch fine (as the device carry out the changes would receive the 204, and any devices display the status view would fetch the value again before showing), but the HomeKit will not be notified any changes in the background.
So, it won't work on sensory triggered push notification and automation. (So, something like turn on the light if the sensor is triggered etc)

@rti7743
Copy link
Author

rti7743 commented Feb 3, 2017

it won't work on sensory triggered push notification and automation

sorry,I did not try it.

but...,I lent my ipad mini for the display of our product.
Therefore, it can not be verified and corrected immediately.

I wish I had received an answer a little earlier, around the New Year holidays....
I lent it out in the middle of January.

If possible, I'd be happy if you merge it except for the part that you want to erase broadcastMessage ().

I will consult with the person who lends my ipad mini to get it back as soon as possible.
but, it will take some time....

@etwmc
Copy link
Owner

etwmc commented Feb 4, 2017

I think you can test it with iPhone Stimulator?
I haven't get any Github messages since last September, so I might drop the ball when I manually check the Github notification list when I'm half awake -_-

@rti7743
Copy link
Author

rti7743 commented Feb 6, 2017

I revived broadcastMessage()
e8a2945

I found an old ipad mini (ios 9), so I useed Insteon+ and tested the operation.

I added pthread_detach to announce().
(Otherwise it will leak memory.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants