picofuse-objc

Instance Methods | Class Methods | List of all members
NXNetworkInterface Class Reference

The Wi-Fi radio, as an event source of the application, which sends a target an NXNetworkEvent for each scan result, and as it joins, connects to, or leaves a network. More...

#import <Network/Network.h>

Inheritance diagram for NXNetworkInterface:
Inheritance graph
[legend]
Collaboration diagram for NXNetworkInterface:
Collaboration graph
[legend]

Instance Methods

(NXString *) - countryCode
 Returns its two-letter country code, such as "GB", or @"XX" for worldwide.
 
(BOOL) - setTarget:selector:
 Sets what's sent each event, or nil for none, and returns NO, changing nothing, if the selector isn't a method of the target which takes one object.
 
(BOOL) - scan
 Starts a scan, which sends an NXNetworkEventScanned for each network it finds, and then an NXNetworkEventScanDone, or returns NO if it's busy, joining or scanning already.
 
(BOOL) - joinNetwork:password:
 Starts joining a network, with a password, or nil for an open one, which sends NXNetworkEventJoining, and then NXNetworkEventConnected, or one which says why it couldn't, or returns NO if it's busy.
 
(BOOL) - leave
 Leaves the network it's joined, which sends NXNetworkEventDisconnected, or returns NO if it isn't joined to one.
 
(NXArray *) - addresses
 Returns its addresses, as strings, IPv4 first, which are empty until it's joined a network, or its own as an access point.
 
(BOOL) - startAccessPointWithName:password:
 Makes it an access point, which other devices join, with a name, and a password, which is WPA2, or nil for an open one, leaving any network it's joined; or returns NO, leaving it as it was, if it's already one, it can't be one, as on Linux, or the name or password won't do: a password is 8 to 63 characters. More...
 
(BOOL) - stopAccessPoint
 Stops it being an access point, so it can scan and join networks again, or returns NO if it isn't one.
 
(BOOL) - isAccessPoint
 Returns YES while it's an access point.
 
(BOOL) - isAttached
 Returns YES while it's attached to the application.
 
- Instance Methods inherited from NXObject
(void) - dealloc
 Frees the instance. More...
 
(NXZone *) - zone
 Returns the zone in which the instance was allocated. More...
 
(id) - retain
 Increases the retain count of the receiver. More...
 
(void) - release
 Decreases the retain count of the receiver. More...
 
(id) - autorelease
 Releases the receiver later, when the current autorelease pool of the thread is drained. More...
 
(id) - copy
 Returns a copy which can't be changed by anything else, which the caller owns and has to release. More...
 
(uintptr_t) - hash
 Returns a number for the object, which is the same for objects which are equal by isEqual:. More...
 
(NXString *) - description
 Returns a string which describes the instance, for logging. More...
 
- Instance Methods inherited from Object
(id) - init
 Initialize the instance, after allocation. More...
 
(Class) - class
 Returns the class of the instance. More...
 
(Class) - superclass
 Returns the superclass of the instance. More...
 
(BOOL) - isEqual:
 Compares the receiver to another object for equality. More...
 
(BOOL) - isKindOfClass:
 Returns a Boolean value that indicates whether the receiver is an instance of a given class. More...
 
(BOOL) - conformsTo:
 Checks if the receiver's class conforms to a protocol. More...
 
- Instance Methods inherited from <ObjectProtocol>
(BOOL) - respondsToSelector:
 Checks if the receiver responds to a selector. More...
 

Class Methods

(NXNetworkInterface *) + defaultInterface
 Returns the radio, for anywhere ("XX", worldwide), or nil if there isn't one, or it's already been made for another country.
 
(NXNetworkInterface *) + defaultWithCountryCode:
 Returns the radio, for a country, by its two-letter code, such as "GB" or @"US", or nil for worldwide; or nil if the code isn't two letters, there isn't a radio, or it's already been made for another country.
 
- Class Methods inherited from NXObject
(id) + alloc
 Allocates a new instance in the default zone, or if there isn't one, with sys_calloc(). More...
 
(id) + allocWithZone:
 Allocates a new instance in a specific zone. More...
 
(id) + new
 Allocates and initializes a new instance, as [[cls alloc] init] does. More...
 
(NXString *) + description
 Returns the name of the class.
 
- Class Methods inherited from Object
(void) + initialize
 Performs one-time initialization for the class. More...
 
(Class) + class
 Returns the class object. More...
 
(Class) + superclass
 Returns the superclass of the class. More...
 
(const char *) + name
 Returns the name of the class. More...
 
(BOOL) + conformsTo:
 Checks if the class conforms to a protocol. More...
 

Additional Inherited Members

- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

The Wi-Fi radio, as an event source of the application, which sends a target an NXNetworkEvent for each scan result, and as it joins, connects to, or leaves a network.

There's one, made by the first +defaultInterface or +defaultWithCountryCode:, which sets its country for as long as the program runs. There's none on a Mac, where the system manages Wi-Fi and these return nil, and an application uses the system's network as it is. On Linux, it's NetworkManager's Wi-Fi device, if there is one, whose country is the system's. Joining, and a fresh scan, need polkit's permission (see picofuse's README); without it, a scan reports the networks NetworkManager found last, so a scan which succeeds may not be a fresh one.

if (wifi == nil) {
[self start]; // the system's network
} else {
[wifi setTarget:self selector:@selector(network:)];
[wifi joinNetwork:[NXWirelessNetwork networkWithName:@"home"] password:@"secret"];
}
- (void)network:(NXNetworkEvent *)event {
if ([event type] == NXNetworkEventConnected) {
[self start];
}
}

The message is sent on any of the run loop's workers, while it's attached: once -[NXApplication detachEventSource:] returns, none is being sent, unless it was called from one.

Definition at line 46 of file NXNetworkInterface.h.

Method Documentation

◆ startAccessPointWithName:password:()

- (BOOL) startAccessPointWithName: (NXString *)  name
password: (NXString *)  password 

Makes it an access point, which other devices join, with a name, and a password, which is WPA2, or nil for an open one, leaving any network it's joined; or returns NO, leaving it as it was, if it's already one, it can't be one, as on Linux, or the name or password won't do: a password is 8 to 63 characters.

It sends no events while it's one, as the radio doesn't report who joins, and it can't scan or join a network until -stopAccessPoint.


The documentation for this class was generated from the following file: